2012-07-11 17:39:20 +02:00
|
|
|
# coding: utf-8
|
2013-09-05 22:20:52 +02:00
|
|
|
|
|
|
|
import unicodecsv
|
|
|
|
|
|
|
|
from django.shortcuts import redirect, get_object_or_404, render
|
|
|
|
from django.http import Http404, HttpResponse
|
2012-06-27 23:28:35 +02:00
|
|
|
from django.core.urlresolvers import reverse
|
2013-09-05 22:20:52 +02:00
|
|
|
from django.contrib.auth.models import User
|
2012-06-27 23:28:35 +02:00
|
|
|
from django.contrib.auth.decorators import login_required
|
|
|
|
from django import forms
|
|
|
|
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
2012-07-11 17:39:20 +02:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2013-09-05 22:20:52 +02:00
|
|
|
from django.db.models import Max
|
|
|
|
from django.contrib.auth.views import login as django_login_view
|
2012-07-11 17:39:20 +02:00
|
|
|
|
2012-06-27 23:28:35 +02:00
|
|
|
from gestioncof.models import Survey, SurveyQuestion, SurveyQuestionAnswer, SurveyAnswer
|
|
|
|
from gestioncof.models import Event, EventOption, EventOptionChoice, EventRegistration
|
2014-08-19 12:54:22 +02:00
|
|
|
from gestioncof.models import EventCommentField, EventCommentValue
|
2013-09-05 22:20:52 +02:00
|
|
|
from gestioncof.models import CofProfile, Clipper
|
2012-07-11 17:39:20 +02:00
|
|
|
from gestioncof.decorators import buro_required, cof_required
|
|
|
|
from gestioncof.widgets import TriStateCheckbox
|
2014-08-19 12:54:22 +02:00
|
|
|
from gestioncof.shared import lock_table, unlock_table, send_custom_mail
|
2012-06-27 23:28:35 +02:00
|
|
|
|
2015-01-06 11:01:15 +01:00
|
|
|
import re
|
|
|
|
|
2012-06-27 23:28:35 +02:00
|
|
|
@login_required
|
|
|
|
def home(request):
|
2013-09-05 22:20:52 +02:00
|
|
|
data = {"surveys": Survey.objects.filter(old = False).all(),
|
|
|
|
"events": Event.objects.filter(old = False).all(),
|
|
|
|
"open_surveys": Survey.objects.filter(survey_open = True, old = False).all(),
|
|
|
|
"open_events": Event.objects.filter(registration_open = True, old = False).all()}
|
|
|
|
return render(request, "home.html", data)
|
2012-06-27 23:28:35 +02:00
|
|
|
|
|
|
|
def login(request):
|
|
|
|
if request.user.is_authenticated():
|
|
|
|
return redirect("gestioncof.views.home")
|
2013-09-05 22:20:52 +02:00
|
|
|
return render(request, "login_switch.html", {})
|
|
|
|
|
|
|
|
def login_ext(request):
|
|
|
|
if request.method == "POST" and "username" in request.POST:
|
|
|
|
try:
|
|
|
|
user = User.objects.get(username = request.POST["username"])
|
|
|
|
if not user.has_usable_password() or user.password in ("","!"):
|
|
|
|
profile, created = CofProfile.objects.get_or_create(user = user)
|
|
|
|
if profile.login_clipper:
|
|
|
|
return render(request, "error.html", {"error_type": "use_clipper_login"})
|
|
|
|
else:
|
|
|
|
return render(request, "error.html", {"error_type": "no_password"})
|
|
|
|
except User.DoesNotExist:
|
|
|
|
pass
|
|
|
|
return django_login_view(request, template_name = 'login.html')
|
2012-06-27 23:28:35 +02:00
|
|
|
|
|
|
|
@login_required
|
|
|
|
def logout(request):
|
2012-07-11 17:39:20 +02:00
|
|
|
try:
|
|
|
|
profile = request.user.get_profile()
|
|
|
|
except CofProfile.DoesNotExist:
|
|
|
|
profile, created = CofProfile.objects.get_or_create(user = request.user)
|
|
|
|
if profile.login_clipper:
|
2012-06-27 23:28:35 +02:00
|
|
|
return redirect("django_cas.views.logout")
|
|
|
|
else:
|
|
|
|
return redirect("django.contrib.auth.views.logout")
|
|
|
|
|
|
|
|
class SurveyForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
survey = kwargs.pop("survey")
|
|
|
|
current_answers = kwargs.pop("current_answers", None)
|
|
|
|
super(SurveyForm, self).__init__(*args, **kwargs)
|
|
|
|
answers = {}
|
|
|
|
if current_answers:
|
|
|
|
for answer in current_answers.all():
|
|
|
|
if answer.survey_question.id not in answers:
|
|
|
|
answers[answer.survey_question.id] = [answer.id]
|
|
|
|
else:
|
|
|
|
answers[answer.survey_question.id].append(answer.id)
|
|
|
|
for question in survey.questions.all():
|
|
|
|
choices = [(answer.id, answer.answer) for answer in question.answers.all()]
|
|
|
|
if question.multi_answers:
|
|
|
|
initial = [] if question.id not in answers else answers[question.id]
|
|
|
|
field = forms.MultipleChoiceField(label = question.question,
|
|
|
|
choices = choices,
|
|
|
|
widget = CheckboxSelectMultiple,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
else:
|
|
|
|
initial = None if question.id not in answers else answers[question.id][0]
|
|
|
|
field = forms.ChoiceField(label = question.question,
|
|
|
|
choices = choices,
|
|
|
|
widget = RadioSelect,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
field.question_id = question.id
|
|
|
|
self.fields["question_%d" % question.id] = field
|
|
|
|
|
|
|
|
def answers(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
|
|
|
if name.startswith('question_'):
|
|
|
|
yield (self.fields[name].question_id, value)
|
2015-01-06 11:01:15 +01:00
|
|
|
|
|
|
|
# Ajoute pour sondage pulms
|
|
|
|
def as_p_formate(self):
|
|
|
|
return 'Hello world !'
|
|
|
|
#return re.sub("[img (.+?)]", "<img src='$1' height='200'/>", self.as_p())
|
2012-06-27 23:28:35 +02:00
|
|
|
|
|
|
|
@login_required
|
|
|
|
def survey(request, survey_id):
|
|
|
|
survey = get_object_or_404(Survey, id = survey_id)
|
|
|
|
if not survey.survey_open:
|
|
|
|
raise Http404
|
|
|
|
success = False
|
2012-07-11 17:39:20 +02:00
|
|
|
deleted = False
|
2012-06-27 23:28:35 +02:00
|
|
|
if request.method == "POST":
|
|
|
|
form = SurveyForm(request.POST, survey = survey)
|
2012-07-11 17:39:20 +02:00
|
|
|
if request.POST.get('delete'):
|
2012-06-27 23:28:35 +02:00
|
|
|
try:
|
|
|
|
current_answer = SurveyAnswer.objects.get(user = request.user, survey = survey)
|
2012-07-11 17:39:20 +02:00
|
|
|
current_answer.delete()
|
|
|
|
current_answer = None
|
2012-06-27 23:28:35 +02:00
|
|
|
except SurveyAnswer.DoesNotExist:
|
2012-07-11 17:39:20 +02:00
|
|
|
current_answer = None
|
|
|
|
form = SurveyForm(survey = survey)
|
2012-06-27 23:28:35 +02:00
|
|
|
success = True
|
2012-07-11 17:39:20 +02:00
|
|
|
deleted = True
|
|
|
|
else:
|
|
|
|
if form.is_valid():
|
|
|
|
all_answers = []
|
|
|
|
for question_id, answers_ids in form.answers():
|
|
|
|
question = get_object_or_404(SurveyQuestion, id = question_id,
|
|
|
|
survey = survey)
|
|
|
|
if type(answers_ids) != list:
|
|
|
|
answers_ids = [answers_ids]
|
|
|
|
if not question.multi_answers and len(answers_ids) > 1:
|
|
|
|
raise Http404
|
|
|
|
for answer_id in answers_ids:
|
|
|
|
if not answer_id:
|
|
|
|
continue
|
|
|
|
answer_id = int(answer_id)
|
|
|
|
answer = SurveyQuestionAnswer.objects.get(
|
|
|
|
id = answer_id,
|
|
|
|
survey_question = question)
|
|
|
|
all_answers.append(answer)
|
|
|
|
try:
|
|
|
|
current_answer = SurveyAnswer.objects.get(user = request.user, survey = survey)
|
|
|
|
except SurveyAnswer.DoesNotExist:
|
|
|
|
current_answer = SurveyAnswer(user = request.user, survey = survey)
|
|
|
|
current_answer.save()
|
|
|
|
current_answer.answers = all_answers
|
|
|
|
current_answer.save()
|
|
|
|
success = True
|
2012-06-27 23:28:35 +02:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
current_answer = SurveyAnswer.objects.get(user = request.user, survey = survey)
|
|
|
|
form = SurveyForm(survey = survey, current_answers = current_answer.answers)
|
|
|
|
except SurveyAnswer.DoesNotExist:
|
2012-07-11 17:39:20 +02:00
|
|
|
current_answer = None
|
2012-06-27 23:28:35 +02:00
|
|
|
form = SurveyForm(survey = survey)
|
2013-09-05 22:20:52 +02:00
|
|
|
return render(request, "survey.html", {"survey": survey, "form": form, "success": success, "deleted": deleted, "current_answer": current_answer})
|
2012-07-11 17:39:20 +02:00
|
|
|
|
|
|
|
class EventForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
event = kwargs.pop("event")
|
2013-09-05 22:20:52 +02:00
|
|
|
self.event = event
|
2012-07-11 17:39:20 +02:00
|
|
|
current_choices = kwargs.pop("current_choices", None)
|
|
|
|
super(EventForm, self).__init__(*args, **kwargs)
|
|
|
|
choices = {}
|
|
|
|
if current_choices:
|
|
|
|
for choice in current_choices.all():
|
|
|
|
if choice.event_option.id not in choices:
|
|
|
|
choices[choice.event_option.id] = [choice.id]
|
|
|
|
else:
|
|
|
|
choices[choice.event_option.id].append(choice.id)
|
|
|
|
all_choices = choices
|
|
|
|
for option in event.options.all():
|
|
|
|
choices = [(choice.id, choice.value) for choice in option.choices.all()]
|
|
|
|
if option.multi_choices:
|
|
|
|
initial = [] if option.id not in all_choices else all_choices[option.id]
|
|
|
|
field = forms.MultipleChoiceField(label = option.name,
|
|
|
|
choices = choices,
|
|
|
|
widget = CheckboxSelectMultiple,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
else:
|
|
|
|
initial = None if option.id not in all_choices else all_choices[option.id][0]
|
|
|
|
field = forms.ChoiceField(label = option.name,
|
|
|
|
choices = choices,
|
|
|
|
widget = RadioSelect,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
field.option_id = option.id
|
|
|
|
self.fields["option_%d" % option.id] = field
|
|
|
|
|
|
|
|
def choices(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
|
|
|
if name.startswith('option_'):
|
|
|
|
yield (self.fields[name].option_id, value)
|
|
|
|
|
2013-09-05 22:20:52 +02:00
|
|
|
def get_event_form_choices(event, form):
|
|
|
|
all_choices = []
|
|
|
|
for option_id, choices_ids in form.choices():
|
|
|
|
option = get_object_or_404(EventOption, id = option_id,
|
|
|
|
event = event)
|
|
|
|
if type(choices_ids) != list:
|
|
|
|
choices_ids = [choices_ids]
|
|
|
|
if not option.multi_choices and len(choices_ids) > 1:
|
|
|
|
raise Http404
|
|
|
|
for choice_id in choices_ids:
|
|
|
|
if not choice_id:
|
|
|
|
continue
|
|
|
|
choice_id = int(choice_id)
|
|
|
|
choice = EventOptionChoice.objects.get(
|
|
|
|
id = choice_id,
|
|
|
|
event_option = option)
|
|
|
|
all_choices.append(choice)
|
|
|
|
return all_choices
|
|
|
|
|
2014-08-19 12:54:22 +02:00
|
|
|
def update_event_form_comments(event, form, registration):
|
|
|
|
for commentfield_id, value in form.comments():
|
|
|
|
field = get_object_or_404(EventCommentField, id = commentfield_id,
|
|
|
|
event = event)
|
|
|
|
if value == field.default:
|
|
|
|
continue
|
|
|
|
(storage, _) = EventCommentValue.objects.get_or_create(commentfield = field,
|
|
|
|
registration = registration)
|
|
|
|
storage.content = value
|
|
|
|
storage.save()
|
|
|
|
|
2012-07-11 17:39:20 +02:00
|
|
|
@login_required
|
|
|
|
def event(request, event_id):
|
|
|
|
event = get_object_or_404(Event, id = event_id)
|
|
|
|
if not event.registration_open:
|
|
|
|
raise Http404
|
|
|
|
success = False
|
|
|
|
if request.method == "POST":
|
|
|
|
form = EventForm(request.POST, event = event)
|
|
|
|
if form.is_valid():
|
2013-09-05 22:20:52 +02:00
|
|
|
all_choices = get_event_form_choices(event, form)
|
|
|
|
(current_registration, _) = EventRegistration.objects.get_or_create(user = request.user, event = event)
|
2012-07-11 17:39:20 +02:00
|
|
|
current_registration.options = all_choices
|
|
|
|
current_registration.save()
|
|
|
|
success = True
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
current_registration = EventRegistration.objects.get(user = request.user, event = event)
|
|
|
|
form = EventForm(event = event, current_choices = current_registration.options)
|
|
|
|
except EventRegistration.DoesNotExist:
|
|
|
|
form = EventForm(event = event)
|
2013-09-05 22:20:52 +02:00
|
|
|
return render(request, "event.html", {"event": event, "form": form, "success": success})
|
2012-07-11 17:39:20 +02:00
|
|
|
|
|
|
|
class SurveyStatusFilterForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
survey = kwargs.pop("survey")
|
|
|
|
super(SurveyStatusFilterForm, self).__init__(*args, **kwargs)
|
|
|
|
answers = {}
|
|
|
|
for question in survey.questions.all():
|
|
|
|
for answer in question.answers.all():
|
|
|
|
name = "question_%d_answer_%d" % (question.id, answer.id)
|
|
|
|
if self.is_bound and self.data.get(self.add_prefix(name), None):
|
|
|
|
initial = self.data.get(self.add_prefix(name), None)
|
|
|
|
else:
|
|
|
|
initial = "none"
|
|
|
|
field = forms.ChoiceField(label = "%s : %s" % (question.question, answer.answer),
|
|
|
|
choices = [("yes", "yes"),("no","no"),("none","none")],
|
|
|
|
widget = TriStateCheckbox,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
field.question_id = question.id
|
|
|
|
field.answer_id = answer.id
|
|
|
|
self.fields[name] = field
|
|
|
|
|
|
|
|
def filters(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
|
|
|
if name.startswith('question_'):
|
|
|
|
yield (self.fields[name].question_id, self.fields[name].answer_id, value)
|
|
|
|
|
|
|
|
class EventStatusFilterForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
event = kwargs.pop("event")
|
|
|
|
super(EventStatusFilterForm, self).__init__(*args, **kwargs)
|
|
|
|
for option in event.options.all():
|
|
|
|
for choice in option.choices.all():
|
|
|
|
name = "option_%d_choice_%d" % (option.id, choice.id)
|
|
|
|
if self.is_bound and self.data.get(self.add_prefix(name), None):
|
|
|
|
initial = self.data.get(self.add_prefix(name), None)
|
|
|
|
else:
|
|
|
|
initial = "none"
|
|
|
|
field = forms.ChoiceField(label = "%s : %s" % (option.name, choice.value),
|
|
|
|
choices = [("yes", "yes"),("no","no"),("none","none")],
|
|
|
|
widget = TriStateCheckbox,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
field.option_id = option.id
|
|
|
|
field.choice_id = choice.id
|
|
|
|
self.fields[name] = field
|
2013-09-05 22:20:52 +02:00
|
|
|
# has_paid
|
|
|
|
name = "event_has_paid"
|
|
|
|
if self.is_bound and self.data.get(self.add_prefix(name), None):
|
|
|
|
initial = self.data.get(self.add_prefix(name), None)
|
|
|
|
else:
|
|
|
|
initial = "none"
|
|
|
|
field = forms.ChoiceField(label = "Événement payé",
|
|
|
|
choices = [("yes", "yes"),("no","no"),("none","none")],
|
|
|
|
widget = TriStateCheckbox,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
self.fields[name] = field
|
2012-07-11 17:39:20 +02:00
|
|
|
|
|
|
|
def filters(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
|
|
|
if name.startswith('option_'):
|
|
|
|
yield (self.fields[name].option_id, self.fields[name].choice_id, value)
|
2013-09-05 22:20:52 +02:00
|
|
|
elif name == "event_has_paid":
|
|
|
|
yield ("has_paid", None, value)
|
2012-07-11 17:39:20 +02:00
|
|
|
|
|
|
|
def clean_post_for_status(initial):
|
2013-09-05 22:20:52 +02:00
|
|
|
d = initial.copy()
|
2012-07-11 17:39:20 +02:00
|
|
|
for k, v in d.items():
|
|
|
|
if k.startswith("id_"):
|
|
|
|
del d[k]
|
2013-09-05 22:20:52 +02:00
|
|
|
d[k[3:]] = v
|
2012-07-11 17:39:20 +02:00
|
|
|
return d
|
|
|
|
|
2013-09-05 22:20:52 +02:00
|
|
|
@buro_required
|
2012-07-11 17:39:20 +02:00
|
|
|
def event_status(request, event_id):
|
|
|
|
event = get_object_or_404(Event, id = event_id)
|
|
|
|
registrations_query = EventRegistration.objects.filter(event = event)
|
|
|
|
post_data = clean_post_for_status(request.POST)
|
|
|
|
form = EventStatusFilterForm(post_data or None, event = event)
|
|
|
|
if form.is_valid():
|
|
|
|
for option_id, choice_id, value in form.filters():
|
2013-09-05 22:20:52 +02:00
|
|
|
if option_id == "has_paid":
|
|
|
|
if value == "yes":
|
|
|
|
registrations_query = registrations_query.filter(paid = True)
|
|
|
|
elif value == "no":
|
|
|
|
registrations_query = registrations_query.filter(paid = False)
|
|
|
|
continue
|
2012-07-11 17:39:20 +02:00
|
|
|
choice = get_object_or_404(EventOptionChoice, id = choice_id, event_option__id = option_id)
|
|
|
|
if value == "none":
|
|
|
|
continue
|
|
|
|
if value == "yes":
|
|
|
|
registrations_query = registrations_query.filter(options__id__exact = choice.id)
|
|
|
|
elif value == "no":
|
|
|
|
registrations_query = registrations_query.exclude(options__id__exact = choice.id)
|
|
|
|
user_choices = registrations_query.prefetch_related("user").all()
|
|
|
|
options = EventOption.objects.filter(event = event).all()
|
|
|
|
choices_count = {}
|
|
|
|
for option in options:
|
|
|
|
for choice in option.choices.all():
|
|
|
|
choices_count[choice.id] = 0
|
|
|
|
for user_choice in user_choices:
|
|
|
|
for choice in user_choice.options.all():
|
|
|
|
choices_count[choice.id] += 1
|
2016-05-21 23:57:36 +02:00
|
|
|
return render(request, "event_status.html", {"event": event, "user_choices": user_choices, "options": options, "choices_count": choices_count, "form": form})
|
2012-07-11 17:39:20 +02:00
|
|
|
|
2013-09-05 22:20:52 +02:00
|
|
|
@buro_required
|
2012-07-11 17:39:20 +02:00
|
|
|
def survey_status(request, survey_id):
|
|
|
|
survey = get_object_or_404(Survey, id = survey_id)
|
|
|
|
answers_query = SurveyAnswer.objects.filter(survey = survey)
|
|
|
|
post_data = clean_post_for_status(request.POST)
|
|
|
|
form = SurveyStatusFilterForm(post_data or None, survey = survey)
|
|
|
|
if form.is_valid():
|
|
|
|
for question_id, answer_id, value in form.filters():
|
|
|
|
answer = get_object_or_404(SurveyQuestionAnswer, id = answer_id, survey_question__id = question_id)
|
|
|
|
if value == "none":
|
|
|
|
continue
|
|
|
|
if value == "yes":
|
|
|
|
answers_query = answers_query.filter(answers__id__exact = answer.id)
|
|
|
|
elif value == "no":
|
|
|
|
answers_query = answers_query.exclude(answers__id__exact = answer.id)
|
|
|
|
user_answers = answers_query.prefetch_related("user").all()
|
|
|
|
questions = SurveyQuestion.objects.filter(survey = survey).all()
|
|
|
|
answers_count = {}
|
|
|
|
for question in questions:
|
|
|
|
for answer in question.answers.all():
|
|
|
|
answers_count[answer.id] = 0
|
|
|
|
for user_answer in user_answers:
|
|
|
|
for answer in user_answer.answers.all():
|
|
|
|
answers_count[answer.id] += 1
|
2013-09-05 22:20:52 +02:00
|
|
|
return render(request, "survey_status.html", {"survey": survey, "user_answers": user_answers, "questions": questions, "answers_count": answers_count, "form": form})
|
2012-07-11 17:39:20 +02:00
|
|
|
|
|
|
|
class UserProfileForm(forms.ModelForm):
|
|
|
|
first_name = forms.CharField(label=_(u'Prénom'), max_length=30)
|
|
|
|
last_name = forms.CharField(label=_(u'Nom'), max_length=30)
|
|
|
|
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
super(UserProfileForm, self).__init__(*args, **kw)
|
|
|
|
self.fields['first_name'].initial = self.instance.user.first_name
|
|
|
|
self.fields['last_name'].initial = self.instance.user.last_name
|
|
|
|
|
|
|
|
self.fields.keyOrder = [
|
|
|
|
'first_name',
|
|
|
|
'last_name',
|
|
|
|
'phone',
|
|
|
|
'mailing_cof',
|
2013-09-05 22:20:52 +02:00
|
|
|
'mailing_bda',
|
2012-07-11 17:39:20 +02:00
|
|
|
'mailing_bda_revente',
|
|
|
|
]
|
|
|
|
|
|
|
|
def save(self, *args, **kw):
|
|
|
|
super(UserProfileForm, self).save(*args, **kw)
|
|
|
|
self.instance.user.first_name = self.cleaned_data.get('first_name')
|
|
|
|
self.instance.user.last_name = self.cleaned_data.get('last_name')
|
|
|
|
self.instance.user.save()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = CofProfile
|
2013-09-05 22:20:52 +02:00
|
|
|
fields = ("phone", "mailing_cof", "mailing_bda", "mailing_bda_revente",)
|
2012-07-11 17:39:20 +02:00
|
|
|
|
|
|
|
@login_required
|
|
|
|
def profile(request):
|
|
|
|
success = False
|
|
|
|
if request.method == "POST":
|
|
|
|
form = UserProfileForm(request.POST, instance = request.user.get_profile())
|
|
|
|
if form.is_valid():
|
|
|
|
form.save()
|
|
|
|
success = True
|
|
|
|
else:
|
|
|
|
form = UserProfileForm(instance = request.user.get_profile())
|
2013-09-05 22:20:52 +02:00
|
|
|
return render(request, "profile.html", {"form": form, "success": success})
|
2012-07-11 17:39:20 +02:00
|
|
|
|
2013-09-05 22:20:52 +02:00
|
|
|
class RegistrationUserForm(forms.ModelForm):
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
super(RegistrationUserForm, self).__init__(*args, **kw)
|
|
|
|
self.fields['username'].help_text = ""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ("username", "first_name", "last_name", "email")
|
|
|
|
|
|
|
|
class RegistrationProfileForm(forms.ModelForm):
|
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
super(RegistrationProfileForm, self).__init__(*args, **kw)
|
|
|
|
self.fields['mailing_cof'].initial = True
|
|
|
|
self.fields['mailing_bda'].initial = True
|
|
|
|
self.fields['mailing_bda_revente'].initial = True
|
|
|
|
self.fields['num'].widget.attrs['readonly'] = True
|
|
|
|
|
|
|
|
self.fields.keyOrder = [
|
|
|
|
'login_clipper',
|
|
|
|
'phone',
|
|
|
|
'occupation',
|
|
|
|
'departement',
|
|
|
|
'is_cof',
|
|
|
|
'num',
|
|
|
|
'type_cotiz',
|
|
|
|
'mailing_cof',
|
|
|
|
'mailing_bda',
|
|
|
|
'mailing_bda_revente',
|
2014-08-19 12:54:22 +02:00
|
|
|
'comments'
|
2013-09-05 22:20:52 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
def save(self, *args, **kw):
|
|
|
|
instance = super(RegistrationProfileForm, self).save(*args, **kw)
|
|
|
|
if instance.is_cof and not instance.num:
|
|
|
|
# Generate new number
|
|
|
|
try:
|
|
|
|
lock_table(CofProfile)
|
|
|
|
aggregate = CofProfile.objects.aggregate(Max('num'))
|
|
|
|
instance.num = aggregate['num__max'] + 1
|
|
|
|
instance.save()
|
|
|
|
self.cleaned_data['num'] = instance.num
|
|
|
|
self.data['num'] = instance.num
|
|
|
|
finally:
|
|
|
|
unlock_table(CofProfile)
|
|
|
|
return instance
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = CofProfile
|
2014-08-19 12:54:22 +02:00
|
|
|
fields = ("login_clipper", "num", "phone", "occupation", "departement", "is_cof", "type_cotiz", "mailing_cof", "mailing_bda", "mailing_bda_revente", "comments")
|
2013-09-05 22:20:52 +02:00
|
|
|
|
|
|
|
def registration_set_ro_fields(user_form, profile_form):
|
|
|
|
user_form.fields['username'].widget.attrs['readonly'] = True
|
|
|
|
profile_form.fields['login_clipper'].widget.attrs['readonly'] = True
|
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def registration_form(request, login_clipper = None, username = None):
|
|
|
|
member = None
|
|
|
|
if login_clipper:
|
|
|
|
clipper = get_object_or_404(Clipper, username = login_clipper)
|
|
|
|
try: # check if the given user is already registered
|
|
|
|
member = User.objects.filter(username = login_clipper).get()
|
|
|
|
username = member.username
|
|
|
|
login_clipper = None
|
|
|
|
except User.DoesNotExist:
|
|
|
|
# new user, but prefill
|
|
|
|
user_form = RegistrationUserForm()
|
|
|
|
profile_form = RegistrationProfileForm()
|
|
|
|
user_form.fields['username'].initial = login_clipper
|
|
|
|
user_form.fields['email'].initial = login_clipper + "@clipper.ens.fr"
|
|
|
|
profile_form.fields['login_clipper'].initial = login_clipper
|
|
|
|
if clipper.fullname:
|
|
|
|
bits = clipper.fullname.split(" ")
|
|
|
|
user_form.fields['first_name'].initial = bits[0]
|
|
|
|
if len(bits) > 1:
|
|
|
|
user_form.fields['last_name'].initial = " ".join(bits[1:])
|
|
|
|
registration_set_ro_fields(user_form, profile_form)
|
|
|
|
if username:
|
|
|
|
member = get_object_or_404(User, username = username)
|
|
|
|
(profile, _) = CofProfile.objects.get_or_create(user = member)
|
|
|
|
# already existing, prefill
|
|
|
|
user_form = RegistrationUserForm(instance = member)
|
|
|
|
profile_form = RegistrationProfileForm(instance = profile)
|
|
|
|
registration_set_ro_fields(user_form, profile_form)
|
|
|
|
elif not login_clipper:
|
|
|
|
# new user
|
|
|
|
user_form = RegistrationUserForm()
|
|
|
|
profile_form = RegistrationProfileForm()
|
|
|
|
return render(request, "registration_form.html", {"user_form": user_form, "profile_form": profile_form, "member": member, "login_clipper": login_clipper})
|
|
|
|
|
|
|
|
STATUS_CHOICES = (('no','Non'),
|
2014-08-19 12:54:22 +02:00
|
|
|
('wait','Oui mais attente paiement'),
|
|
|
|
('paid','Oui payé'),)
|
2013-09-05 22:20:52 +02:00
|
|
|
class AdminEventForm(forms.Form):
|
|
|
|
status = forms.ChoiceField(label = "Inscription", choices = STATUS_CHOICES, widget = RadioSelect)
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
event = kwargs.pop("event")
|
|
|
|
self.event = event
|
2014-08-19 12:54:22 +02:00
|
|
|
registration = kwargs.pop("current_registration", None)
|
|
|
|
current_choices = registration.options.all() if registration is not None else []
|
2013-09-05 22:20:52 +02:00
|
|
|
paid = kwargs.pop("paid", None)
|
|
|
|
if paid == True:
|
|
|
|
kwargs["initial"] = {"status":"paid"}
|
|
|
|
elif paid == False:
|
|
|
|
kwargs["initial"] = {"status":"wait"}
|
|
|
|
else:
|
|
|
|
kwargs["initial"] = {"status":"no"}
|
|
|
|
super(AdminEventForm, self).__init__(*args, **kwargs)
|
|
|
|
choices = {}
|
2014-08-19 12:54:22 +02:00
|
|
|
comments = {}
|
|
|
|
for choice in current_choices:
|
|
|
|
if choice.event_option.id not in choices:
|
|
|
|
choices[choice.event_option.id] = [choice.id]
|
|
|
|
else:
|
|
|
|
choices[choice.event_option.id].append(choice.id)
|
2013-09-05 22:20:52 +02:00
|
|
|
all_choices = choices
|
|
|
|
for option in event.options.all():
|
|
|
|
choices = [(choice.id, choice.value) for choice in option.choices.all()]
|
|
|
|
if option.multi_choices:
|
|
|
|
initial = [] if option.id not in all_choices else all_choices[option.id]
|
|
|
|
field = forms.MultipleChoiceField(label = option.name,
|
|
|
|
choices = choices,
|
|
|
|
widget = CheckboxSelectMultiple,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
else:
|
|
|
|
initial = None if option.id not in all_choices else all_choices[option.id][0]
|
|
|
|
field = forms.ChoiceField(label = option.name,
|
|
|
|
choices = choices,
|
|
|
|
widget = RadioSelect,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
field.option_id = option.id
|
|
|
|
self.fields["option_%d" % option.id] = field
|
2014-08-19 12:54:22 +02:00
|
|
|
for commentfield in event.commentfields.all():
|
|
|
|
initial = commentfield.default
|
|
|
|
if registration is not None:
|
|
|
|
try:
|
|
|
|
initial = registration.comments.get(commentfield = commentfield).content
|
|
|
|
except EventCommentValue.DoesNotExist:
|
|
|
|
pass
|
|
|
|
widget = forms.Textarea if commentfield.fieldtype == "text" else forms.TextInput
|
|
|
|
field = forms.CharField(label = commentfield.name,
|
|
|
|
widget = widget,
|
|
|
|
required = False,
|
|
|
|
initial = initial)
|
|
|
|
field.comment_id = commentfield.id
|
|
|
|
self.fields["comment_%d" % commentfield.id] = field
|
2013-09-05 22:20:52 +02:00
|
|
|
|
|
|
|
def choices(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
|
|
|
if name.startswith('option_'):
|
|
|
|
yield (self.fields[name].option_id, value)
|
|
|
|
|
2014-08-19 12:54:22 +02:00
|
|
|
def comments(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
|
|
|
if name.startswith('comment_'):
|
|
|
|
yield (self.fields[name].comment_id, value)
|
|
|
|
|
2013-09-05 22:20:52 +02:00
|
|
|
@buro_required
|
|
|
|
def registration_form2(request, login_clipper = None, username = None):
|
|
|
|
events = Event.objects.filter(old = False).all()
|
|
|
|
member = None
|
|
|
|
if login_clipper:
|
|
|
|
clipper = get_object_or_404(Clipper, username = login_clipper)
|
|
|
|
try: # check if the given user is already registered
|
|
|
|
member = User.objects.filter(username = login_clipper).get()
|
|
|
|
username = member.username
|
|
|
|
login_clipper = None
|
|
|
|
except User.DoesNotExist:
|
|
|
|
# new user, but prefill
|
|
|
|
user_form = RegistrationUserForm()
|
|
|
|
profile_form = RegistrationProfileForm()
|
|
|
|
event_forms = [AdminEventForm(event = event) for event in events]
|
|
|
|
user_form.fields['username'].initial = login_clipper
|
|
|
|
user_form.fields['email'].initial = login_clipper + "@clipper.ens.fr"
|
|
|
|
profile_form.fields['login_clipper'].initial = login_clipper
|
|
|
|
if clipper.fullname:
|
|
|
|
bits = clipper.fullname.split(" ")
|
|
|
|
user_form.fields['first_name'].initial = bits[0]
|
|
|
|
if len(bits) > 1:
|
|
|
|
user_form.fields['last_name'].initial = " ".join(bits[1:])
|
|
|
|
registration_set_ro_fields(user_form, profile_form)
|
|
|
|
if username:
|
|
|
|
member = get_object_or_404(User, username = username)
|
|
|
|
(profile, _) = CofProfile.objects.get_or_create(user = member)
|
|
|
|
# already existing, prefill
|
|
|
|
user_form = RegistrationUserForm(instance = member)
|
|
|
|
profile_form = RegistrationProfileForm(instance = profile)
|
|
|
|
registration_set_ro_fields(user_form, profile_form)
|
|
|
|
event_forms = []
|
|
|
|
for event in events:
|
|
|
|
try:
|
|
|
|
current_registration = EventRegistration.objects.get(user = member, event = event)
|
2014-08-19 12:54:22 +02:00
|
|
|
form = AdminEventForm(event = event, current_registration = current_registration, paid = current_registration.paid)
|
2013-09-05 22:20:52 +02:00
|
|
|
except EventRegistration.DoesNotExist:
|
|
|
|
form = AdminEventForm(event = event)
|
|
|
|
event_forms.append(form)
|
|
|
|
elif not login_clipper:
|
|
|
|
# new user
|
|
|
|
user_form = RegistrationUserForm()
|
|
|
|
profile_form = RegistrationProfileForm()
|
|
|
|
event_forms = [AdminEventForm(event = event) for event in events]
|
|
|
|
return render(request, "registration_form.html", {"user_form": user_form, "profile_form": profile_form, "member": member, "login_clipper": login_clipper, "event_forms": event_forms})
|
|
|
|
|
|
|
|
@buro_required
|
2012-07-11 17:39:20 +02:00
|
|
|
def registration(request):
|
2013-09-05 22:20:52 +02:00
|
|
|
if request.POST:
|
|
|
|
request_dict = request.POST.copy()
|
|
|
|
if "num" in request_dict:
|
|
|
|
del request_dict["num"]
|
|
|
|
success = False
|
|
|
|
user_form = RegistrationUserForm(request_dict)
|
|
|
|
profile_form = RegistrationProfileForm(request_dict)
|
|
|
|
events = Event.objects.filter(old = False).all()
|
|
|
|
event_forms = [AdminEventForm(request_dict, event = event) for event in events]
|
|
|
|
user_form.is_valid()
|
|
|
|
profile_form.is_valid()
|
|
|
|
for event_form in event_forms: event_form.is_valid()
|
|
|
|
member = None
|
|
|
|
login_clipper = None
|
|
|
|
if "user_exists" in request_dict and request_dict["user_exists"]:
|
|
|
|
username = request_dict["username"]
|
|
|
|
try:
|
|
|
|
member = User.objects.filter(username = username).get()
|
|
|
|
(profile, _) = CofProfile.objects.get_or_create(user = member)
|
|
|
|
user_form = RegistrationUserForm(request_dict, instance = member)
|
|
|
|
profile_form = RegistrationProfileForm(request_dict, instance = profile)
|
|
|
|
except User.DoesNotExist:
|
|
|
|
try:
|
|
|
|
clipper = Clipper.objects.filter(username = username).get()
|
|
|
|
login_clipper = clipper.username
|
|
|
|
except Clipper.DoesNotExist:
|
|
|
|
pass
|
|
|
|
for form in event_forms:
|
|
|
|
if not form.is_valid(): break
|
|
|
|
if form.cleaned_data['status'] == 'no': continue
|
|
|
|
all_choices = get_event_form_choices(form.event, form)
|
|
|
|
if user_form.is_valid() and profile_form.is_valid() and not any([not form.is_valid() for form in event_forms]):
|
|
|
|
member = user_form.save()
|
|
|
|
(profile, _) = CofProfile.objects.get_or_create(user = member)
|
2014-08-19 12:54:22 +02:00
|
|
|
was_cof = profile.is_cof
|
2013-09-05 22:20:52 +02:00
|
|
|
request_dict["num"] = profile.num
|
|
|
|
profile_form = RegistrationProfileForm(request_dict, instance = profile)
|
|
|
|
profile_form.is_valid()
|
|
|
|
profile_form.save()
|
2014-08-19 12:54:22 +02:00
|
|
|
(profile, _) = CofProfile.objects.get_or_create(user = member)
|
|
|
|
if profile.is_cof and not was_cof:
|
|
|
|
send_custom_mail(member, "bienvenue")
|
2013-09-05 22:20:52 +02:00
|
|
|
for form in event_forms:
|
|
|
|
if form.cleaned_data['status'] == 'no':
|
|
|
|
try:
|
|
|
|
current_registration = EventRegistration.objects.get(user = member, event = form.event)
|
|
|
|
current_registration.delete()
|
|
|
|
except EventRegistration.DoesNotExist:
|
|
|
|
pass
|
|
|
|
continue
|
|
|
|
all_choices = get_event_form_choices(form.event, form)
|
2014-08-19 12:54:22 +02:00
|
|
|
(current_registration, created_reg) = EventRegistration.objects.get_or_create(user = member, event = form.event)
|
|
|
|
update_event_form_comments(event, form, current_registration)
|
2013-09-05 22:20:52 +02:00
|
|
|
current_registration.options = all_choices
|
|
|
|
current_registration.paid = (form.cleaned_data['status'] == 'paid')
|
|
|
|
current_registration.save()
|
2015-09-13 18:23:47 +02:00
|
|
|
if event.title == "Mega 15" and created_reg:
|
2014-08-19 12:54:22 +02:00
|
|
|
field = EventCommentField.objects.get(event = event, name = "Commentaires")
|
|
|
|
try:
|
|
|
|
comments = EventCommentValue.objects.get(commentfield = field, registration = current_registration).content
|
|
|
|
except EventCommentValue.DoesNotExist:
|
|
|
|
comments = field.default
|
|
|
|
send_custom_mail(member, "mega", {"remarques": comments})
|
2013-09-05 22:20:52 +02:00
|
|
|
success = True
|
|
|
|
return render(request, "registration_post.html", {"success": success, "user_form": user_form, "profile_form": profile_form, "member": member, "login_clipper": login_clipper, "event_forms": event_forms})
|
|
|
|
else:
|
|
|
|
return render(request, "registration.html")
|
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def export_members(request):
|
|
|
|
response = HttpResponse(mimetype = 'text/csv')
|
|
|
|
response['Content-Disposition'] = 'attachment; filename=membres_cof.csv'
|
|
|
|
|
|
|
|
writer = unicodecsv.UnicodeWriter(response)
|
|
|
|
for profile in CofProfile.objects.filter(is_cof = True).all():
|
|
|
|
user = profile.user
|
|
|
|
bits = [profile.num, user.username, user.first_name, user.last_name, user.email, profile.phone, profile.occupation, profile.departement, profile.type_cotiz]
|
|
|
|
writer.writerow([unicode(bit) for bit in bits])
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
2016-05-21 23:57:36 +02:00
|
|
|
@buro_required
|
2014-08-19 12:54:22 +02:00
|
|
|
def csv_export_mega(filename, qs):
|
2013-09-05 22:20:52 +02:00
|
|
|
response = HttpResponse(mimetype = 'text/csv')
|
2014-08-19 12:54:22 +02:00
|
|
|
response['Content-Disposition'] = 'attachment; filename=' + filename
|
2013-09-05 22:20:52 +02:00
|
|
|
writer = unicodecsv.UnicodeWriter(response)
|
2014-08-19 12:54:22 +02:00
|
|
|
|
|
|
|
for reg in qs.all():
|
2013-09-05 22:20:52 +02:00
|
|
|
user = reg.user
|
|
|
|
profile = user.get_profile()
|
2014-08-19 12:54:22 +02:00
|
|
|
comments = "---".join([comment.content for comment in reg.comments.all()])
|
|
|
|
bits = [user.username, user.first_name, user.last_name, user.email, profile.phone, profile.num, profile.comments if profile.comments else "", comments]
|
2013-09-05 22:20:52 +02:00
|
|
|
writer.writerow([unicode(bit) for bit in bits])
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
@buro_required
|
2014-08-19 12:54:22 +02:00
|
|
|
def export_mega_remarksonly(request):
|
2015-09-13 18:23:47 +02:00
|
|
|
filename = 'remarques_mega_2015.csv'
|
2013-09-05 22:20:52 +02:00
|
|
|
response = HttpResponse(mimetype = 'text/csv')
|
2014-08-19 12:54:22 +02:00
|
|
|
response['Content-Disposition'] = 'attachment; filename=' + filename
|
2013-09-05 22:20:52 +02:00
|
|
|
writer = unicodecsv.UnicodeWriter(response)
|
2014-08-19 12:54:22 +02:00
|
|
|
|
2015-09-13 18:23:47 +02:00
|
|
|
event = Event.objects.get(title = "Mega 15")
|
2014-08-19 12:54:22 +02:00
|
|
|
commentfield = event.commentfields.get(name = "Commentaires")
|
|
|
|
for val in commentfield.values.all():
|
|
|
|
reg = val.registration
|
2013-09-05 22:20:52 +02:00
|
|
|
user = reg.user
|
|
|
|
profile = user.get_profile()
|
2014-08-19 12:54:22 +02:00
|
|
|
bits = [user.username, user.first_name, user.last_name, user.email, profile.phone, profile.num, profile.comments, val.content]
|
2013-09-05 22:20:52 +02:00
|
|
|
writer.writerow([unicode(bit) for bit in bits])
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
@buro_required
|
2014-08-19 12:54:22 +02:00
|
|
|
def export_mega_bytype(request, type):
|
2015-09-13 18:23:47 +02:00
|
|
|
types = {"orga-actif": "Orga élève",
|
|
|
|
"orga-branleur": "Orga étudiant",
|
2014-08-19 12:54:22 +02:00
|
|
|
"conscrit-eleve": "Conscrit élève",
|
|
|
|
"conscrit-etudiant": "Conscrit étudiant"}
|
2013-09-05 22:20:52 +02:00
|
|
|
|
2014-08-19 12:54:22 +02:00
|
|
|
if type not in types:
|
|
|
|
raise Http404
|
2013-09-05 22:20:52 +02:00
|
|
|
|
2015-09-13 18:23:47 +02:00
|
|
|
event = Event.objects.get(title = "Mega 15")
|
2014-08-19 12:54:22 +02:00
|
|
|
type_option = event.options.get(name = "Type")
|
|
|
|
participant_type = type_option.choices.get(value = types[type]).id
|
|
|
|
qs = EventRegistration.objects.filter(event = event).filter(options__id__exact = participant_type)
|
2015-09-13 18:23:47 +02:00
|
|
|
return csv_export_mega(type + '_mega_2015.csv', qs)
|
2014-08-19 12:54:22 +02:00
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def export_mega_orgas(request):
|
2015-09-13 18:23:47 +02:00
|
|
|
event = Event.objects.get(title = "Mega 15")
|
2014-08-19 12:54:22 +02:00
|
|
|
type_option = event.options.get(name = "Type")
|
|
|
|
participant_type_a = type_option.choices.get(value = "Conscrit étudiant").id
|
|
|
|
participant_type_b = type_option.choices.get(value = "Conscrit élève").id
|
|
|
|
qs = EventRegistration.objects.filter(event = event).exclude(options__id__in = (participant_type_a, participant_type_b))
|
2015-09-13 18:23:47 +02:00
|
|
|
return csv_export_mega('orgas_mega_15.csv', qs)
|
2014-08-19 12:54:22 +02:00
|
|
|
|
2016-05-21 23:57:36 +02:00
|
|
|
@buro_required
|
2014-08-19 12:54:22 +02:00
|
|
|
def export_mega_participants(request):
|
2015-09-13 18:23:47 +02:00
|
|
|
event = Event.objects.get(title = "Mega 15")
|
2014-08-19 12:54:22 +02:00
|
|
|
type_option = event.options.get(name = "Type")
|
|
|
|
participant_type_a = type_option.choices.get(value = "Conscrit étudiant").id
|
|
|
|
participant_type_b = type_option.choices.get(value = "Conscrit élève").id
|
|
|
|
qs = EventRegistration.objects.filter(event = event).filter(options__id__in = (participant_type_a, participant_type_b))
|
2015-09-13 18:23:47 +02:00
|
|
|
return csv_export_mega('participants_mega_15.csv', qs)
|
2014-08-19 12:54:22 +02:00
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def export_mega(request):
|
2015-09-13 18:23:47 +02:00
|
|
|
event = Event.objects.filter(title = "Mega 15")
|
2014-08-19 12:54:22 +02:00
|
|
|
qs = EventRegistration.objects.filter(event = event).order_by("user__username")
|
2015-09-13 18:23:47 +02:00
|
|
|
return csv_export_mega('all_mega_2015.csv', qs)
|
2013-09-05 22:20:52 +02:00
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def utile_cof(request):
|
|
|
|
return render(request, "utile_cof.html", {})
|
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def utile_bda(request):
|
2013-10-01 15:27:19 +02:00
|
|
|
return render(request, "utile_bda.html", {})
|
2016-05-21 23:57:36 +02:00
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def liste_bdadiff(request):
|
|
|
|
titre = "BdA diffusion"
|
|
|
|
personnes = CofProfile.objects.filter(mailing_bda = True, is_cof = True).all()
|
|
|
|
return render(request, "liste_mails.html", {"titre": titre, "personnes": personnes})
|
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def liste_bdarevente(request):
|
|
|
|
titre = "BdA revente"
|
|
|
|
personnes = CofProfile.objects.filter(mailing_bda_revente = True, is_cof = True).all()
|
|
|
|
return render(request, "liste_mails.html", {"titre": titre, "personnes": personnes})
|
|
|
|
|
|
|
|
@buro_required
|
|
|
|
def liste_diffcof(request):
|
|
|
|
titre = "Diffusion COF"
|
|
|
|
personnes = CofProfile.objects.filter(mailing_cof = True, is_cof = True).all()
|
|
|
|
return render(request, "liste_mails.html", {"titre": titre, "personnes": personnes})
|
|
|
|
|