Création d'un fichier de requirement

This commit is contained in:
root 2015-09-13 18:23:47 +02:00
parent 182ba7f614
commit f704c9f593
10 changed files with 65 additions and 37 deletions

11
Requirements.txt Normal file
View file

@ -0,0 +1,11 @@
Django==1.6
MySQL-python==1.2.5
Pillow==2.9.0
argparse==1.2.1
captcha==0.1.1
django-autocomplete-light==2.2.4
django-autoslug==1.8.0
django-grappelli==2.6.5
eav-django==1.4.7
six==1.9.0
wsgiref==0.1.2

View file

@ -140,8 +140,8 @@ class AttributionAdmin(admin.ModelAdmin):
import autocomplete_light import autocomplete_light
class ChoixSpectacleAdmin(admin.ModelAdmin): class ChoixSpectacleAdmin(admin.ModelAdmin):
form = autocomplete_light.modelform_factory(ChoixSpectacle) form = autocomplete_light.modelform_factory(ChoixSpectacle)
list_display = ("participant", "spectacle", "priority", "double", "autoquit") list_display = ("participant", "spectacle", "priority", "double_choice")
list_filter = ("double", "autoquit") list_filter = ("double_choice",)
search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name') search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
class SpectacleAdmin(admin.ModelAdmin): class SpectacleAdmin(admin.ModelAdmin):

View file

@ -57,12 +57,26 @@ class Participant (models.Model):
def __unicode__ (self): def __unicode__ (self):
return u"%s" % (self.user) return u"%s" % (self.user)
DOUBLE_CHOICES = (
("1", "1 place"),
("autoquit", "2 places si possible, 1 sinon"),
("double", "2 places sinon rien"),
)
class ChoixSpectacle (models.Model): class ChoixSpectacle (models.Model):
participant = models.ForeignKey(Participant) participant = models.ForeignKey(Participant)
spectacle = models.ForeignKey(Spectacle, related_name = "participants") spectacle = models.ForeignKey(Spectacle, related_name = "participants")
priority = models.PositiveIntegerField("Priorité") priority = models.PositiveIntegerField("Priorité")
double = models.BooleanField("Deux places<sup>1</sup>",default=False) double_choice = models.CharField("Nombre de places", default = "1", choices = DOUBLE_CHOICES, max_length = 10)
autoquit = models.BooleanField("Abandon<sup>2</sup>",default=False)
def get_double(self):
return self.double_choice != "1"
double = property(get_double)
def get_autoquit(self):
return self.double_choice == "autoquit"
autoquit = property(get_autoquit)
class Meta: class Meta:
ordering = ("priority",) ordering = ("priority",)
unique_together = (("participant", "spectacle",),) unique_together = (("participant", "spectacle",),)

View file

@ -40,8 +40,8 @@ class BaseBdaFormSet(BaseInlineFormSet):
@cof_required @cof_required
def etat_places(request): def etat_places(request):
spectacles1 = ChoixSpectacle.objects.all().values('spectacle','spectacle__title').annotate(total = models.Count('spectacle')) spectacles1 = ChoixSpectacle.objects.filter(double_choice = "1").all().values('spectacle','spectacle__title').annotate(total = models.Count('spectacle'))
spectacles2 = ChoixSpectacle.objects.filter(double = True).all().values('spectacle','spectacle__title').annotate(total = models.Count('spectacle')) spectacles2 = ChoixSpectacle.objects.exclude(double_choice = "1").all().values('spectacle','spectacle__title').annotate(total = models.Count('spectacle'))
spectacles = Spectacle.objects.all() spectacles = Spectacle.objects.all()
spectacles_dict = {} spectacles_dict = {}
total = 0 total = 0
@ -96,11 +96,11 @@ def places(request):
@cof_required @cof_required
def inscription(request): def inscription(request):
if datetime.now() > datetime(2014, 10, 5, 12, 00): if datetime.now() > datetime(2014, 10, 5, 12, 00) and request.user.username != "seguin":
participant, created = Participant.objects.get_or_create(user = request.user) participant, created = Participant.objects.get_or_create(user = request.user)
choices = participant.choixspectacle_set.order_by("priority").all() choices = participant.choixspectacle_set.order_by("priority").all()
return render(request, "resume_inscription.html", {"error_title": "C'est fini !", "error_description": u"Tirage au sort dans la journée !", "choices": choices}) return render(request, "resume_inscription.html", {"error_title": "C'est fini !", "error_description": u"Tirage au sort dans la journée !", "choices": choices})
BdaFormSet = inlineformset_factory(Participant, ChoixSpectacle, fields = ("spectacle","double","autoquit","priority",), formset = BaseBdaFormSet) BdaFormSet = inlineformset_factory(Participant, ChoixSpectacle, fields = ("spectacle","double_choice","priority",), formset = BaseBdaFormSet)
participant, created = Participant.objects.get_or_create(user = request.user) participant, created = Participant.objects.get_or_create(user = request.user)
success = False success = False
stateerror = False stateerror = False

View file

@ -343,13 +343,15 @@ def event_status(request, event_id):
user_choices = registrations_query.prefetch_related("user").all() user_choices = registrations_query.prefetch_related("user").all()
options = EventOption.objects.filter(event = event).all() options = EventOption.objects.filter(event = event).all()
choices_count = {} choices_count = {}
total = 0
for option in options: for option in options:
for choice in option.choices.all(): for choice in option.choices.all():
choices_count[choice.id] = 0 choices_count[choice.id] = 0
for user_choice in user_choices: for user_choice in user_choices:
for choice in user_choice.options.all(): for choice in user_choice.options.all():
choices_count[choice.id] += 1 choices_count[choice.id] += 1
return render(request, "event_status.html", {"event": event, "user_choices": user_choices, "options": options, "choices_count": choices_count, "form": form}) total += 1
return render(request, "event_status.html", {"event": event, "user_choices": user_choices, "options": options, "choices_count": choices_count, "form": form, "total": total})
@buro_required @buro_required
def survey_status(request, survey_id): def survey_status(request, survey_id):
@ -680,7 +682,7 @@ def registration(request):
current_registration.options = all_choices current_registration.options = all_choices
current_registration.paid = (form.cleaned_data['status'] == 'paid') current_registration.paid = (form.cleaned_data['status'] == 'paid')
current_registration.save() current_registration.save()
if event.title == "Mega 2014" and created_reg: if event.title == "Mega 15" and created_reg:
field = EventCommentField.objects.get(event = event, name = "Commentaires") field = EventCommentField.objects.get(event = event, name = "Commentaires")
try: try:
comments = EventCommentValue.objects.get(commentfield = field, registration = current_registration).content comments = EventCommentValue.objects.get(commentfield = field, registration = current_registration).content
@ -721,12 +723,12 @@ def csv_export_mega(filename, qs):
@buro_required @buro_required
def export_mega_remarksonly(request): def export_mega_remarksonly(request):
filename = 'remarques_mega_2014.csv' filename = 'remarques_mega_2015.csv'
response = HttpResponse(mimetype = 'text/csv') response = HttpResponse(mimetype = 'text/csv')
response['Content-Disposition'] = 'attachment; filename=' + filename response['Content-Disposition'] = 'attachment; filename=' + filename
writer = unicodecsv.UnicodeWriter(response) writer = unicodecsv.UnicodeWriter(response)
event = Event.objects.get(title = "Mega 2014") event = Event.objects.get(title = "Mega 15")
commentfield = event.commentfields.get(name = "Commentaires") commentfield = event.commentfields.get(name = "Commentaires")
for val in commentfield.values.all(): for val in commentfield.values.all():
reg = val.registration reg = val.registration
@ -739,42 +741,42 @@ def export_mega_remarksonly(request):
@buro_required @buro_required
def export_mega_bytype(request, type): def export_mega_bytype(request, type):
types = {"orga-actif": "Orga actif", types = {"orga-actif": "Orga élève",
"orga-branleur": "Orga branleur", "orga-branleur": "Orga étudiant",
"conscrit-eleve": "Conscrit élève", "conscrit-eleve": "Conscrit élève",
"conscrit-etudiant": "Conscrit étudiant"} "conscrit-etudiant": "Conscrit étudiant"}
if type not in types: if type not in types:
raise Http404 raise Http404
event = Event.objects.get(title = "Mega 2014") event = Event.objects.get(title = "Mega 15")
type_option = event.options.get(name = "Type") type_option = event.options.get(name = "Type")
participant_type = type_option.choices.get(value = types[type]).id participant_type = type_option.choices.get(value = types[type]).id
qs = EventRegistration.objects.filter(event = event).filter(options__id__exact = participant_type) qs = EventRegistration.objects.filter(event = event).filter(options__id__exact = participant_type)
return csv_export_mega(type + '_mega_2014.csv', qs) return csv_export_mega(type + '_mega_2015.csv', qs)
@buro_required @buro_required
def export_mega_orgas(request): def export_mega_orgas(request):
event = Event.objects.get(title = "Mega 2014") event = Event.objects.get(title = "Mega 15")
type_option = event.options.get(name = "Type") type_option = event.options.get(name = "Type")
participant_type_a = type_option.choices.get(value = "Conscrit étudiant").id participant_type_a = type_option.choices.get(value = "Conscrit étudiant").id
participant_type_b = type_option.choices.get(value = "Conscrit élève").id participant_type_b = type_option.choices.get(value = "Conscrit élève").id
qs = EventRegistration.objects.filter(event = event).exclude(options__id__in = (participant_type_a, participant_type_b)) qs = EventRegistration.objects.filter(event = event).exclude(options__id__in = (participant_type_a, participant_type_b))
return csv_export_mega('orgas_mega_2014.csv', qs) return csv_export_mega('orgas_mega_15.csv', qs)
def export_mega_participants(request): def export_mega_participants(request):
event = Event.objects.get(title = "Mega 2014") event = Event.objects.get(title = "Mega 15")
type_option = event.options.get(name = "Type") type_option = event.options.get(name = "Type")
participant_type_a = type_option.choices.get(value = "Conscrit étudiant").id participant_type_a = type_option.choices.get(value = "Conscrit étudiant").id
participant_type_b = type_option.choices.get(value = "Conscrit élève").id participant_type_b = type_option.choices.get(value = "Conscrit élève").id
qs = EventRegistration.objects.filter(event = event).filter(options__id__in = (participant_type_a, participant_type_b)) qs = EventRegistration.objects.filter(event = event).filter(options__id__in = (participant_type_a, participant_type_b))
return csv_export_mega('participants_mega_2014.csv', qs) return csv_export_mega('participants_mega_15.csv', qs)
@buro_required @buro_required
def export_mega(request): def export_mega(request):
event = Event.objects.filter(title = "Mega 2014") event = Event.objects.filter(title = "Mega 15")
qs = EventRegistration.objects.filter(event = event).order_by("user__username") qs = EventRegistration.objects.filter(event = event).order_by("user__username")
return csv_export_mega('all_mega_2014.csv', qs) return csv_export_mega('all_mega_2015.csv', qs)
@buro_required @buro_required
def utile_cof(request): def utile_cof(request):

View file

@ -30,11 +30,12 @@ table#bda_formset {
width: 100%; width: 100%;
} }
.bda-field-spectacle { .bda-field-spectacle select {
width: 65%; width: 96%;
margin: 0 2%;
} }
.bda-field-spectacle select { .bda-field-double_choice select {
width: 94%; width: 94%;
margin: 0 3%; margin: 0 3%;
} }
@ -631,4 +632,4 @@ th[data-sort]{
tr.awesome{ tr.awesome{
color: red; color: red;
} }

View file

@ -112,9 +112,7 @@ var django = {
Prix total actuel : {{ total_price }}€ Prix total actuel : {{ total_price }}€
<hr /> <hr />
<p class="footnotes"> <p class="footnotes">
<sup>1</sup>: demander deux places pour ce spectable<br /> <sup>1</sup>: cette liste de v&oelig;u est ordonnée (du plus important au moins important), pour ajuster la priorité vous pouvez déplacer chaque v&oelig;u<br />
<sup>2</sup>: abandonner une place si impossible d'en obtenir une seconde pour ce spectacle (si vous avez coché l'option <tt>Deux places</tt> pour ce spectacle)<br />
<sup>3</sup>: cette liste de v&oelig;u est ordonnée (du plus important au moins important), pour ajuster la priorité vous pouvez déplacer chaque v&oelig;u<br />
</p> </p>
</form> </form>
{% endblock %} {% endblock %}

View file

@ -9,7 +9,7 @@
<th class="bda-field-{{ field.name }}">{{ field.label|safe|capfirst }}</th> <th class="bda-field-{{ field.name }}">{{ field.label|safe|capfirst }}</th>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<th><sup>3</sup></th> <th><sup>1</sup></th>
</tr></thead> </tr></thead>
<tbody class="bda_formset_content"> <tbody class="bda_formset_content">
{% endif %} {% endif %}

View file

@ -20,6 +20,7 @@
{% for choice in option.choices.all %} {% for choice in option.choices.all %}
<li>{{ choice.value }} : {{ choices_count|key:choice.id }}</li> <li>{{ choice.value }} : {{ choices_count|key:choice.id }}</li>
{% endfor %} {% endfor %}
<li>Total : {{ total }}</li>
</ul> </ul>
{% endfor %} {% endfor %}
<h3>Réponses individuelles</h3> <h3>Réponses individuelles</h3>

View file

@ -5,14 +5,14 @@
{% block realcontent %} {% block realcontent %}
<h2>Bienvenue, {% if user.first_name %}{{ user.first_name }}{% else %}<tt>{{ user.username }}</tt>{% endif %} <span style="float: right;"><tt>{% if user.profile.is_cof %}Membre du COF{% else %}Non-membre du COF{% endif %}</tt></span></h2> <h2>Bienvenue, {% if user.first_name %}{{ user.first_name }}{% else %}<tt>{{ user.username }}</tt>{% endif %} <span style="float: right;"><tt>{% if user.profile.is_cof %}Membre du COF{% else %}Non-membre du COF{% endif %}</tt></span></h2>
{% if open_events %} <!-- {% if open_events %}
<h3>Événements</h3> <h3>Événements</h3>
<ul> <ul>
{% for event in open_events %} {% for event in open_events %}
<li><a href="{% url "gestioncof.views.event" event.id %}">{{ event.title }}</a></li> <li><a href="{% url "gestioncof.views.event" event.id %}">{{ event.title }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %} --!>
{% if open_surveys %} {% if open_surveys %}
<h3>Sondages en cours</h3> <h3>Sondages en cours</h3>
<ul> <ul>
@ -24,7 +24,7 @@
{% if user.profile.is_cof %} {% if user.profile.is_cof %}
<h3>BdA</h3> <!-- <h3>BdA</h3>
<ul> <ul>
<li><a href="{% url "bda-tirage-inscription" %}">Inscription au premier tirage au sort du BdA</a></li> <li><a href="{% url "bda-tirage-inscription" %}">Inscription au premier tirage au sort du BdA</a></li>
<li><a href="{% url "bda-etat-places" %}">État des demandes</a> <li><a href="{% url "bda-etat-places" %}">État des demandes</a>
@ -38,23 +38,24 @@
<li><a href="{% url "bda2-revente" %}">Revendre une place du deuxième tirage</a></li> <li><a href="{% url "bda2-revente" %}">Revendre une place du deuxième tirage</a></li>
<br> <br>
<!--
Troisième tirage Troisième tirage
<li><a href="{% url "bda3-tirage-inscription" %}">Inscription au troisième tirage au sort du BdA</a></li> <li><a href="{% url "bda3-tirage-inscription" %}">Inscription au troisième tirage au sort du BdA</a></li>
<li><a href="{% url "bda3-etat-places" %}">État des demandes</a></li> <li><a href="{% url "bda3-etat-places" %}">État des demandes</a></li>
<li><a href="{% url "bda3-places-attribuees" %}">Mes places du troisième tirage</a></li> <li><a href="{% url "bda3-places-attribuees" %}">Mes places du troisième tirage</a></li>
<li><a href="{% url "bda3-revente" %}">Revendre une place du troisième tirage</a></li> <li><a href="{% url "bda3-revente" %}">Revendre une place du troisième tirage</a></li>
<br> <br>
-->
</ul> </ul> --!>
{% endif %} {% endif %}
<h3>Divers</h3> <h3>Divers</h3>
<ul> <ul>
{% if user.profile.is_cof or True %}<li><a href="{% url "petits-cours-inscription" %}">Inscription pour donner des petits cours</a></li>{% endif %} {% if user.profile.is_cof %}<li><a href="{% url "petits-cours-inscription" %}">Inscription pour donner des petits cours</a></li>{% endif %}
<li><a href="{% url "gestioncof.views.profile" %}">Éditer mon profil</a></li> <li><a href="{% url "gestioncof.views.profile" %}">Éditer mon profil</a></li>
{% if not user.profile.login_clipper %}<li><a href="{% url "django.contrib.auth.views.password_change" %}">Changer mon mot de passe</a></li>{% endif %}
<li><a href="{% url "gestioncof.views.logout" %}">Se déconnecter</a></li> <li><a href="{% url "gestioncof.views.logout" %}">Se déconnecter</a></li>
</ul> </ul>