volunteers: send subscription url by mail

This commit is contained in:
Élie Bouttier 2017-10-30 18:05:57 +01:00
parent d980c82285
commit d0ceac00e4
3 changed files with 43 additions and 8 deletions

View File

@ -415,7 +415,7 @@ class Volunteer(PonyConfModel):
conversation = models.OneToOneField(MessageThread)
def get_absolute_url(self):
return reverse('volunteer-details', kwargs={'volunteer_id': self.token})
return reverse('volunteer-home', kwargs={'volunteer_id': self.token})
class Meta:
# A volunteer can participe only once to a Conference (= Site)

View File

@ -11,9 +11,11 @@ urlpatterns = [
url(r'^cfp/(?P<talk_id>[\w\-]+)/(?P<participant_id>[\w\-]+)/confirm/$', views.talk_acknowledgment, {'confirm': True}, name='talk-confirm'),
url(r'^cfp/(?P<talk_id>[\w\-]+)/(?P<participant_id>[\w\-]+)/desist/$', views.talk_acknowledgment, {'confirm': False}, name='talk-desist'),
url(r'^volunteer/$', views.volunteer_enrole, name='volunteer-enrole'),
url(r'^volunteer/(?P<volunteer_id>[\w\-]+)/$', views.volunteer, name='volunteer'),
url(r'^volunteer/(?P<volunteer_id>[\w\-]+)/join/(?P<activity>[\w\-]+)/$', views.volunteer_activity, {'join': True}, name='volunteer-join'),
url(r'^volunteer/(?P<volunteer_id>[\w\-]+)/quit/(?P<activity>[\w\-]+)/$', views.volunteer_activity, {'join': False}, name='volunteer-quit'),
url(r'^volunteer/(?P<volunteer_id>[\w\-]+)/$', views.volunteer_home, name='volunteer-home'),
url(r'^volunteer/(?P<volunteer_id>[\w\-]+)/join/(?P<activity>[\w\-]+)/$', views.volunteer_update_activity, {'join': True}, name='volunteer-join'),
url(r'^volunteer/(?P<volunteer_id>[\w\-]+)/quit/(?P<activity>[\w\-]+)/$', views.volunteer_update_activity, {'join': False}, name='volunteer-quit'),
#url(r'^talk/(?P<talk_id>[\w\-]+)/$', views.talk_show, name='show-talk'),
#url(r'^speaker/(?P<participant_id>[\w\-]+)/$', views.speaker_show, name='show-speaker'),
url(r'^staff/$', views.staff, name='staff'),
url(r'^staff/talks/$', views.talk_list, name='talk-list'),
url(r'^staff/talks/(?P<talk_id>[\w\-]+)/$', views.talk_details, name='talk-details'),
@ -34,6 +36,7 @@ urlpatterns = [
url(r'^staff/rooms/(?P<slug>[-\w]+)/$', views.RoomDetail.as_view(), name='room-details'),
url(r'^staff/rooms/(?P<slug>[-\w]+)/edit/$', views.RoomUpdate.as_view(), name='room-edit'),
url(r'^staff/volunteers/$', views.volunteer_list, name='volunteer-list'),
url(r'^staff/volunteers/(?P<volunteer_id>[\w\-]+)/$', views.volunteer_details, name='volunteer-details'),
url(r'^staff/add-user/$', views.create_user, name='create-user'),
url(r'^staff/schedule/((?P<program_format>[\w]+)/)?$', views.staff_schedule, name='staff-schedule'),
url(r'^staff/select2/$', views.Select2View.as_view(), name='django_select2-json'),

View File

@ -11,6 +11,7 @@ from django.views.generic import CreateView, DetailView, ListView, UpdateView
from django.http import HttpResponse, Http404
from django.utils import timezone
from django.core.exceptions import PermissionDenied
from django.core.mail import send_mail
from django_select2.views import AutoResponseView
@ -45,15 +46,41 @@ def volunteer_enrole(request):
volunteer = form.save(commit=False)
volunteer.language = request.LANGUAGE_CODE
volunteer.save()
volunteer_url = ('https' if request.is_secure() else 'http') + '://' + request.conference.site.domain + volunteer.get_absolute_url()
body = _("""Hi {},
Thank your for your help in the organization of the conference {}!
You can update your availability at anytime:
{}
Thanks!
{}
""").format(volunteer.name, request.conference.name, volunteer_url, request.conference.name)
#Message.objects.create(
# thread=volunteer.conversation,
# author=request.conference,
# from_email=request.conference.contact_email,
# content=body,
#)
send_mail(
subject=_('Thank you for your help!'),
message=body,
from_email='%s <%s>' % (request.conference.name, request.conference.contact_email),
recipient_list=['%s <%s>' % (volunteer.name, volunteer.email)],
)
messages.success(request, _('Thank you for your participation! You can now subscribe to some activities.'))
return redirect(reverse('volunteer', kwargs=dict(volunteer_id=volunteer.token)))
return redirect(reverse('volunteer-home', kwargs=dict(volunteer_id=volunteer.token)))
return render(request, 'cfp/volunteer_enrole.html', {
'activities': Activity.objects.filter(site=request.conference.site),
'form': form,
})
def volunteer(request, volunteer_id):
def volunteer_home(request, volunteer_id):
volunteer = get_object_or_404(Volunteer, token=volunteer_id, site=request.conference.site)
return render(request, 'cfp/volunteer.html', {
'activities': Activity.objects.filter(site=request.conference.site),
@ -61,7 +88,7 @@ def volunteer(request, volunteer_id):
})
def volunteer_activity(request, volunteer_id, activity, join):
def volunteer_update_activity(request, volunteer_id, activity, join):
if not request.conference.volunteers_enrollment_is_open():
raise PermissionDenied
volunteer = get_object_or_404(Volunteer, token=volunteer_id, site=request.conference.site)
@ -74,7 +101,7 @@ def volunteer_activity(request, volunteer_id, activity, join):
activity.volunteers.remove(volunteer)
activity.save()
messages.success(request, _('Okay, no problem!'))
return redirect(reverse('volunteer', kwargs=dict(volunteer_id=volunteer.token)))
return redirect(reverse('volunteer-home', kwargs=dict(volunteer_id=volunteer.token)))
@staff_required
@ -98,6 +125,11 @@ def volunteer_list(request):
})
@staff_required
def volunteer_details(request, volunteer_id):
pass
def talk_proposal(request, talk_id=None, participant_id=None):
conference = request.conference
site = conference.site