From de227efcb01bee5a3e36976f854df22b833411bd Mon Sep 17 00:00:00 2001 From: ludo Date: Thu, 9 Jun 2016 13:07:02 +0200 Subject: [PATCH 01/31] Ajoute l'admin des tirages BDA sur la page d'accueil --- gestioncof/templates/home.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gestioncof/templates/home.html b/gestioncof/templates/home.html index f0aecebc..52c0ebfd 100644 --- a/gestioncof/templates/home.html +++ b/gestioncof/templates/home.html @@ -63,6 +63,12 @@
  • Sondage : {{ survey.title }}
  • {% endfor %}
    +

    Gestion tirages BDA

    + {% for tirage in open_tirages %} +
  • {{ tirage.title }}
  • + {% endfor %} + +
  • Liens utiles du COF
  • Liens utiles BdA
  • From 6cd89da67c5ec29090728f48d476da99dd8283f0 Mon Sep 17 00:00:00 2001 From: ludo Date: Thu, 9 Jun 2016 13:10:59 +0200 Subject: [PATCH 02/31] =?UTF-8?q?Donne=20plus=20d'infos=20=C3=A0=20la=20vu?= =?UTF-8?q?e=20spectacles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/views.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bda/views.py b/bda/views.py index f4495f55..2161b682 100644 --- a/bda/views.py +++ b/bda/views.py @@ -306,7 +306,17 @@ def revente(request, tirage_id): def spectacle(request, tirage_id, spectacle_id): tirage = get_object_or_404(Tirage, id=tirage_id) spectacle = get_object_or_404(Spectacle, id = spectacle_id, tirage=tirage) - return render(request, "bda-emails.html", {"spectacle": spectacle}) + attributions = spectacle.attribues.all() + participants = [] + for attrib in attributions: + participant = attrib.participant + if (participant in participants): + participant.nb_places = 2 + else: + participant.nb_places = 1 + participants.append(participant) + + return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants}) class SpectacleListView(ListView): From 96195f1e813dfab0d002dd3cf33dcac2c95a389b Mon Sep 17 00:00:00 2001 From: ludo Date: Thu, 9 Jun 2016 14:31:40 +0200 Subject: [PATCH 03/31] ajoute un tag True/False -> Oui/Non --- gestioncof/templatetags/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gestioncof/templatetags/utils.py b/gestioncof/templatetags/utils.py index 9c439dd3..5f90722e 100644 --- a/gestioncof/templatetags/utils.py +++ b/gestioncof/templatetags/utils.py @@ -34,3 +34,10 @@ def highlight_clipper(clipper, q): else: text = clipper.username return highlight_text(text, q) + +@register.filter +def oui_ou_non(b): + if b: + return "Oui" + else: + return "Non" From e93e60ec84665b4f763163234bc7465be2b4e5a2 Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 10 Jun 2016 18:04:02 +0200 Subject: [PATCH 04/31] =?UTF-8?q?fix=20=C3=A9limination=20des=20doublons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/views.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bda/views.py b/bda/views.py index 2161b682..2e405ec1 100644 --- a/bda/views.py +++ b/bda/views.py @@ -307,16 +307,17 @@ def spectacle(request, tirage_id, spectacle_id): tirage = get_object_or_404(Tirage, id=tirage_id) spectacle = get_object_or_404(Spectacle, id = spectacle_id, tirage=tirage) attributions = spectacle.attribues.all() - participants = [] + participants = {} for attrib in attributions: participant = attrib.participant - if (participant in participants): - participant.nb_places = 2 + participant.given = attrib.given + if (participant.id in participants): + participants[participant.id].nb_places = 2 else: participant.nb_places = 1 - participants.append(participant) + participants[participant.id]=participant - return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants}) + return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants.values()}) class SpectacleListView(ListView): @@ -329,6 +330,7 @@ class SpectacleListView(ListView): def get_context_data(self, **kwargs): context = super(SpectacleListView, self).get_context_data(**kwargs) context['tirage_id'] = self.tirage.id + context['tirage_name'] = self.tirage.title return context @buro_required From e15aed65c9b4a5f272d203c4de72f7965a58418e Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 10 Jun 2016 18:10:25 +0200 Subject: [PATCH 05/31] =?UTF-8?q?D=C3=A9place=20l'interface=20des=20tirage?= =?UTF-8?q?s=20vers=20une=20vue=20sp=C3=A9ciale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/templates/spectacle_list.html | 11 +++++++++-- gestioncof/templates/utile_bda.html | 10 ---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/bda/templates/spectacle_list.html b/bda/templates/spectacle_list.html index d707dde4..e1863eef 100644 --- a/bda/templates/spectacle_list.html +++ b/bda/templates/spectacle_list.html @@ -1,11 +1,18 @@ {% extends "base_title.html" %} {% block realcontent %} -

    Spectacles

    +

    {{tirage_name}}

    +
    +

    Liste des spectacles

    +
    +

    Exports

    + {% endblock %} diff --git a/gestioncof/templates/utile_bda.html b/gestioncof/templates/utile_bda.html index 5f4f383a..8948de97 100644 --- a/gestioncof/templates/utile_bda.html +++ b/gestioncof/templates/utile_bda.html @@ -10,14 +10,4 @@
  • BdA diffusion
  • BdA revente
  • -

    Tirages

    - {% for tirage in tirages %} -

    {{ tirage.title }}

    - - {% endfor %} {% endblock %} From 185c7b5ca4e51b048898d24bf4f22807750315f8 Mon Sep 17 00:00:00 2001 From: ludo Date: Sun, 12 Jun 2016 17:57:31 +0200 Subject: [PATCH 06/31] =?UTF-8?q?Vue=20listant=20les=20participants=20?= =?UTF-8?q?=C3=A0=20un=20spectacle,=20avec=20quelques=20exports=20:=20list?= =?UTF-8?q?e=20des=20mails,=20et=20export=20des=20noms=20pour=20les=20sall?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/templates/bda-participants.html | 72 +++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 bda/templates/bda-participants.html diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html new file mode 100644 index 00000000..64f260b8 --- /dev/null +++ b/bda/templates/bda-participants.html @@ -0,0 +1,72 @@ +{% extends "base_title.html" %} +{% load utils %} + +{% block realcontent %} +

    {{ spectacle }}

    + + + + + + + + + + + + {% for participant in participants %} + + + + + + + + + + {% endfor %} + + {% csrf_token %} + + + + + + + + + +
    NomClipperPlacesAdresse MailPayéDonné
    {{participant.user.get_full_name}}{{participant.user.username}}{{participant.nb_places}} place{{participant.nb_places|pluralize:",s"}}{{participant.user.email}} +
    + {{participant.paid|oui_ou_non}} +
    +
    +
    + {{participant.given|oui_ou_non}} +
    +
    +
    + + + +
    + + + + + +{% endblock %} From 7686d33dff38348eea98e4b70233d59b9a068f94 Mon Sep 17 00:00:00 2001 From: ludo Date: Sun, 12 Jun 2016 18:00:26 +0200 Subject: [PATCH 07/31] =?UTF-8?q?D=C3=A9but=20de=20l'ajout=20de=20particip?= =?UTF-8?q?ants=20=C3=A0=20un=20spectacle=20;=20cr=C3=A9ation=20d'url=20et?= =?UTF-8?q?=20gestion=20de=20formulaire=20(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/urls.py | 3 +++ bda/views.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bda/urls.py b/bda/urls.py index d3f4fe2f..8cd94d17 100644 --- a/bda/urls.py +++ b/bda/urls.py @@ -32,4 +32,7 @@ urlpatterns = patterns('', url(r'spectacles/unpaid/(?P\d+)$', "bda.views.unpaid", name="bda-unpaid"), + url(r'spectacles/add-attrib/(?P\d+)/(?P\d+)$', + 'bda.views.add_attrib', + name='bda-add-attrib'), ) diff --git a/bda/views.py b/bda/views.py index c79a5483..9c052c84 100644 --- a/bda/views.py +++ b/bda/views.py @@ -12,6 +12,8 @@ import hashlib from django.core.mail import send_mail from django.utils import timezone from django.views.generic.list import ListView +from django.http import HttpResponseRedirect +from django.core.urlresolvers import reverse from datetime import timedelta import time @@ -305,7 +307,18 @@ def spectacle(request, tirage_id, spectacle_id): return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants.values()}) - +@buro_required +def add_attrib(request, tirage_id, spectacle_id): + tirage = get_object_or_404(Tirage, id=tirage_id) + spectacle = get_object_or_404(Spectacle, id = spectacle_id, tirage=tirage) + # TODO : erreur + part= tirage.participant_set.get(user__username=request.POST['clipper']) + attrib = Attribution(participant=part, spectacle=spectacle, given=request.POST['given']) + attrib.save() + if request.POST['nb_places']==2: + attrib.save() + return HttpResponseRedirect(reverse('bda-spectacle', args=(tirage_id, spectacle_id,))) + class SpectacleListView(ListView): model = Spectacle template_name = 'spectacle_list.html' From 574aaad745915c1830f9909b97a2991e3bf82b0a Mon Sep 17 00:00:00 2001 From: ludo Date: Thu, 16 Jun 2016 15:09:14 +0200 Subject: [PATCH 08/31] =?UTF-8?q?gestion=20des=20erreurs=20et=20des=20mess?= =?UTF-8?q?ages=20associ=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/templates/bda-participants.html | 5 ++++- bda/views.py | 27 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html index 5cc678d1..ed3767a3 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda-participants.html @@ -2,6 +2,9 @@ {% block realcontent %}

    {{ spectacle }}

    + {% for message in messages %} +

    {{ message }}

    + {% endfor %} @@ -36,7 +39,7 @@ {% csrf_token %} - + -
    @@ -18,8 +18,13 @@ {% for participant in participants %} + + {% csrf_token %} - + - + + {% endfor %} @@ -48,7 +60,7 @@ - +
    {{participant.name}}{{participant.username}}{{participant.username}} + {{participant.nb_places}} place{{participant.nb_places|pluralize}} {{participant.email}} @@ -28,11 +33,18 @@ -
    - {% if participant.given %}Oui{% else %}Non{%endif%} +
    + {% if participant.given == participant.nb_places %}Oui + {% elif participant.given == 0 %}Non + {% else %}{{participant.given}}/{{participant.nb_places}} + {%endif%}

    diff --git a/bda/urls.py b/bda/urls.py index 8cd94d17..1617d36b 100644 --- a/bda/urls.py +++ b/bda/urls.py @@ -35,4 +35,7 @@ urlpatterns = patterns('', url(r'spectacles/add-attrib/(?P\d+)/(?P\d+)$', 'bda.views.add_attrib', name='bda-add-attrib'), + url(r'spectacles/del-attrib/(?P\d+)/(?P\d+)$', + 'bda.views.del_attrib', + name='bda-del-attrib'), ) diff --git a/bda/views.py b/bda/views.py index c8e250f1..3f446310 100644 --- a/bda/views.py +++ b/bda/views.py @@ -15,6 +15,7 @@ from django.views.generic.list import ListView from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse from django.contrib import messages +from django.views.decorators.http import require_POST from datetime import timedelta import time @@ -303,11 +304,12 @@ def spectacle(request, tirage_id, spectacle_id): 'name': participant.user.get_full_name, 'username':participant.user.username, 'email':participant.user.email, - 'given':attrib.given, + 'given':int(attrib.given), 'paid':participant.paid, 'nb_places':1} if participant.id in participants: - participants[participant.id]['nb_places'] = 2 + participants[participant.id]['nb_places'] += 1 + participants[participant.id]['given'] += attrib.given else: participants[participant.id] = participant_info @@ -317,9 +319,10 @@ def spectacle(request, tirage_id, spectacle_id): {"spectacle": spectacle, "participants": participants_info}) @buro_required +@require_POST def add_attrib(request, tirage_id, spectacle_id): tirage = get_object_or_404(Tirage, id=tirage_id) - spectacle = get_object_or_404(Spectacle, id = spectacle_id, tirage=tirage) + spectacle = get_object_or_404(Spectacle, id=spectacle_id, tirage=tirage) try: part=tirage.participant_set.get(user__username=request.POST['username']) except Participant.DoesNotExist: @@ -328,14 +331,6 @@ def add_attrib(request, tirage_id, spectacle_id): return HttpResponseRedirect(reverse('bda-spectacle', args=(tirage_id, spectacle_id,))) - places_owned = len(spectacle.attribues.filter(participant=part)) - - if int(request.POST['nb_places'])+places_owned > 2: - messages.add_message(request, messages.ERROR, - "Erreur: on ne peut pas avoir plus de deux places") - return HttpResponseRedirect(reverse('bda-spectacle', - args=(tirage_id, spectacle_id,))) - attrib = Attribution(participant=part, spectacle=spectacle, given=('given' in request.POST)) attrib.save() @@ -345,6 +340,20 @@ def add_attrib(request, tirage_id, spectacle_id): "Attribution réussie !") return HttpResponseRedirect(reverse('bda-spectacle', args=(tirage_id, spectacle_id,))) + +@buro_required +@require_POST +def del_attrib(request, tirage_id, spectacle_id): + tirage = get_object_or_404(Tirage, id=tirage_id) + spectacle = get_object_or_404(Spectacle, id=spectacle_id, tirage=tirage) + part = tirage.participant_set.get(user__username=request.POST['username']) + spectacle.attribues.filter(participant=part).delete() + + + messages.add_message(request, messages.SUCCESS, + "Attribution(s) supprimée(s) !") + return HttpResponseRedirect(reverse('bda-spectacle', + args=(tirage_id, spectacle_id,))) class SpectacleListView(ListView): model = Spectacle diff --git a/gestioncof/static/css/cof.css b/gestioncof/static/css/cof.css index d59e6ded..ed7363c9 100644 --- a/gestioncof/static/css/cof.css +++ b/gestioncof/static/css/cof.css @@ -601,6 +601,11 @@ pre code { .etat-bda tr:nth-child(even) {background: #CCC} +#bda-part-button { + border:none; + background-color:#eee +} + .greenratio { background-color: #3F3; border: 5px solid #ccc; From 2b43db8a79b916d10311ac8d7907402ec252c74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 17 Jun 2016 02:05:05 +0200 Subject: [PATCH 10/31] =?UTF-8?q?Corrige=20la=20liste=20des=20impay=C3=A9s?= =?UTF-8?q?=20dans=20bda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La liste des gens n'ayant pas payé leur places pour un tirage ne contient plus les participants n'ayant pas eu de place. Ajoute un compte des impayés dans le template. Fixes 43 --- bda/templates/bda-unpaid.html | 1 + bda/views.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bda/templates/bda-unpaid.html b/bda/templates/bda-unpaid.html index 5596dd82..df30cfd3 100644 --- a/bda/templates/bda-unpaid.html +++ b/bda/templates/bda-unpaid.html @@ -4,4 +4,5 @@

    Impayés

    +

    Total : {{ unpaid|length }}

    {% endblock %} diff --git a/bda/views.py b/bda/views.py index fd0a0cdc..9b0323ce 100644 --- a/bda/views.py +++ b/bda/views.py @@ -330,7 +330,8 @@ class SpectacleListView(ListView): def unpaid(request, tirage_id): tirage = get_object_or_404(Tirage, id=tirage_id) unpaid = tirage.participant_set.filter(paid=False).all() - return render(request, "bda-unpaid.html", {"unpaid": unpaid}) + really_unpaid = [part for part in unpaid if part.attribution_set.all()] + return render(request, "bda-unpaid.html", {"unpaid": really_unpaid}) @buro_required def liste_spectacles_ics(request, tirage_id): From 28487bc48352944f8446659551f0a05bf45cdee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 17 Jun 2016 13:26:55 +0200 Subject: [PATCH 11/31] Code cleanup --- gestioncof/admin.py | 37 +++++++++----- gestioncof/petits_cours_models.py | 81 +++++++++++++++++++------------ 2 files changed, 73 insertions(+), 45 deletions(-) diff --git a/gestioncof/admin.py b/gestioncof/admin.py index 785ab6a2..ee0f1409 100644 --- a/gestioncof/admin.py +++ b/gestioncof/admin.py @@ -9,7 +9,7 @@ from django.core.urlresolvers import reverse from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ -def add_link_field(target_model = '', field = '', link_text = unicode, desc_text = unicode): +def add_link_field(target_model='', field='', link_text=unicode, desc_text=unicode): def add_link(cls): reverse_name = target_model or cls.model.__name__.lower() def link(self, instance): @@ -30,7 +30,8 @@ def add_link_field(target_model = '', field = '', link_text = unicode, desc_text class SurveyQuestionAnswerInline(admin.TabularInline): model = SurveyQuestionAnswer -@add_link_field(desc_text = lambda x: "Réponses", link_text = lambda x: "Éditer les réponses") +@add_link_field(desc_text=lambda x: "Réponses", + link_text=lambda x: "Éditer les réponses") class SurveyQuestionInline(admin.TabularInline): model = SurveyQuestion @@ -47,7 +48,8 @@ class SurveyAdmin(admin.ModelAdmin): class EventOptionChoiceInline(admin.TabularInline): model = EventOptionChoice -@add_link_field(desc_text = lambda x: "Choix", link_text = lambda x: "Éditer les choix") +@add_link_field(desc_text=lambda x: "Choix", + link_text=lambda x: "Éditer les choix") class EventOptionInline(admin.TabularInline): model = EventOption @@ -67,7 +69,6 @@ class EventAdmin(admin.ModelAdmin): class CofProfileInline(admin.StackedInline): model = CofProfile - #form = BaseDynamicEntityForm inline_classes = ("collapse open",) class FkeyLookup(object): @@ -80,14 +81,15 @@ class FkeyLookup(object): def __get__(self, obj, klass): if obj is None: - return self # hack required to make Django validate (if obj is None, then we're a class, and classes are callable ) - + return self # hack required to make Django validate (if obj is + # None, then we're a class, and classes are callable + # ) item = getattr(obj, self.fk) for attr in self.fkattrs: item = getattr(item, attr) return item -def ProfileInfo(field, short_description, boolean = False): +def ProfileInfo(field, short_description, boolean=False): def getter(self): try: return getattr(self.profile, field) @@ -121,9 +123,14 @@ class UserProfileAdmin(UserAdmin): return False is_cof.short_description = 'Membre du COF' is_cof.boolean = True - list_display = ('profile_num',) + UserAdmin.list_display + ('profile_login_clipper','profile_phone','profile_occupation','profile_mailing_cof','profile_mailing_bda','profile_mailing_bda_revente','is_cof','is_buro',) + list_display = ('profile_num',) + UserAdmin.list_display \ + + ( 'profile_login_clipper','profile_phone','profile_occupation', + 'profile_mailing_cof','profile_mailing_bda', + 'profile_mailing_bda_revente','is_cof','is_buro',) list_display_links = ('username','email','first_name','last_name') - list_filter = UserAdmin.list_filter + ('profile__is_cof', 'profile__is_buro', 'profile__mailing_cof', 'profile__mailing_bda') + list_filter = UserAdmin.list_filter \ + + ( 'profile__is_cof', 'profile__is_buro', 'profile__mailing_cof', + 'profile__mailing_bda') search_fields = UserAdmin.search_fields + ('profile__phone',) inlines = [ CofProfileInline, @@ -140,11 +147,13 @@ class EventRegistrationAdmin(admin.ModelAdmin): form = autocomplete_light.modelform_factory(EventRegistration, exclude=[]) list_display = ('__unicode__','event','user','paid') list_filter = ('paid',) - search_fields = ('user__username', 'user__first_name', 'user__last_name', 'user__email', 'event__title') + search_fields = ('user__username', 'user__first_name', 'user__last_name', + 'user__email', 'event__title') class PetitCoursAbilityAdmin(admin.ModelAdmin): list_display = ('user','matiere','niveau','agrege') - search_fields = ('user__username', 'user__first_name', 'user__last_name', 'user__email', 'matiere__name', 'niveau') + search_fields = ('user__username', 'user__first_name', 'user__last_name', + 'user__email', 'matiere__name', 'niveau') list_filter = ('matiere','niveau','agrege') class PetitCoursAttributionAdmin(admin.ModelAdmin): @@ -153,10 +162,12 @@ class PetitCoursAttributionAdmin(admin.ModelAdmin): class PetitCoursAttributionCounterAdmin(admin.ModelAdmin): list_display = ('user','matiere','count',) list_filter = ('matiere',) - search_fields = ('user__username', 'user__first_name', 'user__last_name', 'user__email', 'matiere__name') + search_fields = ('user__username', 'user__first_name', 'user__last_name', + 'user__email', 'matiere__name') class PetitCoursDemandeAdmin(admin.ModelAdmin): - list_display = ('name','email','agrege_requis','niveau','created','traitee','processed') + list_display = ('name','email','agrege_requis','niveau','created', + 'traitee','processed') list_filter = ('traitee','niveau') admin.site.register(Survey, SurveyAdmin) diff --git a/gestioncof/petits_cours_models.py b/gestioncof/petits_cours_models.py index b9e03794..25f7ec15 100644 --- a/gestioncof/petits_cours_models.py +++ b/gestioncof/petits_cours_models.py @@ -17,9 +17,9 @@ LEVELS_CHOICES = ( ) class PetitCoursSubject(models.Model): - name = models.CharField(_(u"Matière"), max_length = 30) - users = models.ManyToManyField(User, related_name = "petits_cours_matieres", - through = "PetitCoursAbility") + name = models.CharField(_(u"Matière"), max_length=30) + users = models.ManyToManyField(User, related_name="petits_cours_matieres", + through="PetitCoursAbility") class Meta: verbose_name = "Matière de petits cours" @@ -30,11 +30,11 @@ class PetitCoursSubject(models.Model): class PetitCoursAbility(models.Model): user = models.ForeignKey(User) - matiere = models.ForeignKey(PetitCoursSubject, verbose_name = _(u"Matière")) + matiere = models.ForeignKey(PetitCoursSubject, verbose_name=_(u"Matière")) niveau = models.CharField (_(u"Niveau"), - choices = LEVELS_CHOICES, - max_length = choices_length (LEVELS_CHOICES)) - agrege = models.BooleanField(_(u"Agrégé"), default = False) + choices=LEVELS_CHOICES, + max_length=choices_length (LEVELS_CHOICES)) + agrege = models.BooleanField(_(u"Agrégé"), default=False) class Meta: verbose_name = "Compétence petits cours" @@ -44,27 +44,40 @@ class PetitCoursAbility(models.Model): return u"%s - %s - %s" % (self.user.username, self.matiere, self.niveau) class PetitCoursDemande(models.Model): - name = models.CharField(_(u"Nom/prénom"), max_length = 200) - email = models.CharField(_(u"Adresse email"), max_length = 300) - phone = models.CharField(_(u"Téléphone (facultatif)"), max_length = 20, blank = True) - quand = models.CharField(_(u"Quand ?"), help_text = _(u"Indiquez ici la période désirée pour les petits cours (vacances scolaires, semaine, week-end)."), max_length = 300, blank = True) - freq = models.CharField(_(u"Fréquence"), help_text = _(u"Indiquez ici la fréquence envisagée (hebdomadaire, 2 fois par semaine, ...)"), max_length = 300, blank = True) - lieu = models.CharField(_(u"Lieu (si préférence)"), help_text = _(u"Si vous avez avez une préférence sur le lieu."), max_length = 300, blank = True) + name = models.CharField(_(u"Nom/prénom"), max_length=200) + email = models.CharField(_(u"Adresse email"), max_length=300) + phone = models.CharField(_(u"Téléphone (facultatif)"), + max_length=20, blank=True) + quand = models.CharField( + _(u"Quand ?"), + help_text=_(u"Indiquez ici la période désirée pour les petits" \ + + "cours (vacances scolaires, semaine, week-end)."), + max_length=300, blank=True) + freq = models.CharField( + _(u"Fréquence"), + help_text=_(u"Indiquez ici la fréquence envisagée " \ + + "(hebdomadaire, 2 fois par semaine, ...)"), + max_length=300, blank=True) + lieu = models.CharField( + _(u"Lieu (si préférence)"), + help_text=_(u"Si vous avez avez une préférence sur le lieu."), + max_length=300, blank=True) - matieres = models.ManyToManyField(PetitCoursSubject, verbose_name = _(u"Matières"), - related_name = "demandes") - agrege_requis = models.BooleanField(_(u"Agrégé requis"), default = False) + matieres = models.ManyToManyField( + PetitCoursSubject, verbose_name=_(u"Matières"), + related_name="demandes") + agrege_requis = models.BooleanField(_(u"Agrégé requis"), default=False) niveau = models.CharField (_(u"Niveau"), - default = "", - choices = LEVELS_CHOICES, - max_length = choices_length (LEVELS_CHOICES)) + default="", + choices=LEVELS_CHOICES, + max_length=choices_length (LEVELS_CHOICES)) - remarques = models.TextField(_(u"Remarques et précisions"), blank = True) + remarques = models.TextField(_(u"Remarques et précisions"), blank=True) - traitee = models.BooleanField(_(u"Traitée"), default = False) - traitee_par = models.ForeignKey(User, blank = True, null = True) - processed = models.DateTimeField(_(u"Date de traitement"), blank = True) - created = models.DateTimeField(_(u"Date de création"), auto_now_add = True) + traitee = models.BooleanField(_(u"Traitée"), default=False) + traitee_par = models.ForeignKey(User, blank=True, null=True) + processed = models.DateTimeField(_(u"Date de traitement"), blank=True) + created = models.DateTimeField(_(u"Date de création"), auto_now_add=True) class Meta: verbose_name = "Demande de petits cours" @@ -75,27 +88,31 @@ class PetitCoursDemande(models.Model): class PetitCoursAttribution(models.Model): user = models.ForeignKey(User) - demande = models.ForeignKey(PetitCoursDemande, verbose_name = _("Demande")) - matiere = models.ForeignKey(PetitCoursSubject, verbose_name = _(u"Matière")) - date = models.DateTimeField(_(u"Date d'attribution"), auto_now_add = True) + demande = models.ForeignKey(PetitCoursDemande, verbose_name=_("Demande")) + matiere = models.ForeignKey(PetitCoursSubject, verbose_name=_(u"Matière")) + date = models.DateTimeField(_(u"Date d'attribution"), auto_now_add=True) rank = models.IntegerField("Rang dans l'email") - selected = models.BooleanField(_(u"Sélectionné par le demandeur"), default = False) + selected = models.BooleanField(_(u"Sélectionné par le demandeur"), + default=False) class Meta: verbose_name = "Attribution de petits cours" verbose_name_plural = "Attributions de petits cours" def __unicode__(self): - return u"Attribution de la demande %d à %s pour %s" % (self.demande.id, self.user.username, self.matiere) + return u"Attribution de la demande %d à %s pour %s" \ + % (self.demande.id, self.user.username, self.matiere) class PetitCoursAttributionCounter(models.Model): user = models.ForeignKey(User) - matiere = models.ForeignKey(PetitCoursSubject, verbose_name = _("Matiere")) - count = models.IntegerField("Nombre d'envois", default = 0) + matiere = models.ForeignKey(PetitCoursSubject, verbose_name=_("Matiere")) + count = models.IntegerField("Nombre d'envois", default=0) class Meta: verbose_name = "Compteur d'attribution de petits cours" verbose_name_plural = "Compteurs d'attributions de petits cours" def __unicode__(self): - return u"%d demandes envoyées à %s pour %s" % (self.count, self.user.username, self.matiere) + return u"%d demandes envoyées à %s pour %s" \ + % (self.count, self.user.username, self.matiere) + From 7808dd48044ccde5f9f244df88772634cc6a478e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 17 Jun 2016 13:29:26 +0200 Subject: [PATCH 12/31] =?UTF-8?q?Autorise=20les=20demandes=20de=20petits?= =?UTF-8?q?=20cours=20non=20trait=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plus précisément la date de traitement peut prendre la valeur `NULL`. --- .../0002_enable_unprocessed_demandes.py | 19 +++++++++++++++++++ gestioncof/petits_cours_models.py | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gestioncof/migrations/0002_enable_unprocessed_demandes.py diff --git a/gestioncof/migrations/0002_enable_unprocessed_demandes.py b/gestioncof/migrations/0002_enable_unprocessed_demandes.py new file mode 100644 index 00000000..18006588 --- /dev/null +++ b/gestioncof/migrations/0002_enable_unprocessed_demandes.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gestioncof', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='petitcoursdemande', + name='processed', + field=models.DateTimeField(null=True, verbose_name='Date de traitement', blank=True), + ), + ] diff --git a/gestioncof/petits_cours_models.py b/gestioncof/petits_cours_models.py index 25f7ec15..793c6840 100644 --- a/gestioncof/petits_cours_models.py +++ b/gestioncof/petits_cours_models.py @@ -76,7 +76,8 @@ class PetitCoursDemande(models.Model): traitee = models.BooleanField(_(u"Traitée"), default=False) traitee_par = models.ForeignKey(User, blank=True, null=True) - processed = models.DateTimeField(_(u"Date de traitement"), blank=True) + processed = models.DateTimeField(_(u"Date de traitement"), + blank=True, null=True) created = models.DateTimeField(_(u"Date de création"), auto_now_add=True) class Meta: From e67a0a27e9168e83581c35ba1ef00d666221ff55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 17 Jun 2016 13:47:33 +0200 Subject: [PATCH 13/31] Typo --- gestioncof/petits_cours_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestioncof/petits_cours_models.py b/gestioncof/petits_cours_models.py index 793c6840..47339a4e 100644 --- a/gestioncof/petits_cours_models.py +++ b/gestioncof/petits_cours_models.py @@ -51,7 +51,7 @@ class PetitCoursDemande(models.Model): quand = models.CharField( _(u"Quand ?"), help_text=_(u"Indiquez ici la période désirée pour les petits" \ - + "cours (vacances scolaires, semaine, week-end)."), + + " cours (vacances scolaires, semaine, week-end)."), max_length=300, blank=True) freq = models.CharField( _(u"Fréquence"), From 199895630e4e6d2174e302f0bf02fc6bd9a0cfa2 Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 17 Jun 2016 16:31:08 +0200 Subject: [PATCH 14/31] Gestion de plus de deux places --- bda/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bda/views.py b/bda/views.py index 26ca7cb7..826b2e7f 100644 --- a/bda/views.py +++ b/bda/views.py @@ -334,8 +334,11 @@ def add_attrib(request, tirage_id, spectacle_id): attrib = Attribution(participant=part, spectacle=spectacle, given=('given' in request.POST)) attrib.save() - if request.POST['nb_places']==2: - attrib.save() + if int(request.POST['nb_places'])==2: + attrib2 = Attribution(participant=part, spectacle=spectacle, + given=('given' in request.POST)) + attrib2.save() + messages.add_message(request, messages.SUCCESS, "Attribution réussie !") return HttpResponseRedirect(reverse('bda-spectacle', From fc9805658210741260a459646d1a915f8d21811b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 22 Jun 2016 02:16:24 +0200 Subject: [PATCH 15/31] Typo --- bda/templates/bda-unpaid.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bda/templates/bda-unpaid.html b/bda/templates/bda-unpaid.html index df30cfd3..a424dce2 100644 --- a/bda/templates/bda-unpaid.html +++ b/bda/templates/bda-unpaid.html @@ -4,5 +4,5 @@

    Impayés

    -

    Total : {{ unpaid|length }}

    +

    Total : {{ unpaid|length }}

    {% endblock %} From 24e88a95a3ffd8cb765277daea90a5400febcbb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 22 Jun 2016 02:29:20 +0200 Subject: [PATCH 16/31] =?UTF-8?q?Filtre=20les=20participants=20dans=20la?= =?UTF-8?q?=20requ=C3=AAte=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Et non plus en python --- bda/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bda/views.py b/bda/views.py index 9b0323ce..85e62e8d 100644 --- a/bda/views.py +++ b/bda/views.py @@ -5,6 +5,7 @@ from __future__ import division from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required from django.db import models +from django.db.models import Count from django.core import serializers from django.forms.models import inlineformset_factory import hashlib @@ -329,9 +330,10 @@ class SpectacleListView(ListView): @buro_required def unpaid(request, tirage_id): tirage = get_object_or_404(Tirage, id=tirage_id) - unpaid = tirage.participant_set.filter(paid=False).all() - really_unpaid = [part for part in unpaid if part.attribution_set.all()] - return render(request, "bda-unpaid.html", {"unpaid": really_unpaid}) + unpaid = tirage.participant_set \ + .annotate(nb_attributions=Count('attribution')) \ + .filter(paid=False, nb_attributions__gt=0).all() + return render(request, "bda-unpaid.html", {"unpaid": unpaid}) @buro_required def liste_spectacles_ics(request, tirage_id): From f074ba146cf6f7097ac9aee420419f373cae8ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 22 Jun 2016 22:43:44 +0200 Subject: [PATCH 17/31] =?UTF-8?q?Liens=20vers=20la=20liste=20des=20partici?= =?UTF-8?q?pants=20=C3=A0=20un=20tirage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ces nouveaux liens sont sur la page d'accueil dans la partie BdA en bas de l'écran. C'eLe hack n'est pas forcément très beau mais ça marche. --- gestioncof/templates/home.html | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gestioncof/templates/home.html b/gestioncof/templates/home.html index 52c0ebfd..898b2626 100644 --- a/gestioncof/templates/home.html +++ b/gestioncof/templates/home.html @@ -63,15 +63,21 @@
  • Sondage : {{ survey.title }}
  • {% endfor %}
    +

    Gestion tirages BDA

    + -
    -
  • Liens utiles du COF
  • -
  • Liens utiles BdA
  • - +

    Liens utiles

    + {% endif %}

    Pour tout problème : cof@ens.fr.

    From 7e90bcce423aead83c30ca27f26bdd490918b092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 22 Jun 2016 22:49:00 +0200 Subject: [PATCH 18/31] Corrige des urls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Les urls vers les évéments et sondage avaient un `survey`/`event` de trop : `/survey/survey/1`. - On ajoute un `^` dans lers urls de `gestioncof.urls` pour demander des urls exactes : `export/mega` et non `export/trucmega` --- gestioncof/urls.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gestioncof/urls.py b/gestioncof/urls.py index f8693d57..a8a38dbc 100644 --- a/gestioncof/urls.py +++ b/gestioncof/urls.py @@ -2,41 +2,41 @@ from django.conf.urls import url from gestioncof.petits_cours_views import DemandeListView export_patterns = [ - url(r'members$', 'gestioncof.views.export_members'), - url(r'mega/avecremarques$', 'gestioncof.views.export_mega_remarksonly'), - url(r'mega/participants$', 'gestioncof.views.export_mega_participants'), - url(r'mega/orgas$', 'gestioncof.views.export_mega_orgas'), - url(r'mega/(?P.+)$', 'gestioncof.views.export_mega_bytype'), - url(r'mega$', 'gestioncof.views.export_mega'), + url(r'^members$', 'gestioncof.views.export_members'), + url(r'^mega/avecremarques$', 'gestioncof.views.export_mega_remarksonly'), + url(r'^mega/participants$', 'gestioncof.views.export_mega_participants'), + url(r'^mega/orgas$', 'gestioncof.views.export_mega_orgas'), + url(r'^mega/(?P.+)$', 'gestioncof.views.export_mega_bytype'), + url(r'^mega$', 'gestioncof.views.export_mega'), ] petitcours_patterns = [ - url(r'inscription$', 'gestioncof.petits_cours_views.inscription', + url(r'^inscription$', 'gestioncof.petits_cours_views.inscription', name='petits-cours-inscription'), - url(r'demande$', 'gestioncof.petits_cours_views.demande', + url(r'^demande$', 'gestioncof.petits_cours_views.demande', name='petits-cours-demande'), - url(r'demande-raw$', 'gestioncof.petits_cours_views.demande_raw', + url(r'^demande-raw$', 'gestioncof.petits_cours_views.demande_raw', name='petits-cours-demande-raw'), - url(r'demandes$', DemandeListView.as_view(), + url(r'^demandes$', DemandeListView.as_view(), name='petits-cours-demandes-list'), - url(r'demandes/(?P\d+)$', 'gestioncof.petits_cours_views.details', + url(r'^demandes/(?P\d+)$', 'gestioncof.petits_cours_views.details', name='petits-cours-demande-details'), - url(r'demandes/(?P\d+)/traitement$', + url(r'^demandes/(?P\d+)/traitement$', 'gestioncof.petits_cours_views.traitement', name='petits-cours-demande-traitement'), - url(r'demandes/(?P\d+)/retraitement$', + url(r'^demandes/(?P\d+)/retraitement$', 'gestioncof.petits_cours_views.retraitement', name='petits-cours-demande-retraitement'), ] surveys_patterns = [ - url(r'^survey/(?P\d+)/status$', 'gestioncof.views.survey_status'), - url(r'^survey/(?P\d+)$', 'gestioncof.views.survey'), + url(r'^(?P\d+)/status$', 'gestioncof.views.survey_status'), + url(r'^(?P\d+)$', 'gestioncof.views.survey'), ] events_patterns = [ - url(r'^event/(?P\d+)$', 'gestioncof.views.event'), - url(r'^event/(?P\d+)/status$', 'gestioncof.views.event_status'), + url(r'^(?P\d+)$', 'gestioncof.views.event'), + url(r'^(?P\d+)/status$', 'gestioncof.views.event_status'), ] From 93e7fbf87dd247efd312a298ca59e0b3b3f92835 Mon Sep 17 00:00:00 2001 From: ludo Date: Thu, 23 Jun 2016 18:07:01 +0200 Subject: [PATCH 19/31] redirige admin/logout vers /logout --- cof/urls.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cof/urls.py b/cof/urls.py index ce7cd6f6..f0b3c207 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -53,6 +53,7 @@ urlpatterns = patterns('', url(r'^autocomplete/registration$', 'gestioncof.autocomplete.autocomplete'), url(r'^autocomplete/', include('autocomplete_light.urls')), # Interface admin + url(r'^admin/logout/', 'gestioncof.views.logout'), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/(?P[\d\w]+)/(?P[\d\w]+)/csv/', 'gestioncof.csv_views.admin_list_export', From 2b056a58b23d8609f97fb3db72ee3c1cc9b6cc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 24 Jun 2016 13:59:07 +0200 Subject: [PATCH 20/31] Fix typo --- gestioncof/templates/home.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestioncof/templates/home.html b/gestioncof/templates/home.html index 898b2626..ed567455 100644 --- a/gestioncof/templates/home.html +++ b/gestioncof/templates/home.html @@ -69,7 +69,7 @@ {% for tirage in open_tirages %}

    {{ tirage.title }}

  • Spectacles
  • -
  • Participants
  • +
  • Participants
  • {% endfor %} From 929e70f5d3bae2c1ed08b1702c57d061b9b83e2a Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 24 Jun 2016 16:38:14 +0200 Subject: [PATCH 21/31] Lien vers l'interface admin --- bda/templates/bda-participants.html | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html index 9669c939..2ec22155 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda-participants.html @@ -5,6 +5,7 @@ {% for message in messages %}

    {{ message }}

    {% endfor %} +

    Ajouter une attribution

    @@ -18,13 +19,8 @@ {% for participant in participants %} - - {% csrf_token %} - - {% endfor %} - - {% csrf_token %} - - - - - - - - -
    {{participant.name}} {{participant.username}} - {{participant.nb_places}} place{{participant.nb_places|pluralize}} {{participant.email}} @@ -43,25 +39,8 @@ {%endif%}
    -

    From 8e8c9a173a1721177fe3067948b57687fa280974 Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 24 Jun 2016 16:52:21 +0200 Subject: [PATCH 22/31] suppression fonctions inutiles --- bda/views.py | 40 ----------------------------------- gestioncof/static/css/cof.css | 5 ----- 2 files changed, 45 deletions(-) diff --git a/bda/views.py b/bda/views.py index a7acc127..d72a0a10 100644 --- a/bda/views.py +++ b/bda/views.py @@ -320,46 +320,6 @@ def spectacle(request, tirage_id, spectacle_id): return render(request, "bda-participants.html", {"spectacle": spectacle, "participants": participants_info}) -@buro_required -@require_POST -def add_attrib(request, tirage_id, spectacle_id): - tirage = get_object_or_404(Tirage, id=tirage_id) - spectacle = get_object_or_404(Spectacle, id=spectacle_id, tirage=tirage) - try: - part=tirage.participant_set.get(user__username=request.POST['username']) - except Participant.DoesNotExist: - messages.add_message(request, messages.ERROR, - u"Erreur : utilisateur %s non trouvé" % request.POST['username']) - return HttpResponseRedirect(reverse('bda-spectacle', - args=(tirage_id, spectacle_id,))) - - attrib = Attribution(participant=part, spectacle=spectacle, - given=('given' in request.POST)) - attrib.save() - if int(request.POST['nb_places'])==2: - attrib2 = Attribution(participant=part, spectacle=spectacle, - given=('given' in request.POST)) - attrib2.save() - - messages.add_message(request, messages.SUCCESS, - "Attribution réussie !") - return HttpResponseRedirect(reverse('bda-spectacle', - args=(tirage_id, spectacle_id,))) - -@buro_required -@require_POST -def del_attrib(request, tirage_id, spectacle_id): - tirage = get_object_or_404(Tirage, id=tirage_id) - spectacle = get_object_or_404(Spectacle, id=spectacle_id, tirage=tirage) - part = tirage.participant_set.get(user__username=request.POST['username']) - spectacle.attribues.filter(participant=part).delete() - - - messages.add_message(request, messages.SUCCESS, - "Attribution(s) supprimée(s) !") - return HttpResponseRedirect(reverse('bda-spectacle', - args=(tirage_id, spectacle_id,))) - class SpectacleListView(ListView): model = Spectacle template_name = 'spectacle_list.html' diff --git a/gestioncof/static/css/cof.css b/gestioncof/static/css/cof.css index ed7363c9..d59e6ded 100644 --- a/gestioncof/static/css/cof.css +++ b/gestioncof/static/css/cof.css @@ -601,11 +601,6 @@ pre code { .etat-bda tr:nth-child(even) {background: #CCC} -#bda-part-button { - border:none; - background-color:#eee -} - .greenratio { background-color: #3F3; border: 5px solid #ccc; From 963c545eb8aa384363f9eebe837c844a43c09d1f Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 24 Jun 2016 16:54:59 +0200 Subject: [PATCH 23/31] suppression fonctions inutiles --- bda/urls.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bda/urls.py b/bda/urls.py index 1617d36b..d3f4fe2f 100644 --- a/bda/urls.py +++ b/bda/urls.py @@ -32,10 +32,4 @@ urlpatterns = patterns('', url(r'spectacles/unpaid/(?P\d+)$', "bda.views.unpaid", name="bda-unpaid"), - url(r'spectacles/add-attrib/(?P\d+)/(?P\d+)$', - 'bda.views.add_attrib', - name='bda-add-attrib'), - url(r'spectacles/del-attrib/(?P\d+)/(?P\d+)$', - 'bda.views.del_attrib', - name='bda-del-attrib'), ) From 36a711339dc40f4758a95f9b49d70c593a01b5c3 Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 24 Jun 2016 16:56:43 +0200 Subject: [PATCH 24/31] syntax correction --- bda/templates/bda-participants.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html index 2ec22155..1748a027 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda-participants.html @@ -20,7 +20,7 @@ {% for participant in participants %}
    {{participant.name}}{{participant.username}} + {{participant.username}} {{participant.nb_places}} place{{participant.nb_places|pluralize}} {{participant.email}} From 67b56edc3386eb7bf4cd035374fddd56544f6522 Mon Sep 17 00:00:00 2001 From: ludo Date: Sat, 25 Jun 2016 03:37:05 +0200 Subject: [PATCH 25/31] remove useless code --- bda/views.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bda/views.py b/bda/views.py index d72a0a10..1206fec6 100644 --- a/bda/views.py +++ b/bda/views.py @@ -12,10 +12,6 @@ import hashlib from django.core.mail import send_mail from django.utils import timezone from django.views.generic.list import ListView -from django.http import HttpResponseRedirect -from django.core.urlresolvers import reverse -from django.contrib import messages -from django.views.decorators.http import require_POST from datetime import timedelta import time From 4596d588e9160fa600379160a589b220e7736515 Mon Sep 17 00:00:00 2001 From: ludo Date: Sat, 25 Jun 2016 03:37:28 +0200 Subject: [PATCH 26/31] Finished >2 attributions support --- bda/templates/bda-participants.html | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html index 1748a027..a54242d5 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda-participants.html @@ -2,10 +2,7 @@ {% block realcontent %}

    {{ spectacle }}

    - {% for message in messages %} -

    {{ message }}

    - {% endfor %} -

    Ajouter une attribution

    +

    Ajouter une attribution

    @@ -50,8 +47,7 @@
    From 442f358cf5c35a19ae39a85aa4157d420f311ccb Mon Sep 17 00:00:00 2001 From: ludo Date: Sat, 25 Jun 2016 23:17:31 +0200 Subject: [PATCH 27/31] =?UTF-8?q?Ajoute=20une=20v=C3=A9rification=20de=20t?= =?UTF-8?q?irage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bda/admin.py | 11 +++++++++++ bda/models.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bda/admin.py b/bda/admin.py index 476f7d89..0e257593 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -5,6 +5,7 @@ from django.core.mail import send_mail from django.contrib import admin from django.db.models import Sum, Count from bda.models import Spectacle, Salle, Participant, ChoixSpectacle, Attribution, Tirage +from django import forms from datetime import timedelta @@ -107,6 +108,15 @@ Le Bureau des Arts self.message_user(request, u"%s été informé%s avec succès." % (message_bit, plural)) send_attribs.short_description = u"Envoyer les résultats par mail" +class AttributionAdminForm(forms.ModelForm): + def clean(self): + cleaned_data=super(AttributionAdminForm, self).clean() + participant = cleaned_data.get("participant") + spectacle = cleaned_data.get("spectacle") + if participant and spectacle: + if participant.tirage != spectacle.tirage: + raise forms.ValidationError(u"Erreur : le participant et le spectacle n'appartiennent pas au même tirage") + class AttributionAdmin(admin.ModelAdmin): def paid(self, obj): return obj.participant.paid @@ -114,6 +124,7 @@ class AttributionAdmin(admin.ModelAdmin): paid.boolean = True list_display = ("id", "spectacle", "participant", "given", "paid") search_fields = ('spectacle__title', 'participant__user__username', 'participant__user__first_name', 'participant__user__last_name') + form = AttributionAdminForm import autocomplete_light class ChoixSpectacleAdmin(admin.ModelAdmin): diff --git a/bda/models.py b/bda/models.py index 16ea4818..294870c6 100644 --- a/bda/models.py +++ b/bda/models.py @@ -75,7 +75,7 @@ class Participant(models.Model): tirage = models.ForeignKey(Tirage) def __unicode__ (self): - return u"%s" % (self.user) + return u"%s, %s" % (self.user, self.tirage.title) DOUBLE_CHOICES = ( ("1", "1 place"), From dc02e9cd45db8379c7953c1335f2bf2959d8b46f Mon Sep 17 00:00:00 2001 From: ludo Date: Mon, 27 Jun 2016 13:18:58 +0200 Subject: [PATCH 28/31] ajoute des filtres pour les voeux et spectacles --- bda/admin.py | 11 +++++++---- bda/models.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bda/admin.py b/bda/admin.py index 0e257593..604ac883 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -116,6 +116,7 @@ class AttributionAdminForm(forms.ModelForm): if participant and spectacle: if participant.tirage != spectacle.tirage: raise forms.ValidationError(u"Erreur : le participant et le spectacle n'appartiennent pas au même tirage") + return cleaned_data class AttributionAdmin(admin.ModelAdmin): def paid(self, obj): @@ -129,14 +130,16 @@ class AttributionAdmin(admin.ModelAdmin): import autocomplete_light class ChoixSpectacleAdmin(admin.ModelAdmin): form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[]) - list_display = ("participant", "spectacle", "priority", "double_choice") - list_filter = ("double_choice",) + def tirage(self, obj): + return obj.participant.tirage + list_display = ("participant", "tirage", "spectacle", "priority", "double_choice") + list_filter = ("double_choice", "participant__tirage") search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name') class SpectacleAdmin(admin.ModelAdmin): model = Spectacle - list_display = ("title", "date", "location", "slots", "price") - list_filter = ("location",) + list_display = ("title", "date", "tirage", "location", "slots", "price") + list_filter = ("location", "tirage",) search_fields = ("title", "location__name") class TirageAdmin(admin.ModelAdmin): diff --git a/bda/models.py b/bda/models.py index 294870c6..16ea4818 100644 --- a/bda/models.py +++ b/bda/models.py @@ -75,7 +75,7 @@ class Participant(models.Model): tirage = models.ForeignKey(Tirage) def __unicode__ (self): - return u"%s, %s" % (self.user, self.tirage.title) + return u"%s" % (self.user) DOUBLE_CHOICES = ( ("1", "1 place"), From d4040670f519effc71aebba3a8614a05024c6e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 27 Jun 2016 18:47:31 +0200 Subject: [PATCH 29/31] Typos --- bda/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bda/views.py b/bda/views.py index 1206fec6..996a92fb 100644 --- a/bda/views.py +++ b/bda/views.py @@ -300,11 +300,11 @@ def spectacle(request, tirage_id, spectacle_id): participant = attrib.participant participant_info = {'lastname': participant.user.last_name, 'name': participant.user.get_full_name, - 'username':participant.user.username, - 'email':participant.user.email, - 'given':int(attrib.given), - 'paid':participant.paid, - 'nb_places':1} + 'username': participant.user.username, + 'email': participant.user.email, + 'given': int(attrib.given), + 'paid': participant.paid, + 'nb_places': 1} if participant.id in participants: participants[participant.id]['nb_places'] += 1 participants[participant.id]['given'] += attrib.given From c8fb4cdbe9a405d955dafccfa1715da664afea10 Mon Sep 17 00:00:00 2001 From: ludo Date: Mon, 27 Jun 2016 19:11:39 +0200 Subject: [PATCH 30/31] fix l'export des membres du COF --- gestioncof/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gestioncof/views.py b/gestioncof/views.py index 70084e14..886083c8 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -403,7 +403,7 @@ def export_members(request): response = HttpResponse(content_type = 'text/csv') response['Content-Disposition'] = 'attachment; filename=membres_cof.csv' - writer = unicodecsv.UnicodeWriter(response) + writer = unicodecsv.writer(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] From 315606e254332a3c804a58073edbde55c5518395 Mon Sep 17 00:00:00 2001 From: ludo Date: Mon, 27 Jun 2016 19:13:53 +0200 Subject: [PATCH 31/31] fix l'export des membres du COF --- gestioncof/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gestioncof/views.py b/gestioncof/views.py index 886083c8..a862c773 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -415,7 +415,7 @@ def export_members(request): def csv_export_mega(filename, qs): response = HttpResponse(content_type = 'text/csv') response['Content-Disposition'] = 'attachment; filename=' + filename - writer = unicodecsv.UnicodeWriter(response) + writer = unicodecsv.writer(response) for reg in qs.all(): user = reg.user @@ -431,7 +431,7 @@ def export_mega_remarksonly(request): filename = 'remarques_mega_2015.csv' response = HttpResponse(content_type = 'text/csv') response['Content-Disposition'] = 'attachment; filename=' + filename - writer = unicodecsv.UnicodeWriter(response) + writer = unicodecsv.writer(response) event = Event.objects.get(title = "Mega 15") commentfield = event.commentfields.get(name = "Commentaires")