Include the Clubs into the admin site
This commit is contained in:
parent
669129e30d
commit
1f85f75896
2 changed files with 15 additions and 22 deletions
22
cof/admin.py
22
cof/admin.py
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
|
@ -13,7 +12,7 @@ from .petits_cours_models import PetitCoursDemande, \
|
|||
PetitCoursAttributionCounter
|
||||
from .models import (
|
||||
SurveyQuestionAnswer, SurveyQuestion, CofProfile, EventOption,
|
||||
EventOptionChoice, Event, Club, EventCommentField, EventRegistration,
|
||||
EventOptionChoice, Event, EventCommentField, EventRegistration,
|
||||
Survey
|
||||
)
|
||||
|
||||
|
@ -135,30 +134,11 @@ class PetitCoursDemandeAdmin(admin.ModelAdmin):
|
|||
search_fields = ('name', 'email', 'phone', 'lieu', 'remarques')
|
||||
|
||||
|
||||
class ClubAdminForm(forms.ModelForm):
|
||||
def clean(self):
|
||||
cleaned_data = super(ClubAdminForm, self).clean()
|
||||
respos = cleaned_data.get('respos')
|
||||
members = cleaned_data.get('membres')
|
||||
for respo in respos.all():
|
||||
if respo not in members:
|
||||
raise forms.ValidationError(
|
||||
"Erreur : le respo %s n'est pas membre du club."
|
||||
% respo.get_full_name())
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class ClubAdmin(admin.ModelAdmin):
|
||||
list_display = ['name']
|
||||
form = ClubAdminForm
|
||||
|
||||
|
||||
admin.site.register(Survey, SurveyAdmin)
|
||||
admin.site.register(SurveyQuestion, SurveyQuestionAdmin)
|
||||
admin.site.register(Event, EventAdmin)
|
||||
admin.site.register(EventOption, EventOptionAdmin)
|
||||
admin.site.register(CofProfile)
|
||||
admin.site.register(Club, ClubAdmin)
|
||||
admin.site.register(PetitCoursSubject)
|
||||
admin.site.register(PetitCoursAbility, PetitCoursAbilityAdmin)
|
||||
admin.site.register(PetitCoursAttribution, PetitCoursAttributionAdmin)
|
||||
|
|
|
@ -2,9 +2,13 @@ from django.contrib import admin
|
|||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from .models import Profile
|
||||
from .models import Profile, Club
|
||||
|
||||
|
||||
# ---
|
||||
# The user related stuff
|
||||
# ---
|
||||
|
||||
class ProfileInline(admin.StackedInline):
|
||||
model = Profile
|
||||
inline_classes = ["collapse open"]
|
||||
|
@ -16,5 +20,14 @@ class UserProfileAdmin(UserAdmin):
|
|||
]
|
||||
|
||||
|
||||
# ---
|
||||
# Clubs
|
||||
# ---
|
||||
|
||||
@admin.register(Club)
|
||||
class ClubAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
admin.site.unregister(User)
|
||||
admin.site.register(User, UserProfileAdmin)
|
||||
|
|
Loading…
Reference in a new issue