forked from DGNum/gestioCOF
Merge branch 'master' of https://git.eleves.ens.fr/cof-geek/gestioCOF into Aufinal/bda_revente
This commit is contained in:
commit
af524a3081
8 changed files with 42 additions and 17 deletions
|
@ -5,13 +5,16 @@ from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from gestioncof.models import *
|
from gestioncof.models import SurveyQuestionAnswer, SurveyQuestion, \
|
||||||
from gestioncof.petits_cours_models import *
|
CofProfile, EventOption, EventOptionChoice, Event, Club, CustomMail, \
|
||||||
|
Survey, EventCommentField, EventRegistration
|
||||||
|
from gestioncof.petits_cours_models import PetitCoursDemande, \
|
||||||
|
PetitCoursSubject, PetitCoursAbility, PetitCoursAttribution, \
|
||||||
|
PetitCoursAttributionCounter
|
||||||
from django.contrib.auth.models import User
|
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
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
import django.utils.six as six
|
import django.utils.six as six
|
||||||
|
|
||||||
import autocomplete_light
|
import autocomplete_light
|
||||||
|
@ -187,7 +190,8 @@ else:
|
||||||
|
|
||||||
class EventRegistrationAdmin(admin.ModelAdmin):
|
class EventRegistrationAdmin(admin.ModelAdmin):
|
||||||
form = autocomplete_light.modelform_factory(EventRegistration, exclude=[])
|
form = autocomplete_light.modelform_factory(EventRegistration, exclude=[])
|
||||||
list_display = ('__unicode__' if six.PY2 else '__str__', 'event', 'user', 'paid')
|
list_display = ('__unicode__' if six.PY2 else '__str__', 'event', 'user',
|
||||||
|
'paid')
|
||||||
list_filter = ('paid',)
|
list_filter = ('paid',)
|
||||||
search_fields = ('user__username', 'user__first_name', 'user__last_name',
|
search_fields = ('user__username', 'user__first_name', 'user__last_name',
|
||||||
'user__email', 'event__title')
|
'user__email', 'event__title')
|
||||||
|
|
|
@ -11,7 +11,7 @@ from django.utils.encoding import python_2_unicode_compatible
|
||||||
import django.utils.six as six
|
import django.utils.six as six
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
|
|
||||||
from gestioncof.petits_cours_models import *
|
from gestioncof.petits_cours_models import choices_length
|
||||||
|
|
||||||
OCCUPATION_CHOICES = (
|
OCCUPATION_CHOICES = (
|
||||||
('exterieur', _("Extérieur")),
|
('exterieur', _("Extérieur")),
|
||||||
|
|
|
@ -53,7 +53,7 @@ class PetitCoursAbility(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s - %s - %s" % (self.user.username,
|
return "%s - %s - %s" % (self.user.username,
|
||||||
self.matiere, self.niveau)
|
self.matiere, self.niveau)
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
|
|
|
@ -20,7 +20,9 @@ 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
|
from gestioncof.models import CofProfile
|
||||||
from gestioncof.petits_cours_models import *
|
from gestioncof.petits_cours_models import PetitCoursDemande, \
|
||||||
|
PetitCoursAttribution, PetitCoursAttributionCounter, PetitCoursAbility, \
|
||||||
|
PetitCoursSubject
|
||||||
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
|
||||||
|
|
||||||
|
@ -359,7 +361,7 @@ def inscription(request):
|
||||||
abilities = PetitCoursAbility.objects \
|
abilities = PetitCoursAbility.objects \
|
||||||
.filter(user=request.user).all()
|
.filter(user=request.user).all()
|
||||||
for ability in abilities:
|
for ability in abilities:
|
||||||
counter = _get_attrib_counter(ability.user, ability.matiere)
|
_get_attrib_counter(ability.user, ability.matiere)
|
||||||
unlock_tables()
|
unlock_tables()
|
||||||
success = True
|
success = True
|
||||||
formset = MatieresFormSet(instance=request.user)
|
formset = MatieresFormSet(instance=request.user)
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
<p class="error">Identifiants incorrects.</p>
|
<p class="error">Identifiants incorrects.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form method="post" action="{% url 'gestioncof.views.login_ext' %}">
|
<form method="post"
|
||||||
|
action="{% url 'gestioncof.views.login_ext' %}?next={{ next|urlencode }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="main-login-container">
|
<div id="main-login-container">
|
||||||
<div id="main-login">
|
<div id="main-login">
|
||||||
<a id="login_clipper" href="{% url 'django_cas_ng.views.login' %}">
|
<a id="login_clipper"
|
||||||
|
href="{% url 'django_cas_ng.views.login' %}?next={{ next|urlencode }}">
|
||||||
Compte clipper
|
Compte clipper
|
||||||
</a>
|
</a>
|
||||||
<a id="login_outsider" href="{% url 'gestioncof.views.login_ext' %}">
|
<a id="login_outsider"
|
||||||
|
href="{% url 'gestioncof.views.login_ext' %}?next={{ next|urlencode }}">
|
||||||
Extérieur
|
Extérieur
|
||||||
</a>
|
</a>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
|
|
|
@ -11,6 +11,7 @@ import re
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def key(d, key_name):
|
def key(d, key_name):
|
||||||
try:
|
try:
|
||||||
|
@ -20,19 +21,25 @@ def key(d, key_name):
|
||||||
value = settings.TEMPLATE_STRING_IF_INVALID
|
value = settings.TEMPLATE_STRING_IF_INVALID
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def highlight_text(text, q):
|
def highlight_text(text, q):
|
||||||
q2 = "|".join(q.split())
|
q2 = "|".join(q.split())
|
||||||
pattern = re.compile(r"(?P<filter>%s)" % q2, re.IGNORECASE)
|
pattern = re.compile(r"(?P<filter>%s)" % q2, re.IGNORECASE)
|
||||||
return mark_safe(re.sub(pattern, r"<span class='highlight'>\g<filter></span>", text))
|
return mark_safe(re.sub(pattern,
|
||||||
|
r"<span class='highlight'>\g<filter></span>",
|
||||||
|
text))
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def highlight_user(user, q):
|
def highlight_user(user, q):
|
||||||
if user.first_name and user.last_name:
|
if user.first_name and user.last_name:
|
||||||
text = "%s %s (<tt>%s</tt>)" % (user.first_name, user.last_name, user.username)
|
text = "%s %s (<tt>%s</tt>)" % (user.first_name, user.last_name,
|
||||||
|
user.username)
|
||||||
else:
|
else:
|
||||||
text = user.username
|
text = user.username
|
||||||
return highlight_text(text, q)
|
return highlight_text(text, q)
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def highlight_clipper(clipper, q):
|
def highlight_clipper(clipper, q):
|
||||||
if clipper.fullname:
|
if clipper.fullname:
|
||||||
|
@ -40,4 +47,3 @@ def highlight_clipper(clipper, q):
|
||||||
else:
|
else:
|
||||||
text = clipper.username
|
text = clipper.username
|
||||||
return highlight_text(text, q)
|
return highlight_text(text, q)
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,10 @@ def home(request):
|
||||||
def login(request):
|
def login(request):
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
return redirect("gestioncof.views.home")
|
return redirect("gestioncof.views.home")
|
||||||
return render(request, "login_switch.html", {})
|
context = {}
|
||||||
|
if request.method == "GET" and 'next' in request.GET:
|
||||||
|
context['next'] = request.GET['next']
|
||||||
|
return render(request, "login_switch.html", context)
|
||||||
|
|
||||||
|
|
||||||
def login_ext(request):
|
def login_ext(request):
|
||||||
|
@ -60,7 +63,13 @@ def login_ext(request):
|
||||||
{"error_type": "no_password"})
|
{"error_type": "no_password"})
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
return django_login_view(request, template_name='login.html')
|
context = {}
|
||||||
|
if request.method == "GET" and 'next' in request.GET:
|
||||||
|
context['next'] = request.GET['next']
|
||||||
|
if request.method == "POST" and 'next' in request.POST:
|
||||||
|
context['next'] = request.POST['next']
|
||||||
|
return django_login_view(request, template_name='login.html',
|
||||||
|
extra_context=context)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -458,7 +467,8 @@ def registration(request):
|
||||||
(current_registration, created_reg) = \
|
(current_registration, created_reg) = \
|
||||||
EventRegistration.objects.get_or_create(user=member,
|
EventRegistration.objects.get_or_create(user=member,
|
||||||
event=form.event)
|
event=form.event)
|
||||||
update_event_form_comments(form.event, form, current_registration)
|
update_event_form_comments(form.event, form,
|
||||||
|
current_registration)
|
||||||
current_registration.options = all_choices
|
current_registration.options = all_choices
|
||||||
current_registration.paid = \
|
current_registration.paid = \
|
||||||
(form.cleaned_data['status'] == 'paid')
|
(form.cleaned_data['status'] == 'paid')
|
||||||
|
|
Loading…
Reference in a new issue