Merge branch 'Kerl/cleanup' into 'master'

Nettoyage

Simplement une suppression des `from foo import *`

See merge request !65
This commit is contained in:
Martin Pepin 2016-07-26 21:11:00 +02:00
commit 5030316842
6 changed files with 25 additions and 12 deletions

View file

@ -5,13 +5,16 @@ from __future__ import print_function
from __future__ import unicode_literals
from django.contrib import admin
from gestioncof.models import *
from gestioncof.petits_cours_models import *
from gestioncof.models import SurveyQuestionAnswer, SurveyQuestion, \
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.admin import UserAdmin
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
import django.utils.six as six
import autocomplete_light
@ -187,7 +190,8 @@ else:
class EventRegistrationAdmin(admin.ModelAdmin):
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',)
search_fields = ('user__username', 'user__first_name', 'user__last_name',
'user__email', 'event__title')

View file

@ -11,7 +11,7 @@ from django.utils.encoding import python_2_unicode_compatible
import django.utils.six as six
from django.db.models.signals import post_save
from gestioncof.petits_cours_models import *
from gestioncof.petits_cours_models import choices_length
OCCUPATION_CHOICES = (
('exterieur', _("Extérieur")),

View file

@ -53,7 +53,7 @@ class PetitCoursAbility(models.Model):
def __str__(self):
return "%s - %s - %s" % (self.user.username,
self.matiere, self.niveau)
self.matiere, self.niveau)
@python_2_unicode_compatible

View file

@ -20,7 +20,9 @@ from django.contrib.auth.decorators import login_required
from django.db.models import Min
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.shared import lock_table, unlock_tables
@ -359,7 +361,7 @@ def inscription(request):
abilities = PetitCoursAbility.objects \
.filter(user=request.user).all()
for ability in abilities:
counter = _get_attrib_counter(ability.user, ability.matiere)
_get_attrib_counter(ability.user, ability.matiere)
unlock_tables()
success = True
formset = MatieresFormSet(instance=request.user)

View file

@ -11,6 +11,7 @@ import re
register = template.Library()
@register.filter
def key(d, key_name):
try:
@ -20,19 +21,25 @@ def key(d, key_name):
value = settings.TEMPLATE_STRING_IF_INVALID
return value
def highlight_text(text, q):
q2 = "|".join(q.split())
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
def highlight_user(user, q):
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:
text = user.username
return highlight_text(text, q)
@register.filter
def highlight_clipper(clipper, q):
if clipper.fullname:
@ -40,4 +47,3 @@ def highlight_clipper(clipper, q):
else:
text = clipper.username
return highlight_text(text, q)

View file

@ -458,7 +458,8 @@ def registration(request):
(current_registration, created_reg) = \
EventRegistration.objects.get_or_create(user=member,
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.paid = \
(form.cleaned_data['status'] == 'paid')