def attend_event(request, event_id, is_going): event = Event.objects.get(pk=event_id) attendence = Attendence.objects.filter(event__pk = event.id, participant__pk = request.user.id) user = request.user is_going = is_going.upper() if not Attendence.is_valid_participation(is_going): raise Http404 if not attendence.exists(): new_attendence = Attendence() new_attendence.participant = user new_attendence.event = event new_attendence.participation = is_going new_attendence.save() elif attendence.exists(): att = attendence[0] att.participation = is_going att.save() return HttpResponseRedirect(("../../../{}").format(event.id))
def attend_event(request, event_id, is_going): event = Event.objects.get(pk=event_id) attendence = Attendence.objects.filter(event__pk=event.id, participant__pk=request.user.id) user = request.user is_going = is_going.upper() if not Attendence.is_valid_participation(is_going): raise Http404 if not attendence.exists(): new_attendence = Attendence() new_attendence.participant = user new_attendence.event = event new_attendence.participation = is_going new_attendence.save() elif attendence.exists(): att = attendence[0] att.participation = is_going att.save() return HttpResponseRedirect(("../../../{}").format(event.id))