Add deregistration
This commit is contained in:
parent
5a1d5713e6
commit
a3891494af
5 changed files with 38 additions and 17 deletions
|
@ -9,10 +9,13 @@
|
|||
<ul>
|
||||
{% for x in events %}
|
||||
<li id="{{x.event.id}}">
|
||||
{{ x.event.date|date:"d F Y" }}, {{ x.event.time_str }}{% if x.event.note %}, <b>{{ x.event.note }}</b>{% endif %}
|
||||
<h3>{{ x.event.date|date:"d F Y" }}, {{ x.event.time_str }}{% if x.event.note %}: <b>{{ x.event.note }}</b>{% endif %}
|
||||
{% if user.is_staff %}
|
||||
<a href="/admin/events/event/{{ x.event.id }}/change/">Edit</a>
|
||||
{% endif %}
|
||||
{% endif %}</h3>
|
||||
|
||||
<p>Verantwoordelijke: {{ x.event.responsible_person.username }}</p>
|
||||
|
||||
{% include "events/registrations.html" with event=x.event my_registration=x.my_registration %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{% if not my_registration %}
|
||||
<form action="{% url 'events:register' event.id %}" method="post">
|
||||
{% else %}
|
||||
<form action="{% url 'events:deregister' event.id %}" method="post">
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
<p>Verantwoordelijke: {{ event.responsible_person.username }}</p>
|
||||
|
||||
<p>{{ event.count_admitted }}/{{ event.capacity }} bevestigd{% if event.count_interested %},
|
||||
{{ event.count_interested }} op wachtlijst
|
||||
{% endif %}
|
||||
|
@ -14,6 +16,6 @@
|
|||
{% elif not my_registration %}
|
||||
<p><input type="submit" value="Ik wil komen"></p>
|
||||
{% else %}
|
||||
<p>Mijn status: {{ my_registration.state_str }} <input type="button" disabled="disabled" value="Uitschrijven (todo)"></input></p>
|
||||
<p>Mijn status: {{ my_registration.state_str }} <input type="submit" value="Uitschrijven"></input></p>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
|
|
@ -5,6 +5,7 @@ from . import views
|
|||
app_name = "events"
|
||||
urlpatterns = [
|
||||
path("", views.index, name="index"),
|
||||
path("<int:event_id>/", views.register, name="register"),
|
||||
path("<int:event_id>/register", views.register, name="register"),
|
||||
path("<int:event_id>/deregister", views.deregister, name="deregister"),
|
||||
path("test/", views.view_score_stuff, name="score_stuff"),
|
||||
]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from django.http import HttpResponseRedirect
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
|
||||
from django.utils import timezone
|
||||
|
@ -27,15 +27,26 @@ def view_score_stuff(request):
|
|||
|
||||
|
||||
def register(request, event_id):
|
||||
if request.method == "POST":
|
||||
if not request.user.has_ugent_info:
|
||||
raise ValueError("User has missing UGent info missing")
|
||||
if request.method != "POST":
|
||||
return HttpResponse(status_code=405)
|
||||
|
||||
event = get_object_or_404(Event, id=event_id)
|
||||
if not request.user.has_ugent_info:
|
||||
raise ValueError("User has missing UGent info missing")
|
||||
|
||||
event.eventregistration_set.create(
|
||||
state=EventRegistration.INTERESTED,
|
||||
event=event,
|
||||
user=request.user,
|
||||
)
|
||||
return HttpResponseRedirect(reverse("events:index") + f"#{event.id}")
|
||||
event = get_object_or_404(Event, id=event_id)
|
||||
|
||||
event.eventregistration_set.create(
|
||||
state=EventRegistration.INTERESTED,
|
||||
event=event,
|
||||
user=request.user,
|
||||
)
|
||||
return HttpResponseRedirect(reverse("events:index") + f"#{event.id}")
|
||||
|
||||
|
||||
def deregister(request, event_id):
|
||||
if request.method != "POST":
|
||||
return HttpResponse(status_code=405)
|
||||
|
||||
registration = get_object_or_404(EventRegistration, event=event_id, user=request.user)
|
||||
registration.delete()
|
||||
return HttpResponseRedirect(reverse("events:index") + f"#{event_id}")
|
||||
|
|
|
@ -14,6 +14,10 @@ a {
|
|||
color: #afafaf;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
|
||||
header {
|
||||
color: #141313;
|
||||
|
|
Loading…
Reference in a new issue