Merge branch 'master' of https://git.eleves.ens.fr/cof-geek/gestioCOF into Aufinal/view_spectacles

This commit is contained in:
ludo 2016-06-12 16:03:55 +02:00
commit d424089a55
18 changed files with 165 additions and 89 deletions

View file

@ -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
@ -38,6 +37,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():
@ -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)

View file

@ -1,6 +1,7 @@
# coding: utf-8
from django.conf import settings
from __future__ import division
from django.db.models import Max
import random
@ -62,7 +63,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)])

View file

@ -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):

View 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'),
),
]

View file

@ -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)

35
bda/urls.py Normal file
View 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"),
)

View file

@ -1,10 +1,10 @@
# 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.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
@ -17,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
@ -49,13 +48,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})
@ -118,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")
@ -262,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.

View file

@ -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/

View file

@ -7,62 +7,63 @@ 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"),
# 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': 'home'}),
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<type>.+)$', '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',
name='password_change_done'),
# Inscription d'un nouveau membre
url(r'^registration$', 'gestioncof.views.registration'),
url(r'^registration/clipper/(?P<login_clipper>[\w-]+)$', 'gestioncof.views.registration_form2', name = "clipper-registration"),
url(r'^registration/user/(?P<username>.+)$', '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<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'^registration/clipper/(?P<login_clipper>[\w-]+)$',
'gestioncof.views.registration_form2', name="clipper-registration"),
url(r'^registration/user/(?P<username>.+)$',
'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<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'^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'),
)

View file

@ -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):

View file

@ -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:

View file

@ -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]

View file

@ -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)

View file

@ -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

View file

@ -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

42
gestioncof/urls.py Normal file
View 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'),
]

View file

@ -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(),

View file

@ -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