forked from DGNum/gestioCOF
Merge branch 'master' of https://git.eleves.ens.fr/cof-geek/gestioCOF into Aufinal/view_spectacles
This commit is contained in:
commit
d424089a55
18 changed files with 165 additions and 89 deletions
11
bda/admin.py
11
bda/admin.py
|
@ -1,7 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.contrib.contenttypes.models import ContentType
|
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.db.models import Sum, Count
|
from django.db.models import Sum, Count
|
||||||
|
@ -38,6 +37,7 @@ class ParticipantAdmin(admin.ModelAdmin):
|
||||||
actions = ['send_attribs',]
|
actions = ['send_attribs',]
|
||||||
actions_on_bottom = True
|
actions_on_bottom = True
|
||||||
list_per_page = 400
|
list_per_page = 400
|
||||||
|
readonly_fields = ("total",)
|
||||||
|
|
||||||
def send_attribs(self, request, queryset):
|
def send_attribs(self, request, queryset):
|
||||||
for member in queryset.all():
|
for member in queryset.all():
|
||||||
|
@ -128,9 +128,16 @@ class SpectacleAdmin(admin.ModelAdmin):
|
||||||
list_filter = ("location",)
|
list_filter = ("location",)
|
||||||
search_fields = ("title", "location__name")
|
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(Spectacle, SpectacleAdmin)
|
||||||
admin.site.register(Salle)
|
admin.site.register(Salle)
|
||||||
admin.site.register(Participant, ParticipantAdmin)
|
admin.site.register(Participant, ParticipantAdmin)
|
||||||
admin.site.register(Attribution, AttributionAdmin)
|
admin.site.register(Attribution, AttributionAdmin)
|
||||||
admin.site.register(ChoixSpectacle, ChoixSpectacleAdmin)
|
admin.site.register(ChoixSpectacle, ChoixSpectacleAdmin)
|
||||||
admin.site.register(Tirage)
|
admin.site.register(Tirage, TirageAdmin)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from django.conf import settings
|
from __future__ import division
|
||||||
|
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
@ -62,7 +63,7 @@ class Algorithm(object):
|
||||||
def __call__(self, seed):
|
def __call__(self, seed):
|
||||||
random.seed(seed)
|
random.seed(seed)
|
||||||
results = []
|
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:
|
for show in shows:
|
||||||
# On regroupe tous les gens ayant le même rang
|
# On regroupe tous les gens ayant le même rang
|
||||||
groups = dict([(i, []) for i in range(1, self.max_group + 1)])
|
groups = dict([(i, []) for i in range(1, self.max_group + 1)])
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.forms.models import BaseInlineFormSet
|
from django.forms.models import BaseInlineFormSet
|
||||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution
|
from bda.models import Spectacle
|
||||||
|
|
||||||
class BaseBdaFormSet(BaseInlineFormSet):
|
class BaseBdaFormSet(BaseInlineFormSet):
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|
24
bda/migrations/0003_update_tirage_and_spectacle.py
Normal file
24
bda/migrations/0003_update_tirage_and_spectacle.py
Normal file
|
@ -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'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -5,7 +5,6 @@ import calendar
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db.models.signals import post_save
|
|
||||||
|
|
||||||
class Tirage(models.Model):
|
class Tirage(models.Model):
|
||||||
title = models.CharField("Titre", max_length=300)
|
title = models.CharField("Titre", max_length=300)
|
||||||
|
|
35
bda/urls.py
Normal file
35
bda/urls.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from django.conf.urls import url, patterns
|
||||||
|
from bda.views import SpectacleListView
|
||||||
|
|
||||||
|
urlpatterns = patterns('',
|
||||||
|
url(r'inscription/(?P<tirage_id>\d+)$',
|
||||||
|
'bda.views.inscription',
|
||||||
|
name='bda-tirage-inscription'),
|
||||||
|
url(r'places/(?P<tirage_id>\d+)$',
|
||||||
|
'bda.views.places',
|
||||||
|
name="bda-places-attribuees"),
|
||||||
|
url(r'places/(?P<tirage_id>\d+)/places_bda.ics$',
|
||||||
|
'bda.views.places_ics',
|
||||||
|
name="bda-places-attribuees-ics"),
|
||||||
|
url(r'revente/(?P<tirage_id>\d+)$',
|
||||||
|
'bda.views.revente',
|
||||||
|
name='bda-revente'),
|
||||||
|
url(r'etat-places/(?P<tirage_id>\d+)$',
|
||||||
|
'bda.views.etat_places',
|
||||||
|
name='bda-etat-places'),
|
||||||
|
url(r'tirage/(?P<tirage_id>\d+)$', 'bda.views.tirage'),
|
||||||
|
url(r'spectacles/(?P<tirage_id>\d+)$',
|
||||||
|
SpectacleListView.as_view() ,
|
||||||
|
name ="bda-liste-spectacles"),
|
||||||
|
url(r'spectacles/(?P<tirage_id>\d+)/(?P<spectacle_id>\d+)$',
|
||||||
|
"bda.views.spectacle",
|
||||||
|
name="bda-spectacle"),
|
||||||
|
url(r'spectacles-ics/(?P<tirage_id>\d+)$',
|
||||||
|
'bda.views.liste_spectacles_ics',
|
||||||
|
name ="bda-liste-spectacles-ics"),
|
||||||
|
url(r'spectacles/unpaid/(?P<tirage_id>\d+)$',
|
||||||
|
"bda.views.unpaid",
|
||||||
|
name="bda-unpaid"),
|
||||||
|
)
|
22
bda/views.py
22
bda/views.py
|
@ -1,10 +1,10 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from __future__ import division
|
||||||
|
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.http import Http404
|
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
from django.forms.models import inlineformset_factory
|
from django.forms.models import inlineformset_factory
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -17,7 +17,6 @@ from datetime import timedelta
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from gestioncof.decorators import cof_required, buro_required
|
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.models import Spectacle, Participant, ChoixSpectacle, Attribution, Tirage
|
||||||
from bda.algorithm import Algorithm
|
from bda.algorithm import Algorithm
|
||||||
|
|
||||||
|
@ -49,13 +48,13 @@ def etat_places(request, tirage_id):
|
||||||
spectacles_dict[spectacle["spectacle"]].total += spectacle["total"]
|
spectacles_dict[spectacle["spectacle"]].total += spectacle["total"]
|
||||||
spectacles_dict[spectacle["spectacle"]].ratio = \
|
spectacles_dict[spectacle["spectacle"]].ratio = \
|
||||||
spectacles_dict[spectacle["spectacle"]].total / \
|
spectacles_dict[spectacle["spectacle"]].total / \
|
||||||
float(spectacles_dict[spectacle["spectacle"]].slots)
|
spectacles_dict[spectacle["spectacle"]].slots
|
||||||
total += spectacle["total"]
|
total += spectacle["total"]
|
||||||
for spectacle in spectacles2:
|
for spectacle in spectacles2:
|
||||||
spectacles_dict[spectacle["spectacle"]].total += 2*spectacle["total"]
|
spectacles_dict[spectacle["spectacle"]].total += 2*spectacle["total"]
|
||||||
spectacles_dict[spectacle["spectacle"]].ratio = \
|
spectacles_dict[spectacle["spectacle"]].ratio = \
|
||||||
spectacles_dict[spectacle["spectacle"]].total / \
|
spectacles_dict[spectacle["spectacle"]].total / \
|
||||||
float(spectacles_dict[spectacle["spectacle"]].slots)
|
spectacles_dict[spectacle["spectacle"]].slots
|
||||||
total += spectacle["total"]
|
total += spectacle["total"]
|
||||||
return render(request, "etat-places.html",
|
return render(request, "etat-places.html",
|
||||||
{"spectacles": spectacles, "total": total, 'tirage': tirage})
|
{"spectacles": spectacles, "total": total, 'tirage': tirage})
|
||||||
|
@ -118,7 +117,6 @@ def places_ics(request, tirage_id):
|
||||||
places_dict[place.spectacle] = place
|
places_dict[place.spectacle] = place
|
||||||
spectacles.append(place.spectacle)
|
spectacles.append(place.spectacle)
|
||||||
filtered_places.append(place)
|
filtered_places.append(place)
|
||||||
date = place.spectacle.date.date()
|
|
||||||
return render(request, "resume_places.ics",
|
return render(request, "resume_places.ics",
|
||||||
{"participant": participant,
|
{"participant": participant,
|
||||||
"places": filtered_places}, content_type="text/calendar")
|
"places": filtered_places}, content_type="text/calendar")
|
||||||
|
@ -262,18 +260,6 @@ def do_resell(request, form):
|
||||||
spectacle = form.cleaned_data["spectacle"]
|
spectacle = form.cleaned_data["spectacle"]
|
||||||
count = form.cleaned_data["count"]
|
count = form.cleaned_data["count"]
|
||||||
places = "2 places" if count == "2" else "une place"
|
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,
|
mail = u"""Bonjour,
|
||||||
|
|
||||||
Je souhaite revendre %s pour %s le %s (%s) à %.02f€.
|
Je souhaite revendre %s pour %s le %s (%s) à %.02f€.
|
||||||
|
|
|
@ -15,6 +15,7 @@ import os
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
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
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
|
||||||
|
|
79
cof/urls.py
79
cof/urls.py
|
@ -7,62 +7,63 @@ from django.contrib import admin
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from bda.models import Spectacle
|
|
||||||
from bda.views import SpectacleListView
|
from gestioncof.urls import export_patterns, petitcours_patterns, \
|
||||||
from gestioncof.petits_cours_views import DemandeListView
|
surveys_patterns, events_patterns
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
|
# Page d'accueil
|
||||||
url(r'^$', 'gestioncof.views.home', name = 'home'),
|
url(r'^$', 'gestioncof.views.home', name = 'home'),
|
||||||
url(r'^cof/denied$', TemplateView.as_view(template_name = 'cof-denied.html'), name = "cof-denied"),
|
# Le BdA
|
||||||
url(r'^cas/login$', 'django_cas_ng.views.login', name = "cas_login_view"),
|
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'^cas/logout$', 'django_cas_ng.views.logout'),
|
||||||
url(r'^outsider/login$', 'gestioncof.views.login_ext'),
|
url(r'^outsider/login$', 'gestioncof.views.login_ext'),
|
||||||
url(r'^outsider/logout$', 'django.contrib.auth.views.logout', {'next_page': '/gestion/'}),
|
url(r'^outsider/logout$', 'django.contrib.auth.views.logout',
|
||||||
url(r'^outsider/password-change$', 'django.contrib.auth.views.password_change'),
|
{'next_page': 'home'}),
|
||||||
url(r'^outsider/password-change-done$', 'django.contrib.auth.views.password_change_done'),
|
|
||||||
url(r'^login$', 'gestioncof.views.login'),
|
url(r'^login$', 'gestioncof.views.login'),
|
||||||
url(r'^logout$', 'gestioncof.views.logout'),
|
url(r'^logout$', 'gestioncof.views.logout'),
|
||||||
|
# Infos persos
|
||||||
url(r'^profile$', 'gestioncof.views.profile'),
|
url(r'^profile$', 'gestioncof.views.profile'),
|
||||||
url(r'^export/members$', 'gestioncof.views.export_members'),
|
url(r'^outsider/password-change$',
|
||||||
url(r'^export/mega/avecremarques$', 'gestioncof.views.export_mega_remarksonly'),
|
'django.contrib.auth.views.password_change'),
|
||||||
url(r'^export/mega/participants$', 'gestioncof.views.export_mega_participants'),
|
url(r'^outsider/password-change-done$',
|
||||||
url(r'^export/mega/orgas$', 'gestioncof.views.export_mega_orgas'),
|
'django.contrib.auth.views.password_change_done',
|
||||||
url(r'^export/mega/(?P<type>.+)$', 'gestioncof.views.export_mega_bytype'),
|
name='password_change_done'),
|
||||||
url(r'^export/mega$', 'gestioncof.views.export_mega'),
|
# Inscription d'un nouveau membre
|
||||||
url(r'^registration$', 'gestioncof.views.registration'),
|
url(r'^registration$', 'gestioncof.views.registration'),
|
||||||
url(r'^registration/clipper/(?P<login_clipper>[\w-]+)$', 'gestioncof.views.registration_form2', name = "clipper-registration"),
|
url(r'^registration/clipper/(?P<login_clipper>[\w-]+)$',
|
||||||
url(r'^registration/user/(?P<username>.+)$', 'gestioncof.views.registration_form2', name = "user-registration"),
|
'gestioncof.views.registration_form2', name="clipper-registration"),
|
||||||
url(r'^registration/empty$', 'gestioncof.views.registration_form2', name = "empty-registration"),
|
url(r'^registration/user/(?P<username>.+)$',
|
||||||
url(r'^petitcours/inscription$', 'gestioncof.petits_cours_views.inscription', name = 'petits-cours-inscription'),
|
'gestioncof.views.registration_form2', name="user-registration"),
|
||||||
url(r'^petitcours/demande$', 'gestioncof.petits_cours_views.demande', name = 'petits-cours-demande'),
|
url(r'^registration/empty$', 'gestioncof.views.registration_form2',
|
||||||
url(r'^petitcours/demande-raw$', 'gestioncof.petits_cours_views.demande_raw', name = 'petits-cours-demande-raw'),
|
name="empty-registration"),
|
||||||
url(r'^petitcours/demandes$', DemandeListView.as_view(), name = 'petits-cours-demandes-list'),
|
# Autocompletion
|
||||||
url(r'^petitcours/demandes/(?P<demande_id>\d+)$', 'gestioncof.petits_cours_views.details', name = 'petits-cours-demande-details'),
|
|
||||||
url(r'^petitcours/demandes/(?P<demande_id>\d+)/traitement$', 'gestioncof.petits_cours_views.traitement', name = 'petits-cours-demande-traitement'),
|
|
||||||
url(r'^petitcours/demandes/(?P<demande_id>\d+)/retraitement$', 'gestioncof.petits_cours_views.retraitement', name = 'petits-cours-demande-retraitement'),
|
|
||||||
url(r'^bda/inscription/(?P<tirage_id>\d+)$', 'bda.views.inscription', name = 'bda-tirage-inscription'),
|
|
||||||
url(r'^bda/places/(?P<tirage_id>\d+)$', 'bda.views.places', name = "bda-places-attribuees"),
|
|
||||||
url(r'^bda/places/(?P<tirage_id>\d+)/places_bda.ics$', 'bda.views.places_ics', name = "bda-places-attribuees-ics"),
|
|
||||||
url(r'^bda/revente/(?P<tirage_id>\d+)$', 'bda.views.revente', name = 'bda-revente'),
|
|
||||||
url(r'^bda/etat-places/(?P<tirage_id>\d+)$', 'bda.views.etat_places', name = 'bda-etat-places'),
|
|
||||||
url(r'^bda/tirage/(?P<tirage_id>\d+)$', 'bda.views.tirage'),
|
|
||||||
url(r'^bda/spectacles/(?P<tirage_id>\d+)$', SpectacleListView.as_view() , name ="bda-liste-spectacles"),
|
|
||||||
url(r'^bda/spectacles/(?P<tirage_id>\d+)/(?P<spectacle_id>\d+)$', "bda.views.spectacle", name = "bda-spectacle"),
|
|
||||||
url(r'^bda/spectacles-ics/(?P<tirage_id>\d+)$', 'bda.views.liste_spectacles_ics', name ="bda-liste-spectacles-ics"),
|
|
||||||
url(r'^bda/spectacles/unpaid/(?P<tirage_id>\d+)$', "bda.views.unpaid", name = "bda-unpaid"),
|
|
||||||
url(r'^survey/(?P<survey_id>\d+)$', 'gestioncof.views.survey'),
|
|
||||||
url(r'^event/(?P<event_id>\d+)$', 'gestioncof.views.event'),
|
|
||||||
url(r'^survey/(?P<survey_id>\d+)/status$', 'gestioncof.views.survey_status'),
|
|
||||||
url(r'^event/(?P<event_id>\d+)/status$', 'gestioncof.views.event_status'),
|
|
||||||
url(r'^autocomplete/registration$', 'gestioncof.autocomplete.autocomplete'),
|
url(r'^autocomplete/registration$', 'gestioncof.autocomplete.autocomplete'),
|
||||||
url(r'^autocomplete/', include('autocomplete_light.urls')),
|
url(r'^autocomplete/', include('autocomplete_light.urls')),
|
||||||
|
# Interface admin
|
||||||
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
url(r'^admin/(?P<app_label>[\d\w]+)/(?P<model_name>[\d\w]+)/csv/', 'gestioncof.csv_views.admin_list_export', {'fields': ['username',]}),
|
url(r'^admin/(?P<app_label>[\d\w]+)/(?P<model_name>[\d\w]+)/csv/',
|
||||||
|
'gestioncof.csv_views.admin_list_export',
|
||||||
|
{'fields': ['username',]}),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^grappelli/', include('grappelli.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_cof$', 'gestioncof.views.utile_cof'),
|
||||||
url(r'^utile_bda$', 'gestioncof.views.utile_bda'),
|
url(r'^utile_bda$', 'gestioncof.views.utile_bda'),
|
||||||
url(r'^utile_bda/bda_diff$', 'gestioncof.views.liste_bdadiff'),
|
url(r'^utile_bda/bda_diff$', 'gestioncof.views.liste_bdadiff'),
|
||||||
url(r'^utile_cof/diff_cof$', 'gestioncof.views.liste_diffcof'),
|
url(r'^utile_cof/diff_cof$', 'gestioncof.views.liste_diffcof'),
|
||||||
url(r'^utile_bda/bda_revente$', 'gestioncof.views.liste_bdarevente'),
|
url(r'^utile_bda/bda_revente$', 'gestioncof.views.liste_bdarevente'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@ from django.contrib.auth.models import User
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
import django.forms as forms
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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_field(target_model = '', field = '', link_text = unicode, desc_text = unicode):
|
||||||
def add_link(cls):
|
def add_link(cls):
|
||||||
|
|
|
@ -2,7 +2,6 @@ import csv
|
||||||
from django.http import HttpResponse, HttpResponseForbidden
|
from django.http import HttpResponse, HttpResponseForbidden
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.contrib.auth.models import User
|
|
||||||
|
|
||||||
def export(qs, fields=None):
|
def export(qs, fields=None):
|
||||||
model = qs.model
|
model = qs.model
|
||||||
|
@ -40,16 +39,6 @@ def admin_list_export(request, model_name, app_label, queryset=None, fields=None
|
||||||
if not queryset:
|
if not queryset:
|
||||||
model = apps.get_model(app_label, model_name)
|
model = apps.get_model(app_label, model_name)
|
||||||
queryset = model.objects.all()
|
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)
|
queryset = queryset.filter(profile__is_cof = True)
|
||||||
if not fields:
|
if not fields:
|
||||||
if list_display and len(queryset.model._meta.admin.list_display) > 1:
|
if list_display and len(queryset.model._meta.admin.list_display) > 1:
|
||||||
|
|
|
@ -4,10 +4,11 @@ from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
|
||||||
|
from django.db.models import Max
|
||||||
|
|
||||||
from gestioncof.models import CofProfile, EventCommentValue
|
from gestioncof.models import CofProfile, EventCommentValue
|
||||||
from gestioncof.widgets import TriStateCheckbox
|
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):
|
class EventForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -82,7 +83,6 @@ class SurveyStatusFilterForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
survey = kwargs.pop("survey")
|
survey = kwargs.pop("survey")
|
||||||
super(SurveyStatusFilterForm, self).__init__(*args, **kwargs)
|
super(SurveyStatusFilterForm, self).__init__(*args, **kwargs)
|
||||||
answers = {}
|
|
||||||
for question in survey.questions.all():
|
for question in survey.questions.all():
|
||||||
for answer in question.answers.all():
|
for answer in question.answers.all():
|
||||||
name = "question_%d_answer_%d" % (question.id, answer.id)
|
name = "question_%d_answer_%d" % (question.id, answer.id)
|
||||||
|
@ -242,7 +242,6 @@ class AdminEventForm(forms.Form):
|
||||||
kwargs["initial"] = {"status":"no"}
|
kwargs["initial"] = {"status":"no"}
|
||||||
super(AdminEventForm, self).__init__(*args, **kwargs)
|
super(AdminEventForm, self).__init__(*args, **kwargs)
|
||||||
choices = {}
|
choices = {}
|
||||||
comments = {}
|
|
||||||
for choice in current_choices:
|
for choice in current_choices:
|
||||||
if choice.event_option.id not in choices:
|
if choice.event_option.id not in choices:
|
||||||
choices[choice.event_option.id] = [choice.id]
|
choices[choice.event_option.id] = [choice.id]
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.db.models.signals import post_save
|
|
||||||
|
|
||||||
def choices_length (choices):
|
def choices_length (choices):
|
||||||
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
|
return reduce (lambda m, choice: max (m, len (choice[0])), choices, 0)
|
||||||
|
|
|
@ -15,7 +15,7 @@ from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import Min
|
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.petits_cours_models import *
|
||||||
from gestioncof.decorators import buro_required
|
from gestioncof.decorators import buro_required
|
||||||
from gestioncof.shared import lock_table, unlock_tables
|
from gestioncof.shared import lock_table, unlock_tables
|
||||||
|
|
|
@ -4,7 +4,7 @@ from django_cas_ng.backends import CASBackend
|
||||||
from django_cas_ng.utils import get_cas_client
|
from django_cas_ng.utils import get_cas_client
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.models import User as DjangoUser
|
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.core.mail import send_mail
|
||||||
from django.template import Template, Context
|
from django.template import Template, Context
|
||||||
|
|
||||||
|
|
42
gestioncof/urls.py
Normal file
42
gestioncof/urls.py
Normal file
|
@ -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<type>.+)$', '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<demande_id>\d+)$', 'gestioncof.petits_cours_views.details',
|
||||||
|
name='petits-cours-demande-details'),
|
||||||
|
url(r'demandes/(?P<demande_id>\d+)/traitement$',
|
||||||
|
'gestioncof.petits_cours_views.traitement',
|
||||||
|
name='petits-cours-demande-traitement'),
|
||||||
|
url(r'demandes/(?P<demande_id>\d+)/retraitement$',
|
||||||
|
'gestioncof.petits_cours_views.retraitement',
|
||||||
|
name='petits-cours-demande-retraitement'),
|
||||||
|
]
|
||||||
|
|
||||||
|
surveys_patterns = [
|
||||||
|
url(r'^survey/(?P<survey_id>\d+)/status$', 'gestioncof.views.survey_status'),
|
||||||
|
url(r'^survey/(?P<survey_id>\d+)$', 'gestioncof.views.survey'),
|
||||||
|
]
|
||||||
|
|
||||||
|
events_patterns = [
|
||||||
|
url(r'^event/(?P<event_id>\d+)$', 'gestioncof.views.event'),
|
||||||
|
url(r'^event/(?P<event_id>\d+)/status$', 'gestioncof.views.event_status'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@ import unicodecsv
|
||||||
|
|
||||||
from django.shortcuts import redirect, get_object_or_404, render
|
from django.shortcuts import redirect, get_object_or_404, render
|
||||||
from django.http import Http404, HttpResponse
|
from django.http import Http404, HttpResponse
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
from django.contrib.auth.decorators import login_required
|
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.views import login as django_login_view
|
||||||
from django.contrib.auth.models import User
|
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.models import EventCommentField, EventCommentValue
|
||||||
from gestioncof.shared import send_custom_mail
|
from gestioncof.shared import send_custom_mail
|
||||||
from gestioncof.models import CofProfile, Clipper
|
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, \
|
from gestioncof.forms import UserProfileForm, EventStatusFilterForm, \
|
||||||
SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
|
SurveyForm, SurveyStatusFilterForm, RegistrationUserForm, \
|
||||||
RegistrationProfileForm, AdminEventForm, EventForm
|
RegistrationProfileForm, AdminEventForm, EventForm
|
||||||
|
|
||||||
from bda.models import Tirage
|
from bda.models import Tirage
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def home(request):
|
def home(request):
|
||||||
data = {"surveys": Survey.objects.filter(old=False).all(),
|
data = {"surveys": Survey.objects.filter(old=False).all(),
|
||||||
|
|
|
@ -8,7 +8,7 @@ if __name__ == "__main__":
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings")
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
settings.DEBUG = True
|
settings.DEBUG = True
|
||||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution
|
from bda.models import Spectacle, Participant, ChoixSpectacle
|
||||||
from bda.algorithm import Algorithm
|
from bda.algorithm import Algorithm
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
|
Loading…
Reference in a new issue