def reply_to_event(request, event_id): event = get_object_or_404_and_check_access(request, Event, pk=event_id, command="view") try: reply = Reply.objects.get(event=event, user=request.user) except Reply.DoesNotExist: reply = Reply(event=event, user=request.user, choice="-", inviter=request.user) import django.forms class ReplyForm(django.forms.Form): choice = django.forms.ChoiceField( choices=(("Y", "Yes"), ("N", "No"), ("?", "?")), label=_("Choice"), help_text=_("Will you participate in this event?"), widget=django.forms.RadioSelect, ) comment = django.forms.CharField( required=False, label=_("Comment"), help_text=_("Leave a comment with your reply") ) if request.POST: form = ReplyForm(request.POST) if form.is_valid(): reply.choice = form.cleaned_data["choice"] reply.comment = form.cleaned_data["comment"] reply.save() from curia.times import set_time_on set_time_on(event) return HttpResponseRedirect("/calendars/agenda/") else: form = ReplyForm(initial={"choice": reply.choice, "comment": reply.comment}) return render_to_response(request, "calendars/reply.html", {"form": form})
def reply(request, event_id, new_reply): event = get_object_or_404_and_check_access(request, Event, pk=event_id, command='view') try: reply = Reply.objects.get(event=event, user=request.user) except Reply.DoesNotExist: reply = Reply(event=event, user=request.user, choice='-', inviter=request.user) if new_reply == 'U': new_reply = '?' if new_reply == 'Y' or new_reply == 'N' or new_reply == '?': reply.choice = new_reply reply.save() from curia.times import set_time_on set_time_on(event) return HttpResponseRedirect('/calendars/agenda/')
def reply(request, event_id, new_reply): event = get_object_or_404_and_check_access(request, Event, pk=event_id, command="view") try: reply = Reply.objects.get(event=event, user=request.user) except Reply.DoesNotExist: reply = Reply(event=event, user=request.user, choice="-", inviter=request.user) if new_reply == "U": new_reply = "?" if new_reply == "Y" or new_reply == "N" or new_reply == "?": reply.choice = new_reply reply.save() from curia.times import set_time_on set_time_on(event) return HttpResponseRedirect("/calendars/agenda/")
def reply_to_event(request, event_id): event = get_object_or_404_and_check_access(request, Event, pk=event_id, command='view') try: reply = Reply.objects.get(event=event, user=request.user) except Reply.DoesNotExist: reply = Reply(event=event, user=request.user, choice='-', inviter=request.user) import django.forms class ReplyForm(django.forms.Form): choice = django.forms.ChoiceField(choices=(('Y', 'Yes'), ('N', 'No'), ('?', '?'),), label=_('Choice'), help_text=_('Will you participate in this event?'), widget = django.forms.RadioSelect) comment = django.forms.CharField(required=False, label=_('Comment'), help_text=_('Leave a comment with your reply')) if request.POST: form = ReplyForm(request.POST) if form.is_valid(): reply.choice = form.cleaned_data['choice'] reply.comment = form.cleaned_data['comment'] reply.save() from curia.times import set_time_on set_time_on(event) return HttpResponseRedirect('/calendars/agenda/') else: form = ReplyForm(initial={'choice':reply.choice, 'comment':reply.comment}) return render_to_response(request, 'calendars/reply.html', {'form': form})