32 lines
930 B
Python
32 lines
930 B
Python
from django.http import HttpResponseRedirect
|
|
from django.shortcuts import render, get_object_or_404
|
|
from django.utils import timezone
|
|
from django.urls import reverse
|
|
import datetime
|
|
|
|
from .models import Event, EventRegistration, CustomUser
|
|
|
|
from events.tasks import assign_reservations
|
|
|
|
|
|
def index(request):
|
|
events = Event.objects.filter(date__gte=timezone.now().date()).order_by("date")[:20]
|
|
return render(request, "events/index.html", {"events": events})
|
|
|
|
|
|
def view_score_stuff(request):
|
|
return HttpResponse(
|
|
assign_reservations()
|
|
)
|
|
|
|
|
|
def register(request, event_id):
|
|
if request.method == "POST":
|
|
event = get_object_or_404(Event, id=event_id)
|
|
|
|
event.eventregistration_set.create(
|
|
state=EventRegistration.INTERESTED,
|
|
event=event,
|
|
user=CustomUser.objects.get(),
|
|
)
|
|
return HttpResponseRedirect(reverse("events:index") + f"#{event.id}")
|