PEP8: fixed ' = ' → '=' on parameters
'unexpected spaces around keyword / parameter equals'
This commit is contained in:
parent
7de11f2285
commit
c7a3656ded
18 changed files with 496 additions and 379 deletions
|
@ -9,16 +9,18 @@ from django.core.urlresolvers import reverse
|
|||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
def add_link_field(target_model='', field='', link_text=unicode, desc_text=unicode):
|
||||
def add_link(cls):
|
||||
reverse_name = target_model or cls.model.__name__.lower()
|
||||
|
||||
def link(self, instance):
|
||||
app_name = instance._meta.app_label
|
||||
reverse_path = "admin:%s_%s_change" % (app_name, reverse_name)
|
||||
link_obj = getattr(instance, field, None) or instance
|
||||
if not link_obj.id:
|
||||
return ""
|
||||
url = reverse(reverse_path, args = (link_obj.id,))
|
||||
url = reverse(reverse_path, args=(link_obj.id,))
|
||||
return mark_safe("<a href='%s'>%s</a>" % (url, link_text(link_obj)))
|
||||
link.allow_tags = True
|
||||
link.short_description = desc_text(reverse_name + ' link')
|
||||
|
@ -27,58 +29,69 @@ def add_link_field(target_model='', field='', link_text=unicode, desc_text=unico
|
|||
return cls
|
||||
return add_link
|
||||
|
||||
|
||||
class SurveyQuestionAnswerInline(admin.TabularInline):
|
||||
model = SurveyQuestionAnswer
|
||||
|
||||
|
||||
@add_link_field(desc_text=lambda x: "Réponses",
|
||||
link_text=lambda x: "Éditer les réponses")
|
||||
link_text=lambda x: "Éditer les réponses")
|
||||
class SurveyQuestionInline(admin.TabularInline):
|
||||
model = SurveyQuestion
|
||||
|
||||
|
||||
class SurveyQuestionAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
SurveyQuestionAnswerInline,
|
||||
]
|
||||
|
||||
|
||||
class SurveyAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
SurveyQuestionInline,
|
||||
]
|
||||
|
||||
|
||||
class EventOptionChoiceInline(admin.TabularInline):
|
||||
model = EventOptionChoice
|
||||
|
||||
|
||||
@add_link_field(desc_text=lambda x: "Choix",
|
||||
link_text=lambda x: "Éditer les choix")
|
||||
link_text=lambda x: "Éditer les choix")
|
||||
class EventOptionInline(admin.TabularInline):
|
||||
model = EventOption
|
||||
|
||||
|
||||
class EventCommentFieldInline(admin.TabularInline):
|
||||
model = EventCommentField
|
||||
|
||||
|
||||
class EventOptionAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
EventOptionChoiceInline,
|
||||
]
|
||||
|
||||
|
||||
class EventAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
EventOptionInline,
|
||||
EventCommentFieldInline,
|
||||
]
|
||||
|
||||
|
||||
class CofProfileInline(admin.StackedInline):
|
||||
model = CofProfile
|
||||
inline_classes = ("collapse open",)
|
||||
|
||||
|
||||
class FkeyLookup(object):
|
||||
def __init__(self, fkeydecl, short_description=None, admin_order_field=None):
|
||||
self.fk, fkattrs = fkeydecl.split('__', 1)
|
||||
self.fkattrs = fkattrs.split('__')
|
||||
|
||||
|
||||
self.short_description = short_description or self.fkattrs[-1]
|
||||
self.admin_order_field = admin_order_field or fkeydecl
|
||||
|
||||
|
||||
def __get__(self, obj, klass):
|
||||
if obj is None:
|
||||
return self # hack required to make Django validate (if obj is
|
||||
|
@ -89,6 +102,7 @@ class FkeyLookup(object):
|
|||
item = getattr(item, attr)
|
||||
return item
|
||||
|
||||
|
||||
def ProfileInfo(field, short_description, boolean=False):
|
||||
def getter(self):
|
||||
try:
|
||||
|
@ -108,6 +122,7 @@ User.profile_mailing_cof = ProfileInfo("mailing_cof", "ML COF", True)
|
|||
User.profile_mailing_bda = ProfileInfo("mailing_bda", "ML BDA", True)
|
||||
User.profile_mailing_bda_revente = ProfileInfo("mailing_bda_revente", "ML BDA-R", True)
|
||||
|
||||
|
||||
class UserProfileAdmin(UserAdmin):
|
||||
def is_buro(self, obj):
|
||||
try:
|
||||
|
@ -137,12 +152,15 @@ class UserProfileAdmin(UserAdmin):
|
|||
]
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
def user_unicode(self):
|
||||
if self.first_name and self.last_name:
|
||||
return u"%s %s (%s)" % (self.first_name, self.last_name, self.username)
|
||||
else:
|
||||
return self.username
|
||||
User.__unicode__ = user_unicode
|
||||
|
||||
|
||||
class EventRegistrationAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(EventRegistration, exclude=[])
|
||||
list_display = ('__unicode__','event','user','paid')
|
||||
|
@ -150,15 +168,18 @@ class EventRegistrationAdmin(admin.ModelAdmin):
|
|||
search_fields = ('user__username', 'user__first_name', 'user__last_name',
|
||||
'user__email', 'event__title')
|
||||
|
||||
|
||||
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',)
|
||||
|
@ -166,11 +187,12 @@ class PetitCoursAttributionCounterAdmin(admin.ModelAdmin):
|
|||
'user__email', 'matiere__name')
|
||||
actions = ['reset',]
|
||||
actions_on_bottom = True
|
||||
|
||||
|
||||
def reset(self, request, queryset):
|
||||
queryset.update(count=0)
|
||||
reset.short_description = u"Remise à zéro du compteur"
|
||||
|
||||
|
||||
class PetitCoursDemandeAdmin(admin.ModelAdmin):
|
||||
list_display = ('name','email','agrege_requis','niveau','created',
|
||||
'traitee','processed')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue