def prepay(request, event_id): """ Prepay to attend an event """ event = get_object_or_404(Event, pk=event_id) if not event.can_prepay: messages.error(request, "Error: Pre-payments are not accepted.") return redirect('event_details', event_id=event_id) user_register_count = Attendance.objects.filter(user=request.user, event=event).count() if user_register_count != 0: messages.error(request, "Error: User has already prepaid for this event.") return redirect('event_details', event_id=event_id) timestamp = timezone.now() #timestamp = timestamp.replace(tzinfo=timezone.utc) attendance = Attendance(user=request.user, event=event, prepaid=True, date_registered=timestamp) attendance.save() return redirect('event_details', event_id=event_id)
def approve_event(request, event_id): """ Set the status of an event reservation to 'approved' and redirect to pending events page """ if not request.user.is_staff: raise Http404 event = get_object_or_404(Event, pk=event_id) event.reservation.status = status_const.APPROVED event.reservation.save() date = timezone.now() new_attendee = Attendance(user=event.creator, event=event, prepaid=False, date_registered=date) new_attendee.save() return redirect('pending_events')
def approve_event(request, event_id): """ Set the status of an event reservation to 'approved' and redirect to pending events page """ if not request.user.is_staff: raise Http404 event = get_object_or_404(Event, pk=event_id) event.reservation.status = status_const.APPROVED event.reservation.save() date = timezone.now() new_attendee = Attendance(user=event.creator, event=event, prepaid=False, date_registered=date ) new_attendee.save() return redirect('pending_events')
def attend(request, event_id): """ Register to attend an event """ event = get_object_or_404(Event, pk=event_id) user_register_count = Attendance.objects.filter(user=request.user, event=event).count() if user_register_count != 0: messages.error(request, "Error: You are already attending this event.") return redirect('event_details', event_id=event_id) timestamp = timezone.now() #timestamp = timestamp.replace(tzinfo=timezone.utc) attendance = Attendance(user=request.user, event=event, prepaid=False, date_registered=timestamp) attendance.save() return redirect('event_details', event_id=event_id)