PEP8: Enforced other rules, including 80 cols
This commit is contained in:
parent
c7a3656ded
commit
88bccc0e60
23 changed files with 571 additions and 324 deletions
|
@ -9,8 +9,11 @@ from django.core.urlresolvers import reverse
|
|||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
def add_link_field(target_model='', field='', link_text=unicode, desc_text=unicode):
|
||||
|
||||
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()
|
||||
|
||||
|
@ -21,11 +24,13 @@ def add_link_field(target_model='', field='', link_text=unicode, desc_text=unico
|
|||
if not link_obj.id:
|
||||
return ""
|
||||
url = reverse(reverse_path, args=(link_obj.id,))
|
||||
return mark_safe("<a href='%s'>%s</a>" % (url, link_text(link_obj)))
|
||||
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')
|
||||
cls.link = link
|
||||
cls.readonly_fields = list(getattr(cls, 'readonly_fields', [])) + ['link']
|
||||
cls.readonly_fields =\
|
||||
list(getattr(cls, 'readonly_fields', [])) + ['link']
|
||||
return cls
|
||||
return add_link
|
||||
|
||||
|
@ -42,14 +47,14 @@ class SurveyQuestionInline(admin.TabularInline):
|
|||
|
||||
class SurveyQuestionAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
SurveyQuestionAnswerInline,
|
||||
]
|
||||
SurveyQuestionAnswerInline,
|
||||
]
|
||||
|
||||
|
||||
class SurveyAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
SurveyQuestionInline,
|
||||
]
|
||||
SurveyQuestionInline,
|
||||
]
|
||||
|
||||
|
||||
class EventOptionChoiceInline(admin.TabularInline):
|
||||
|
@ -68,15 +73,15 @@ class EventCommentFieldInline(admin.TabularInline):
|
|||
|
||||
class EventOptionAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
EventOptionChoiceInline,
|
||||
]
|
||||
EventOptionChoiceInline,
|
||||
]
|
||||
|
||||
|
||||
class EventAdmin(admin.ModelAdmin):
|
||||
inlines = [
|
||||
EventOptionInline,
|
||||
EventCommentFieldInline,
|
||||
]
|
||||
EventOptionInline,
|
||||
EventCommentFieldInline,
|
||||
]
|
||||
|
||||
|
||||
class CofProfileInline(admin.StackedInline):
|
||||
|
@ -85,7 +90,8 @@ class CofProfileInline(admin.StackedInline):
|
|||
|
||||
|
||||
class FkeyLookup(object):
|
||||
def __init__(self, fkeydecl, short_description=None, admin_order_field=None):
|
||||
def __init__(self, fkeydecl, short_description=None,
|
||||
admin_order_field=None):
|
||||
self.fk, fkattrs = fkeydecl.split('__', 1)
|
||||
self.fkattrs = fkattrs.split('__')
|
||||
|
||||
|
@ -94,9 +100,12 @@ class FkeyLookup(object):
|
|||
|
||||
def __get__(self, obj, klass):
|
||||
if obj is None:
|
||||
return self # hack required to make Django validate (if obj is
|
||||
# None, then we're a class, and classes are callable
|
||||
# <wink>)
|
||||
"""
|
||||
hack required to make Django validate (if obj is
|
||||
None, then we're a class, and classes are callable
|
||||
<wink>)
|
||||
"""
|
||||
return self
|
||||
item = getattr(obj, self.fk)
|
||||
for attr in self.fkattrs:
|
||||
item = getattr(item, attr)
|
||||
|
@ -113,14 +122,16 @@ def ProfileInfo(field, short_description, boolean=False):
|
|||
getter.boolean = boolean
|
||||
return getter
|
||||
|
||||
User.profile_login_clipper = FkeyLookup("profile__login_clipper", "Login clipper")
|
||||
User.profile_login_clipper = FkeyLookup("profile__login_clipper",
|
||||
"Login clipper")
|
||||
User.profile_num = FkeyLookup("profile__num", "Numéro")
|
||||
User.profile_phone = ProfileInfo("phone", "Téléphone")
|
||||
User.profile_occupation = ProfileInfo("occupation", "Occupation")
|
||||
User.profile_departement = ProfileInfo("departement", "Departement")
|
||||
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)
|
||||
User.profile_mailing_bda_revente = ProfileInfo("mailing_bda_revente",
|
||||
"ML BDA-R", True)
|
||||
|
||||
|
||||
class UserProfileAdmin(UserAdmin):
|
||||
|
@ -131,6 +142,7 @@ class UserProfileAdmin(UserAdmin):
|
|||
return False
|
||||
is_buro.short_description = 'Membre du Buro'
|
||||
is_buro.boolean = True
|
||||
|
||||
def is_cof(self, obj):
|
||||
try:
|
||||
return obj.profile.is_cof
|
||||
|
@ -139,19 +151,18 @@ class UserProfileAdmin(UserAdmin):
|
|||
is_cof.short_description = 'Membre du COF'
|
||||
is_cof.boolean = True
|
||||
list_display = ('profile_num',) + UserAdmin.list_display \
|
||||
+ ( 'profile_login_clipper','profile_phone','profile_occupation',
|
||||
'profile_mailing_cof','profile_mailing_bda',
|
||||
'profile_mailing_bda_revente','is_cof','is_buro',)
|
||||
list_display_links = ('username','email','first_name','last_name')
|
||||
+ ('profile_login_clipper', 'profile_phone', 'profile_occupation',
|
||||
'profile_mailing_cof', 'profile_mailing_bda',
|
||||
'profile_mailing_bda_revente', 'is_cof', 'is_buro', )
|
||||
list_display_links = ('username', 'email', 'first_name', 'last_name')
|
||||
list_filter = UserAdmin.list_filter \
|
||||
+ ( 'profile__is_cof', 'profile__is_buro', 'profile__mailing_cof',
|
||||
'profile__mailing_bda')
|
||||
+ ('profile__is_cof', 'profile__is_buro', 'profile__mailing_cof',
|
||||
'profile__mailing_bda')
|
||||
search_fields = UserAdmin.search_fields + ('profile__phone',)
|
||||
inlines = [
|
||||
CofProfileInline,
|
||||
]
|
||||
CofProfileInline,
|
||||
]
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
def user_unicode(self):
|
||||
if self.first_name and self.last_name:
|
||||
|
@ -163,29 +174,29 @@ User.__unicode__ = user_unicode
|
|||
|
||||
class EventRegistrationAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(EventRegistration, exclude=[])
|
||||
list_display = ('__unicode__','event','user','paid')
|
||||
list_display = ('__unicode__', 'event', 'user', 'paid')
|
||||
list_filter = ('paid',)
|
||||
search_fields = ('user__username', 'user__first_name', 'user__last_name',
|
||||
'user__email', 'event__title')
|
||||
|
||||
|
||||
class PetitCoursAbilityAdmin(admin.ModelAdmin):
|
||||
list_display = ('user','matiere','niveau','agrege')
|
||||
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')
|
||||
list_filter = ('matiere', 'niveau', 'agrege')
|
||||
|
||||
|
||||
class PetitCoursAttributionAdmin(admin.ModelAdmin):
|
||||
list_display = ('user','demande','matiere','rank',)
|
||||
list_display = ('user', 'demande', 'matiere', 'rank', )
|
||||
|
||||
|
||||
class PetitCoursAttributionCounterAdmin(admin.ModelAdmin):
|
||||
list_display = ('user','matiere','count',)
|
||||
list_display = ('user', 'matiere', 'count', )
|
||||
list_filter = ('matiere',)
|
||||
search_fields = ('user__username', 'user__first_name', 'user__last_name',
|
||||
'user__email', 'matiere__name')
|
||||
actions = ['reset',]
|
||||
actions = ['reset', ]
|
||||
actions_on_bottom = True
|
||||
|
||||
def reset(self, request, queryset):
|
||||
|
@ -194,9 +205,9 @@ class PetitCoursAttributionCounterAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
class PetitCoursDemandeAdmin(admin.ModelAdmin):
|
||||
list_display = ('name','email','agrege_requis','niveau','created',
|
||||
'traitee','processed')
|
||||
list_filter = ('traitee','niveau')
|
||||
list_display = ('name', 'email', 'agrege_requis', 'niveau', 'created',
|
||||
'traitee', 'processed')
|
||||
list_filter = ('traitee', 'niveau')
|
||||
|
||||
admin.site.register(Survey, SurveyAdmin)
|
||||
admin.site.register(SurveyQuestion, SurveyQuestionAdmin)
|
||||
|
@ -210,6 +221,7 @@ admin.site.register(CustomMail)
|
|||
admin.site.register(PetitCoursSubject)
|
||||
admin.site.register(PetitCoursAbility, PetitCoursAbilityAdmin)
|
||||
admin.site.register(PetitCoursAttribution, PetitCoursAttributionAdmin)
|
||||
admin.site.register(PetitCoursAttributionCounter, PetitCoursAttributionCounterAdmin)
|
||||
admin.site.register(PetitCoursAttributionCounter,
|
||||
PetitCoursAttributionCounterAdmin)
|
||||
admin.site.register(PetitCoursDemande, PetitCoursDemandeAdmin)
|
||||
admin.site.register(EventRegistration, EventRegistrationAdmin)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue