Skip to content

Commit

Permalink
Show error when Keen Form "Invite Friends Only" checked but no friend…
Browse files Browse the repository at this point in the history
…s selected

resolves #87
  • Loading branch information
nworbnhoj committed Dec 29, 2024
1 parent 76664be commit 76806dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions player/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ def clean(self):
"place",
'Sorry, that Venue selection did not work. Please try again.'
)
if 'reveal_friends' in self.data:
if len(cleaned_data['friends']) == 0:
self.add_error(
'friends',
'Please invite at least one Friend.'
)

def clean_place(self):
place_id = self.cleaned_data.get('place')
Expand Down Expand Up @@ -541,6 +547,7 @@ def post(klass, request_post, player):
tomorrow.set_hour(hr)
friends = []
if 'reveal_friends' in request_post:
form.fields['friends'].reveal_checked = 'checked'
friends = form.cleaned_data['friends']
context = {
'friends': [ Player.objects.get(pk=f) for f in friends ],
Expand Down

0 comments on commit 76806dd

Please sign in to comment.