diff --git a/events/views.py b/events/views.py index 43b15c5..13b23bf 100644 --- a/events/views.py +++ b/events/views.py @@ -120,11 +120,20 @@ def attend_event(request, event_id): if request.user.is_anonymous: messages.add_message(request, messages.WARNING, message=_("You must be logged in to say you're attending.")) return redirect(event.get_absolute_url()) - if request.user.profile in event.attendees.all(): - messages.add_message(request, messages.INFO, message=_('You are already attending this event.')) - return redirect(event.get_absolute_url()) - new_attendee = Attendee.objects.create(event=event, user=request.user.profile, role=Attendee.NORMAL, status=Attendee.YES) - messages.add_message(request, messages.SUCCESS, message=_("We'll see you there!")) + + try: + attendee = Attendee.objects.get(event=event, user=request.user.profile) + except: + attendee = Attendee(event=event, user=request.user.profile, role=Attendee.NORMAL) + + attendee.status = Attendee.YES + if request.GET.get('response', None) == 'maybe': + attendee.status = Attendee.MAYBE + if request.GET.get('response', None) == 'no': + attendee.status = Attendee.NO + attendee.save() + if attendee.status == Attendee.YES: + messages.add_message(request, messages.SUCCESS, message=_("We'll see you there!")) return redirect(event.get_absolute_url()) def comment_event(request, event_id): diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html index 090179f..39fb079 100644 --- a/get_together/templates/get_together/events/show_event.html +++ b/get_together/templates/get_together/events/show_event.html @@ -102,33 +102,41 @@

{{ event.name }}

Hosted by {{ team.name }}

- {% if can_edit_team or is_email_confirmed %} - Invite - {% endif %} - {% if settings.SOCIAL_AUTH_TWITTER_KEY %} - Tweet - {% endif %} - {% if settings.SOCIAL_AUTH_FACEBOOK_KEY %} - Share - {% endif %} - {% if settings.SOCIAL_AUTH_LINKEDIN_KEY %} - Share - {% endif %} - {% if not is_attending %} - Attend - {% endif %} - {% if can_edit_event %} -