From 8142ef2ee52aa27e1af71ab466d86b5eb9d5d5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 8 Jun 2016 22:28:38 +0200 Subject: [PATCH 1/9] =?UTF-8?q?S=C3=A9pare=20les=20urls=20entre=20les=20di?= =?UTF-8?q?ff=C3=A9rentes=20apps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajoute des commentaires dans `cof/urls` qui donnent des indications sur les groupes d'urls. Enjolive le code --- bda/urls.py | 36 +++++++++++++++++++++ cof/urls.py | 78 +++++++++++++++++++++++----------------------- gestioncof/urls.py | 42 +++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 39 deletions(-) create mode 100644 bda/urls.py create mode 100644 gestioncof/urls.py diff --git a/bda/urls.py b/bda/urls.py new file mode 100644 index 00000000..a1ba1d8c --- /dev/null +++ b/bda/urls.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +from django.conf.urls import include, url, patterns +from bda import views +from bda.views import SpectacleListView + +urlpatterns = patterns('', + url(r'inscription/(?P\d+)$', + 'bda.views.inscription', + name='bda-tirage-inscription'), + url(r'places/(?P\d+)$', + 'bda.views.places', + name="bda-places-attribuees"), + url(r'places/(?P\d+)/places_bda.ics$', + 'bda.views.places_ics', + name="bda-places-attribuees-ics"), + url(r'revente/(?P\d+)$', + 'bda.views.revente', + name='bda-revente'), + url(r'etat-places/(?P\d+)$', + 'bda.views.etat_places', + name='bda-etat-places'), + url(r'tirage/(?P\d+)$', 'bda.views.tirage'), + url(r'spectacles/(?P\d+)$', + SpectacleListView.as_view() , + name ="bda-liste-spectacles"), + url(r'spectacles/(?P\d+)/(?P\d+)$', + "bda.views.spectacle", + name="bda-spectacle"), + url(r'spectacles-ics/(?P\d+)$', + 'bda.views.liste_spectacles_ics', + name ="bda-liste-spectacles-ics"), + url(r'spectacles/unpaid/(?P\d+)$', + "bda.views.unpaid", + name="bda-unpaid"), +) diff --git a/cof/urls.py b/cof/urls.py index e841ee02..0e21c428 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -7,62 +7,62 @@ from django.contrib import admin admin.autodiscover() from django.views.generic.base import TemplateView -from bda.models import Spectacle -from bda.views import SpectacleListView -from gestioncof.petits_cours_views import DemandeListView + +from gestioncof.urls import export_patterns, petitcours_patterns, \ + surveys_patterns, events_patterns urlpatterns = patterns('', + # Page d'accueil url(r'^$', 'gestioncof.views.home', name = 'home'), - url(r'^cof/denied$', TemplateView.as_view(template_name = 'cof-denied.html'), name = "cof-denied"), - url(r'^cas/login$', 'django_cas_ng.views.login', name = "cas_login_view"), + # Le BdA + url(r'^bda/', include('bda.urls')), + # Les exports + url(r'^export/', include(export_patterns)), + # Les petits cours + url(r'^petitcours/', include(petitcours_patterns)), + # Les sondages + url(r'^survey/', include(surveys_patterns)), + # Evenements + url(r'^event/', include(events_patterns)), + # Authentification + url(r'^cof/denied$', TemplateView.as_view(template_name='cof-denied.html'), + name="cof-denied"), + url(r'^cas/login$', 'django_cas_ng.views.login', name="cas_login_view"), url(r'^cas/logout$', 'django_cas_ng.views.logout'), url(r'^outsider/login$', 'gestioncof.views.login_ext'), - url(r'^outsider/logout$', 'django.contrib.auth.views.logout', {'next_page': '/gestion/'}), - url(r'^outsider/password-change$', 'django.contrib.auth.views.password_change'), - url(r'^outsider/password-change-done$', 'django.contrib.auth.views.password_change_done'), + url(r'^outsider/logout$', 'django.contrib.auth.views.logout', + {'next_page': '/gestion/'}), url(r'^login$', 'gestioncof.views.login'), url(r'^logout$', 'gestioncof.views.logout'), + # Infos persos url(r'^profile$', 'gestioncof.views.profile'), - url(r'^export/members$', 'gestioncof.views.export_members'), - url(r'^export/mega/avecremarques$', 'gestioncof.views.export_mega_remarksonly'), - url(r'^export/mega/participants$', 'gestioncof.views.export_mega_participants'), - url(r'^export/mega/orgas$', 'gestioncof.views.export_mega_orgas'), - url(r'^export/mega/(?P.+)$', 'gestioncof.views.export_mega_bytype'), - url(r'^export/mega$', 'gestioncof.views.export_mega'), + url(r'^outsider/password-change$', + 'django.contrib.auth.views.password_change'), + url(r'^outsider/password-change-done$', + 'django.contrib.auth.views.password_change_done'), + # Inscription d'un nouveau membre url(r'^registration$', 'gestioncof.views.registration'), - url(r'^registration/clipper/(?P[\w-]+)$', 'gestioncof.views.registration_form2', name = "clipper-registration"), - url(r'^registration/user/(?P.+)$', 'gestioncof.views.registration_form2', name = "user-registration"), - url(r'^registration/empty$', 'gestioncof.views.registration_form2', name = "empty-registration"), - url(r'^petitcours/inscription$', 'gestioncof.petits_cours_views.inscription', name = 'petits-cours-inscription'), - url(r'^petitcours/demande$', 'gestioncof.petits_cours_views.demande', name = 'petits-cours-demande'), - url(r'^petitcours/demande-raw$', 'gestioncof.petits_cours_views.demande_raw', name = 'petits-cours-demande-raw'), - url(r'^petitcours/demandes$', DemandeListView.as_view(), name = 'petits-cours-demandes-list'), - url(r'^petitcours/demandes/(?P\d+)$', 'gestioncof.petits_cours_views.details', name = 'petits-cours-demande-details'), - url(r'^petitcours/demandes/(?P\d+)/traitement$', 'gestioncof.petits_cours_views.traitement', name = 'petits-cours-demande-traitement'), - url(r'^petitcours/demandes/(?P\d+)/retraitement$', 'gestioncof.petits_cours_views.retraitement', name = 'petits-cours-demande-retraitement'), - url(r'^bda/inscription/(?P\d+)$', 'bda.views.inscription', name = 'bda-tirage-inscription'), - url(r'^bda/places/(?P\d+)$', 'bda.views.places', name = "bda-places-attribuees"), - url(r'^bda/places/(?P\d+)/places_bda.ics$', 'bda.views.places_ics', name = "bda-places-attribuees-ics"), - url(r'^bda/revente/(?P\d+)$', 'bda.views.revente', name = 'bda-revente'), - url(r'^bda/etat-places/(?P\d+)$', 'bda.views.etat_places', name = 'bda-etat-places'), - url(r'^bda/tirage/(?P\d+)$', 'bda.views.tirage'), - url(r'^bda/spectacles/(?P\d+)$', SpectacleListView.as_view() , name ="bda-liste-spectacles"), - url(r'^bda/spectacles/(?P\d+)/(?P\d+)$', "bda.views.spectacle", name = "bda-spectacle"), - url(r'^bda/spectacles-ics/(?P\d+)$', 'bda.views.liste_spectacles_ics', name ="bda-liste-spectacles-ics"), - url(r'^bda/spectacles/unpaid/(?P\d+)$', "bda.views.unpaid", name = "bda-unpaid"), - url(r'^survey/(?P\d+)$', 'gestioncof.views.survey'), - url(r'^event/(?P\d+)$', 'gestioncof.views.event'), - url(r'^survey/(?P\d+)/status$', 'gestioncof.views.survey_status'), - url(r'^event/(?P\d+)/status$', 'gestioncof.views.event_status'), + url(r'^registration/clipper/(?P[\w-]+)$', + 'gestioncof.views.registration_form2', name="clipper-registration"), + url(r'^registration/user/(?P.+)$', + 'gestioncof.views.registration_form2', name="user-registration"), + url(r'^registration/empty$', 'gestioncof.views.registration_form2', + name="empty-registration"), + # Autocompletion url(r'^autocomplete/registration$', 'gestioncof.autocomplete.autocomplete'), url(r'^autocomplete/', include('autocomplete_light.urls')), + # Interface admin 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', {'fields': ['username',]}), + url(r'^admin/(?P[\d\w]+)/(?P[\d\w]+)/csv/', + 'gestioncof.csv_views.admin_list_export', + {'fields': ['username',]}), url(r'^admin/', include(admin.site.urls)), url(r'^grappelli/', include('grappelli.urls')), + # Liens utiles du COF et du BdA url(r'^utile_cof$', 'gestioncof.views.utile_cof'), url(r'^utile_bda$', 'gestioncof.views.utile_bda'), url(r'^utile_bda/bda_diff$', 'gestioncof.views.liste_bdadiff'), url(r'^utile_cof/diff_cof$', 'gestioncof.views.liste_diffcof'), url(r'^utile_bda/bda_revente$', 'gestioncof.views.liste_bdarevente'), ) + diff --git a/gestioncof/urls.py b/gestioncof/urls.py new file mode 100644 index 00000000..f8693d57 --- /dev/null +++ b/gestioncof/urls.py @@ -0,0 +1,42 @@ +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'), +] + +petitcours_patterns = [ + url(r'inscription$', 'gestioncof.petits_cours_views.inscription', + name='petits-cours-inscription'), + url(r'demande$', 'gestioncof.petits_cours_views.demande', + name='petits-cours-demande'), + url(r'demande-raw$', 'gestioncof.petits_cours_views.demande_raw', + name='petits-cours-demande-raw'), + url(r'demandes$', DemandeListView.as_view(), + name='petits-cours-demandes-list'), + url(r'demandes/(?P\d+)$', 'gestioncof.petits_cours_views.details', + name='petits-cours-demande-details'), + url(r'demandes/(?P\d+)/traitement$', + 'gestioncof.petits_cours_views.traitement', + name='petits-cours-demande-traitement'), + 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'), +] + +events_patterns = [ + url(r'^event/(?P\d+)$', 'gestioncof.views.event'), + url(r'^event/(?P\d+)/status$', 'gestioncof.views.event_status'), +] + + From 12118a61612aead74acb3aaef897d3b353ca3f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Thu, 9 Jun 2016 01:17:54 +0200 Subject: [PATCH 2/9] Fixe la vue de changement de mot de passe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La vue par défaut cherchait l'url `password_change_done`. Ce fix créer un alias `password_change_done` qui pointe vers la bonne vue. --- cof/urls.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cof/urls.py b/cof/urls.py index e841ee02..3a7680d6 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -19,7 +19,9 @@ urlpatterns = patterns('', url(r'^outsider/login$', 'gestioncof.views.login_ext'), url(r'^outsider/logout$', 'django.contrib.auth.views.logout', {'next_page': '/gestion/'}), url(r'^outsider/password-change$', 'django.contrib.auth.views.password_change'), - url(r'^outsider/password-change-done$', 'django.contrib.auth.views.password_change_done'), + url(r'^outsider/password-change-done$', + 'django.contrib.auth.views.password_change_done', + name='password_change_done'), url(r'^login$', 'gestioncof.views.login'), url(r'^logout$', 'gestioncof.views.logout'), url(r'^profile$', 'gestioncof.views.profile'), From 34fc334987ba608edb4563de1d9fd8d6ee504207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 10 Jun 2016 00:49:04 +0200 Subject: [PATCH 3/9] Ajoute le backend 'console' pour les mails en dev. --- cof/settings_dev.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 401127ef..75f67646 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -15,6 +15,7 @@ import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ From 7f18d93c5f37880ae43c76b95b09f6fdb33838d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 10 Jun 2016 01:06:43 +0200 Subject: [PATCH 4/9] =?UTF-8?q?Effectue=20des=20migrations=20oubli=C3=A9es?= =?UTF-8?q?=20dans=20!17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le champ `price` des spectacles est devenu obligatoire. Le champ `active` des tirages prends désormais la valeur False par défaut. --- .../0003_update_tirage_and_spectacle.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bda/migrations/0003_update_tirage_and_spectacle.py diff --git a/bda/migrations/0003_update_tirage_and_spectacle.py b/bda/migrations/0003_update_tirage_and_spectacle.py new file mode 100644 index 00000000..f5ca671a --- /dev/null +++ b/bda/migrations/0003_update_tirage_and_spectacle.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bda', '0002_add_tirage'), + ] + + operations = [ + migrations.AlterField( + model_name='spectacle', + name='price', + field=models.FloatField(verbose_name=b"Prix d'une place"), + ), + migrations.AlterField( + model_name='tirage', + name='active', + field=models.BooleanField(default=False, verbose_name=b'Tirage actif'), + ), + ] From 233130499206ff5d40f3c451b7df9e670e0c2e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 10 Jun 2016 15:43:37 +0200 Subject: [PATCH 5/9] Adopte le comportement de python3 pour la division MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les deux seuls fichiers touchés sont `bda/views.py` et `bda/algorithm.py` d'après un `grep -r '/' . | grep '\.py' | grep -v '^Binary' à la racine du projet. --- bda/algorithm.py | 4 +++- bda/views.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bda/algorithm.py b/bda/algorithm.py index bce41282..a6caf531 100644 --- a/bda/algorithm.py +++ b/bda/algorithm.py @@ -1,5 +1,7 @@ # coding: utf-8 +from __future__ import division + from django.conf import settings from django.db.models import Max @@ -62,7 +64,7 @@ class Algorithm(object): def __call__(self, seed): random.seed(seed) results = [] - shows = sorted(self.shows, key = lambda x: float(x.nrequests) / x.slots, reverse = True) + shows = sorted(self.shows, key = lambda x: x.nrequests / x.slots, reverse = True) for show in shows: # On regroupe tous les gens ayant le même rang groups = dict([(i, []) for i in range(1, self.max_group + 1)]) diff --git a/bda/views.py b/bda/views.py index f4495f55..6dc36b55 100644 --- a/bda/views.py +++ b/bda/views.py @@ -1,5 +1,7 @@ # coding: utf-8 +from __future__ import division + from django.contrib.auth.models import User from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required @@ -49,13 +51,13 @@ def etat_places(request, tirage_id): spectacles_dict[spectacle["spectacle"]].total += spectacle["total"] spectacles_dict[spectacle["spectacle"]].ratio = \ spectacles_dict[spectacle["spectacle"]].total / \ - float(spectacles_dict[spectacle["spectacle"]].slots) + spectacles_dict[spectacle["spectacle"]].slots total += spectacle["total"] for spectacle in spectacles2: spectacles_dict[spectacle["spectacle"]].total += 2*spectacle["total"] spectacles_dict[spectacle["spectacle"]].ratio = \ spectacles_dict[spectacle["spectacle"]].total / \ - float(spectacles_dict[spectacle["spectacle"]].slots) + spectacles_dict[spectacle["spectacle"]].slots total += spectacle["total"] return render(request, "etat-places.html", {"spectacles": spectacles, "total": total, 'tirage': tirage}) From 624c431d773cf4dc5d3f81888d4c0bc218d6dc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 10 Jun 2016 17:04:00 +0200 Subject: [PATCH 6/9] Customise la vue Tirage dans admin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajoute des infos les infos suivantes sur la liste des tirages : - Titre - Ouverture - Fermeture - Tirage actif On permet la recherche sur le champ titre. On empêche l'édition de la graine du tirage (`token`). Il s'agit d'une archive et ne doit pas être modifiée. --- bda/admin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bda/admin.py b/bda/admin.py index 8af71d00..aa3ce254 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -128,9 +128,16 @@ class SpectacleAdmin(admin.ModelAdmin): list_filter = ("location",) search_fields = ("title", "location__name") +class TirageAdmin(admin.ModelAdmin): + model = Tirage + list_display = ("title", "ouverture", "fermeture", "active") + readonly_fields = ("token", ) + list_filter = ("active", ) + search_fields = ("title", ) + admin.site.register(Spectacle, SpectacleAdmin) admin.site.register(Salle) admin.site.register(Participant, ParticipantAdmin) admin.site.register(Attribution, AttributionAdmin) admin.site.register(ChoixSpectacle, ChoixSpectacleAdmin) -admin.site.register(Tirage) +admin.site.register(Tirage, TirageAdmin) From 7a8e27d0a3e08b03576ec4a0bf6a3c8fce6edf9f Mon Sep 17 00:00:00 2001 From: Qwann Date: Fri, 10 Jun 2016 18:01:03 +0200 Subject: [PATCH 7/9] affiche maintenant le prix dans dans l'interface admin, quand on clique sur un particpant --- bda/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bda/admin.py b/bda/admin.py index 8af71d00..07d082d1 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -38,6 +38,7 @@ class ParticipantAdmin(admin.ModelAdmin): actions = ['send_attribs',] actions_on_bottom = True list_per_page = 400 + readonly_fields = ("total",) def send_attribs(self, request, queryset): for member in queryset.all(): From b222c944f69f8f230af3868779aaac45cda7a327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 10 Jun 2016 23:16:39 +0200 Subject: [PATCH 8/9] =?UTF-8?q?Change=20la=20redirection=20apr=C3=A8s=20'/?= =?UTF-8?q?outsider/logout'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On change `/gestion/` en `home` qui fait la même chose mais fonctionne à la fois en dev et en prod. --- cof/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cof/urls.py b/cof/urls.py index b9628d0f..ce7cd6f6 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -31,7 +31,7 @@ urlpatterns = patterns('', url(r'^cas/logout$', 'django_cas_ng.views.logout'), url(r'^outsider/login$', 'gestioncof.views.login_ext'), url(r'^outsider/logout$', 'django.contrib.auth.views.logout', - {'next_page': '/gestion/'}), + {'next_page': 'home'}), url(r'^login$', 'gestioncof.views.login'), url(r'^logout$', 'gestioncof.views.logout'), # Infos persos From 3229441cb70fd7c6b40009bbae05fc6c0dc02b73 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Fri, 10 Jun 2016 23:59:41 +0200 Subject: [PATCH 9/9] Nettoyage de code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Essentiellement, suppression d'import inutilisés. --- bda/admin.py | 1 - bda/algorithm.py | 1 - bda/forms.py | 2 +- bda/models.py | 1 - bda/urls.py | 3 +-- bda/views.py | 16 ---------------- gestioncof/admin.py | 3 --- gestioncof/csv_views.py | 11 ----------- gestioncof/forms.py | 5 ++--- gestioncof/petits_cours_models.py | 1 - gestioncof/petits_cours_views.py | 2 +- gestioncof/shared.py | 2 +- gestioncof/views.py | 6 +----- tirage_bda.py | 2 +- 14 files changed, 8 insertions(+), 48 deletions(-) diff --git a/bda/admin.py b/bda/admin.py index 0c991237..2cdce0a6 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -1,7 +1,6 @@ # coding: utf-8 from django.core.mail import send_mail -from django.contrib.contenttypes.models import ContentType from django.contrib import admin from django.db.models import Sum, Count diff --git a/bda/algorithm.py b/bda/algorithm.py index a6caf531..77770377 100644 --- a/bda/algorithm.py +++ b/bda/algorithm.py @@ -2,7 +2,6 @@ from __future__ import division -from django.conf import settings from django.db.models import Max import random diff --git a/bda/forms.py b/bda/forms.py index d61623db..acc2d4b5 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -2,7 +2,7 @@ from django import forms from django.forms.models import BaseInlineFormSet -from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution +from bda.models import Spectacle class BaseBdaFormSet(BaseInlineFormSet): def clean(self): diff --git a/bda/models.py b/bda/models.py index cab8ce41..16ea4818 100644 --- a/bda/models.py +++ b/bda/models.py @@ -5,7 +5,6 @@ import calendar from django.db import models from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ -from django.db.models.signals import post_save class Tirage(models.Model): title = models.CharField("Titre", max_length=300) diff --git a/bda/urls.py b/bda/urls.py index a1ba1d8c..d3f4fe2f 100644 --- a/bda/urls.py +++ b/bda/urls.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -from django.conf.urls import include, url, patterns -from bda import views +from django.conf.urls import url, patterns from bda.views import SpectacleListView urlpatterns = patterns('', diff --git a/bda/views.py b/bda/views.py index 6dc36b55..41c3c94d 100644 --- a/bda/views.py +++ b/bda/views.py @@ -2,11 +2,9 @@ from __future__ import division -from django.contrib.auth.models import User from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required from django.db import models -from django.http import Http404 from django.core import serializers from django.forms.models import inlineformset_factory import hashlib @@ -19,7 +17,6 @@ from datetime import timedelta import time from gestioncof.decorators import cof_required, buro_required -from gestioncof.shared import send_custom_mail from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution, Tirage from bda.algorithm import Algorithm @@ -120,7 +117,6 @@ def places_ics(request, tirage_id): places_dict[place.spectacle] = place spectacles.append(place.spectacle) filtered_places.append(place) - date = place.spectacle.date.date() return render(request, "resume_places.ics", {"participant": participant, "places": filtered_places}, content_type="text/calendar") @@ -264,18 +260,6 @@ def do_resell(request, form): spectacle = form.cleaned_data["spectacle"] count = form.cleaned_data["count"] places = "2 places" if count == "2" else "une place" - """ - send_custom_mail("bda-revente@lists.ens.fr", - "bda-revente", - {"places": places, - "spectacle": spectacle.title, - "date": spectacle.date_no_seconds(), - "lieu": spectacle.location, - "prix": spectacle.price, - "revendeur": request.user.get_full_name(), - "revendeur_mail": request.user.email}, - from_email = request.user.email) - """ mail = u"""Bonjour, Je souhaite revendre %s pour %s le %s (%s) à %.02f€. diff --git a/gestioncof/admin.py b/gestioncof/admin.py index 24f3dc38..785ab6a2 100644 --- a/gestioncof/admin.py +++ b/gestioncof/admin.py @@ -7,10 +7,7 @@ from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin from django.core.urlresolvers import reverse from django.utils.safestring import mark_safe -import django.forms as forms from django.utils.translation import ugettext_lazy as _ -from django.contrib.admin import SimpleListFilter -from django.db.models import Q def add_link_field(target_model = '', field = '', link_text = unicode, desc_text = unicode): def add_link(cls): diff --git a/gestioncof/csv_views.py b/gestioncof/csv_views.py index 10eda18a..f921953f 100644 --- a/gestioncof/csv_views.py +++ b/gestioncof/csv_views.py @@ -2,7 +2,6 @@ import csv from django.http import HttpResponse, HttpResponseForbidden from django.template.defaultfilters import slugify from django.apps import apps -from django.contrib.auth.models import User def export(qs, fields=None): model = qs.model @@ -40,16 +39,6 @@ def admin_list_export(request, model_name, app_label, queryset=None, fields=None if not queryset: model = apps.get_model(app_label, model_name) queryset = model.objects.all() - filters = dict() - """ - for key, value in request.GET.items(): - if key not in ('ot', 'o'): - filters[str(key)] = str(value) - if len(filters): - queryset = queryset.filter(**filters) - """ - #qs2 = User.objects.filter(profile__eav__a_vot = True) - #queryset = queryset.filter(pk__in = qs2.values_list('id', flat = True)) queryset = queryset.filter(profile__is_cof = True) if not fields: if list_display and len(queryset.model._meta.admin.list_display) > 1: diff --git a/gestioncof/forms.py b/gestioncof/forms.py index 2f0f78ac..751755b4 100644 --- a/gestioncof/forms.py +++ b/gestioncof/forms.py @@ -4,10 +4,11 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User from django.forms.widgets import RadioSelect, CheckboxSelectMultiple +from django.db.models import Max from gestioncof.models import CofProfile, EventCommentValue from gestioncof.widgets import TriStateCheckbox -from gestioncof.shared import lock_table, unlock_table, send_custom_mail +from gestioncof.shared import lock_table, unlock_table class EventForm(forms.Form): def __init__(self, *args, **kwargs): @@ -82,7 +83,6 @@ 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) @@ -242,7 +242,6 @@ class AdminEventForm(forms.Form): kwargs["initial"] = {"status":"no"} super(AdminEventForm, self).__init__(*args, **kwargs) choices = {} - comments = {} for choice in current_choices: if choice.event_option.id not in choices: choices[choice.event_option.id] = [choice.id] diff --git a/gestioncof/petits_cours_models.py b/gestioncof/petits_cours_models.py index e7c56f0c..b9e03794 100644 --- a/gestioncof/petits_cours_models.py +++ b/gestioncof/petits_cours_models.py @@ -3,7 +3,6 @@ from django.db import models from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ -from django.db.models.signals import post_save def choices_length (choices): return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0) diff --git a/gestioncof/petits_cours_views.py b/gestioncof/petits_cours_views.py index 0b9ac048..a5347948 100644 --- a/gestioncof/petits_cours_views.py +++ b/gestioncof/petits_cours_views.py @@ -15,7 +15,7 @@ from django.conf import settings from django.contrib.auth.decorators import login_required from django.db.models import Min -from gestioncof.models import CofProfile, Clipper +from gestioncof.models import CofProfile from gestioncof.petits_cours_models import * from gestioncof.decorators import buro_required from gestioncof.shared import lock_table, unlock_tables diff --git a/gestioncof/shared.py b/gestioncof/shared.py index 5a6c7775..4bdd9aa5 100644 --- a/gestioncof/shared.py +++ b/gestioncof/shared.py @@ -4,7 +4,7 @@ from django_cas_ng.backends import CASBackend from django_cas_ng.utils import get_cas_client from django.contrib.auth import get_user_model from django.contrib.auth.models import User as DjangoUser -from django.db import models, connection +from django.db import connection from django.core.mail import send_mail from django.template import Template, Context diff --git a/gestioncof/views.py b/gestioncof/views.py index 71dab9a3..963fd5f5 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -4,9 +4,7 @@ import unicodecsv from django.shortcuts import redirect, get_object_or_404, render from django.http import Http404, HttpResponse -from django.core.urlresolvers import reverse from django.contrib.auth.decorators import login_required -from django.db.models import Max from django.contrib.auth.views import login as django_login_view from django.contrib.auth.models import User @@ -15,15 +13,13 @@ from gestioncof.models import Event, EventRegistration, EventOption, EventOption from gestioncof.models import EventCommentField, EventCommentValue from gestioncof.shared import send_custom_mail from gestioncof.models import CofProfile, Clipper -from gestioncof.decorators import buro_required, cof_required +from gestioncof.decorators import buro_required from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \ SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \ RegistrationProfileForm, AdminEventForm, EventForm from bda.models import Tirage -import re - @login_required def home(request): data = {"surveys": Survey.objects.filter(old=False).all(), diff --git a/tirage_bda.py b/tirage_bda.py index d73b3e0a..cedf48d7 100644 --- a/tirage_bda.py +++ b/tirage_bda.py @@ -8,7 +8,7 @@ if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings") from django.conf import settings settings.DEBUG = True - from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution + from bda.models import Spectacle, Participant, ChoixSpectacle from bda.algorithm import Algorithm from django.db.models import Sum from django.db import connection