Pourquoi c'est pas commité avant ?

This commit is contained in:
root 2013-10-01 15:27:19 +02:00
parent ef74c84095
commit 62797491cb
12 changed files with 233 additions and 38 deletions

View file

@ -17,7 +17,7 @@ class Spectacle (models.Model):
date = models.DateTimeField ("Date & heure")
location = models.ForeignKey(Salle)
description = models.TextField ("Description", blank = True)
#slots_description = models.TextField ("Description des places", blank = True)
slots_description = models.TextField ("Description des places", blank = True)
price = models.FloatField("Prix d'une place", blank = True)
slots = models.IntegerField ("Places")
priority = models.IntegerField ("Priorité", default = 1000)

View file

@ -33,7 +33,7 @@ class BaseBdaFormSet(BaseInlineFormSet):
raise forms.ValidationError("Vous ne pouvez pas vous inscrire deux fois pour le même spectacle.")
spectacles.append(spectacle)
@buro_required
@cof_required
def etat_places(request):
spectacles1 = ChoixSpectacle.objects.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'))
@ -53,7 +53,7 @@ def etat_places(request):
@cof_required
def inscription(request):
if time.time() > 1349474400:
if False and time.time() > 1349474400:
return render(request, "error.html", {"error_title": "C'est fini !", "error_description": u"Tirage au sort le 6 octobre dans la soirée "})
BdaFormSet = inlineformset_factory(Participant, ChoixSpectacle, fields = ("spectacle","double","autoquit","priority",), formset = BaseBdaFormSet)
participant, created = Participant.objects.get_or_create(user = request.user)

View file

@ -229,6 +229,23 @@ class VoterAdmin(UserProfileAdmin):
]
"""
class PetitCoursAbilityAdmin(admin.ModelAdmin):
list_display = ('user','matiere','niveau','agrege')
search_fields = ('user__username', 'user__first_name', 'user__last_name', 'user__email', 'matiere__name', 'niveau')
list_filter = ('matiere','niveau','agrege')
class PetitCoursAttributionAdmin(admin.ModelAdmin):
list_display = ('user','demande','matiere','rank',)
class PetitCoursAttributionCounterAdmin(admin.ModelAdmin):
list_display = ('user','matiere','count',)
list_filter = ('matiere',)
search_fields = ('user__username', 'user__first_name', 'user__last_name', 'user__email', 'matiere__name')
class PetitCoursDemandeAdmin(admin.ModelAdmin):
list_display = ('name','email','agrege_requis','niveau','created','traitee','processed')
list_filter = ('traitee','niveau')
admin.site.register(Survey, SurveyAdmin)
admin.site.register(SurveyQuestion, SurveyQuestionAdmin)
admin.site.register(Event, EventAdmin)
@ -237,7 +254,9 @@ admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
admin.site.register(CofProfile)
admin.site.register(PetitCoursSubject)
admin.site.register(PetitCoursAbility)
admin.site.register(PetitCoursDemande)
admin.site.register(PetitCoursAbility, PetitCoursAbilityAdmin)
admin.site.register(PetitCoursAttribution, PetitCoursAttributionAdmin)
admin.site.register(PetitCoursAttributionCounter, PetitCoursAttributionCounterAdmin)
admin.site.register(PetitCoursDemande, PetitCoursDemandeAdmin)
#admin.site.register(Voter, VoterAdmin)
admin.site.register(EventRegistration, EventRegistrationAdmin)

View file

@ -8,6 +8,7 @@ def is_cof(user):
return False
cof_required = user_passes_test(lambda u: is_cof(u))
cof_required_customdenied = user_passes_test(lambda u: is_cof(u), login_url = "cof-denied")
def is_buro(user):
try:

View file

@ -47,7 +47,8 @@ class CofProfile(models.Model):
mailing_bda_revente = models.BooleanField("Recevoir les mails de revente de places BdA", default = False)
is_buro = models.BooleanField("Membre du Burô", default = False)
petits_cours_accept = models.BooleanField("Recevoir des petits cours", default = False)
petits_cours_sent = models.IntegerField("Nombre de propositions petits cours reçues", default = 0)
petits_cours_remarques = models.TextField(_(u"Remarques et précisions pour les petits cours"),
blank = True, default = "")
class Meta:
verbose_name = "Profil COF"

View file

@ -1,14 +1,38 @@
from django.contrib.sites.models import Site
from django.conf import settings
from django_cas.backends import CASBackend
from django_cas.backends import CASBackend, _verify as CASverify
from django_cas.models import User
from django.db import models, connection
from gestioncof.models import CofProfile
class COFCASBackend(CASBackend):
def authenticate(self, ticket, service):
def authenticate_cas(self, ticket, service, request):
"""Verifies CAS ticket and gets or creates User object"""
username, attributes = CASverify(ticket, service)
if attributes:
request.session['attributes'] = attributes
if not username:
return None
profiles = CofProfile.objects.filter(login_clipper = username)
if len(profiles) > 0:
profile = profiles.order_by('-is_cof')[0]
user = profile.user
return user
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
# user will have an "unusable" password
user = User.objects.create_user(username, '')
user.save()
return user
def authenticate(self, ticket, service, request):
"""Authenticates CAS ticket and retrieves user data"""
user = super(COFCASBackend, self).authenticate(ticket, service)
user = self.authenticate_cas(ticket, service, request)
if user is None:
return user
try:
profile = user.get_profile()
except CofProfile.DoesNotExist:
@ -34,15 +58,21 @@ def context_processor (request):
}
return data
def lock_table(model):
def lock_table(*models):
query = "LOCK TABLES "
for i, model in enumerate(models):
table = model._meta.db_table
if i > 0: query += ", "
query += "%s WRITE" % table
cursor = connection.cursor()
table = model._meta.db_table
cursor.execute("LOCK TABLES %s WRITE" % table)
cursor.execute(query)
row = cursor.fetchone()
return row
def unlock_table(model):
def unlock_tables(*models):
cursor = connection.cursor()
cursor.execute("UNLOCK TABLES")
row = cursor.fetchone()
return row
unlock_table = unlock_tables

View file

@ -656,11 +656,13 @@ def export_members(request):
@buro_required
def export_mega_orgas(request):
response = HttpResponse(mimetype = 'text/csv')
response['Content-Disposition'] = 'attachment; filename=participants_mega.csv'
response['Content-Disposition'] = 'attachment; filename=orgas_mega.csv'
writer = unicodecsv.UnicodeWriter(response)
event = Event.objects.filter(title = "MEGA")
for reg in EventRegistration.objects.filter(event = event).exclude(options__id__exact = 3).all():
event = Event.objects.get(title = "MEGA")
type_option = event.options.get(name = "Type")
participant_type = type_option.choices.get(value = "Participant").id
for reg in EventRegistration.objects.filter(event = event).exclude(options__id__exact = participant_type).all():
user = reg.user
profile = user.get_profile()
bits = [user.username, user.first_name, user.last_name, user.email, profile.phone, profile.num]
@ -674,8 +676,10 @@ def export_mega_participants(request):
response['Content-Disposition'] = 'attachment; filename=participants_mega.csv'
writer = unicodecsv.UnicodeWriter(response)
event = Event.objects.filter(title = "MEGA")
for reg in EventRegistration.objects.filter(event = event).filter(options__id__exact = 3).all():
event = Event.objects.get(title = "MEGA")
type_option = event.options.get(name = "Type")
participant_type = type_option.choices.get(value = "Participant").id
for reg in EventRegistration.objects.filter(event = event).filter(options__id__exact = participant_type).all():
user = reg.user
profile = user.get_profile()
bits = [user.username, user.first_name, user.last_name, user.email, profile.phone, profile.num]

View file

@ -239,6 +239,12 @@ fieldset legend {
background-color: transparent;
}
.error {
font-weight: bold;
color: #B00000;
background-color: transparent;
}
#main form ul.errorlist li {
font-weight: bold;
color: #B00000;
@ -462,3 +468,123 @@ hr {
.tristate:hover {
cursor: pointer;
}
abbr[title] {
cursor: help;
border-bottom: 1px dotted #999999;
}
abbr.initialism {
font-size: 90%;
text-transform: uppercase;
}
blockquote {
padding: 0 0 0 15px;
margin: 0 0 20px;
border-left: 5px solid #eeeeee;
}
blockquote p {
margin-bottom: 0;
font-size: 16px;
font-weight: 300;
line-height: 25px;
}
blockquote small {
display: block;
line-height: 20px;
color: #999999;
}
blockquote small:before {
content: '\2014 \00A0';
}
blockquote.pull-right {
float: right;
padding-right: 15px;
padding-left: 0;
border-right: 5px solid #eeeeee;
border-left: 0;
}
blockquote.pull-right p,
blockquote.pull-right small {
text-align: right;
}
blockquote.pull-right small:before {
content: '';
}
blockquote.pull-right small:after {
content: '\00A0 \2014';
}
q:before,
q:after,
blockquote:before,
blockquote:after {
content: "";
}
address {
display: block;
margin-bottom: 20px;
font-style: normal;
line-height: 20px;
}
code,
pre {
padding: 0 3px 2px;
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
font-size: 12px;
color: #333333;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
code {
padding: 2px 4px;
color: #d14;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 20px;
word-break: break-all;
word-wrap: break-word;
white-space: pre;
white-space: pre-wrap;
background-color: #f5f5f5;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.15);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
pre.prettyprint {
margin-bottom: 20px;
}
pre code {
padding: 0;
color: inherit;
background-color: transparent;
border: 0;
}
.pre-scrollable {
max-height: 340px;
overflow-y: scroll;
}

View file

@ -5,7 +5,7 @@
{% if success %}
<p class="success">Votre demande a été enregistrée avec succès !</p>
{% else %}
<form id="demandecours" method="post" action="{% url "gestioncof.petit_cours_views.demande" %}">
<form id="demandecours" method="post" action="{% url "gestioncof.petits_cours_views.demande" %}">
{% csrf_token %}
<table>
{{ form.as_table }}

View file

@ -4,7 +4,7 @@
{% endblock %}
{% block realcontent %}
<h2>Bienvenue, {% if user.first_name %}{{ user.first_name }}{% else %}<tt>{{ user.username }}</tt>{% endif %}</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 %}
<h3>Événements</h3>
<ul>
@ -22,19 +22,28 @@
</ul>
{% endif %}
<h3>Divers</h3>
<h3>BdA</h3>
<ul>
<!-- <li><a href="{% url "bda2.views.inscription" %}">Inscription au tirage au sort du BdA</a></li> -->
<li><a href="{% url "bda-tirage-inscription" %}">Inscription au tirage au sort du BdA</a></li>
<li><a href="{% url "bda.views.etat_places" %}">Etat des demandes</a></li>
<!-- <li><a href="{% url "bda.views.revente" %}">Revente de places BdA (premier tirage)</a></li> -->
<!-- <li><a href="{% url "bda2.views.revente" %}">Revente de places BdA (second tirage)</a></li> -->
<li><a href="{% url "gestioncof.views.profile" %}">Éditer mon profil</a></li>
<li><a href="{% url "gestioncof.views.logout" %}">Se déconnecter</a></li>
</ul>
<h3>Divers</h3>
<ul>
{% if user.profile.is_cof or True %}<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.logout" %}">Se déconnecter</a></li>
</ul>
{% if user.get_profile.is_buro %}
<h3>Administration</h3>
<ul>
<li><a href="{% url "admin:index" %}">Administration générale</a></li>
<li><a href="{% url "petits-cours-demandes-list" %}">Demandes de petits cours</a></li>
<li><a href="{% url "gestioncof.views.registration" %}">Inscription d'un nouveau membre</a></li>
<br>
{% for event in events %}

View file

@ -33,7 +33,7 @@ var django = {
}
deleteButtonHandler = function(elem) {
elem.bind("click", function() {
var deleteInput = $(this).prev().prev(),
var deleteInput = $(this).prev(),
form = $(this).parents(".dynamic-form").first();
// callback
// toggle options.predeleteCssClass and toggle checkbox
@ -91,26 +91,31 @@ var django = {
})(django.jQuery);
</script>
<h2>Inscription au tirage au sort du BDA</h2>
<h2>Inscription pour donner des cours particuliers</h2>
{% if success %}
<p class="success">Votre inscription a été mise à jour avec succès !</p>
{% endif %}
<form id="bda_form" method="post" action="{% url 'bda-tirage-inscription' %}">
<form id="bda_form" method="post" action="{% url 'petits-cours-inscription' %}">
{% csrf_token %}
{% include "inscription-formset.html" %}
<input type="button" class="btn-addmore" value="Ajouter un autre v&oelig;u" id="add_more">
<span style="font-size: 1.25em; font-weight: bold; color: #e00000;"><input type="checkbox" name="receive_proposals" {% if receive_proposals %}checked="checked"{% endif %} /> Recevoir des propositions de petits cours</span>
<hr />
{% include "inscription-petit-cours-formset.html" %}
<input type="button" class="btn-addmore" value="Ajouter une autre matière" id="add_more" />
<script>
django.jQuery('#add_more').click(function() {
cloneMore('tbody.bda_formset_content tr:last-child', 'choixspectacle_set');
cloneMore('tbody.bda_formset_content tr:last-child', 'petitcoursability_set');
});
</script>
</script><br />
<div style="margin: 10px 0px;">
<span style="vertical-align: top; font-weight: bold;">Remarques:</span> <textarea name="remarques" style="width: 60%; height: 60px;">{{ remarques }}</textarea>
</div>
<input type="submit" class="btn-submit" value="Enregistrer" />
Prix total actuel : {{ total_price }}€
<hr />
<p class="footnotes">
<sup>1</sup>: demander deux places pour ce spectable<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 />
<sup>1</sup>: spécifiez les matières pour lesquelles vous êtes compétent<br />
<sup>2</sup>: spécifiez pour chaque matière le ou les niveaux pour lesquels vous souhaitez recevoir des demandes<br />
<sup>3</sup>: spécifiez si vous êtes titulaire de l'agrégation pour cette matière<br />
<sup>4</sup>: pour supprimer une ligne, cliquez sur la croix puis appuyer sur <tt>Enregistrer</tt><br />
</p>
</form>
{% endblock %}

View file

@ -8,7 +8,7 @@
<h3>Premier tirage</h3>
<ul>
<li><a href="{% url 'bda.views.etat_places' %}">Etat des voeux</a></li>
<li>Mailing list par spectacle</li>
<li><a href="{% url 'bda-liste-spectacles' %}">Mailing list par spectacle</a></li>
<li><a href="{% url 'bda.views.unpaid' %}">Mailing list des impayés</a></li>
</ul>
{% endblock %}