Commit f856dd47 authored by Stefano Rivera's avatar Stefano Rivera

Add some error messages around volunteering

parent 04702003
from django.views.generic import FormView, DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import UpdateView
from django.contrib import messages
from django.core.urlresolvers import reverse, reverse_lazy
from django.db.models import F, Q
from django.http import HttpResponseForbidden
......@@ -100,13 +101,21 @@ class TaskView(DetailView):
for task in self.object.concurrent_tasks()
for volunteer in task.volunteers.all()]
# TODO Show an error message
if self.object in volunteer.tasks.all():
elif (self.object.nbr_volunteers < self.object.max_volunteers) and (volunteer not in concurrent_volunteers):, 'Removed')
elif volunteer in concurrent_volunteers:
# TODO Show where the user is going to be
'You are already volunteering in this time-slot. '
'You can only be in one place at a time.')
elif self.object.nbr_volunteers >= self.object.max_volunteers:
messages.error(request, 'This task already has enough volunteers.')
messages.success(request, 'Thank you for volunteering!')
return redirect('wafer_task',
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment