register the events stuff into the admin site
A simple admin interface which may be modified later
This commit is contained in:
parent
c217b549bd
commit
745e7a1c0c
2 changed files with 40 additions and 46 deletions
44
cof/admin.py
44
cof/admin.py
|
@ -9,9 +9,7 @@ from .petits_cours_models import PetitCoursDemande, \
|
|||
PetitCoursSubject, PetitCoursAbility, PetitCoursAttribution, \
|
||||
PetitCoursAttributionCounter
|
||||
from .models import (
|
||||
SurveyQuestionAnswer, SurveyQuestion, CofProfile, EventOption,
|
||||
EventOptionChoice, Event, EventCommentField, EventRegistration,
|
||||
Survey
|
||||
SurveyQuestionAnswer, SurveyQuestion, CofProfile, Survey
|
||||
)
|
||||
|
||||
|
||||
|
@ -62,43 +60,6 @@ class SurveyAdmin(admin.ModelAdmin):
|
|||
]
|
||||
|
||||
|
||||
class EventOptionChoiceInline(admin.TabularInline):
|
||||
model = EventOptionChoice
|
||||
|
||||
|
||||
@add_link_field(desc_text=lambda x: "Choix",
|
||||
link_text=lambda x: "Éditer les choix")
|
||||
class EventOptionInline(admin.TabularInline):
|
||||
model = EventOption
|
||||
|
||||
|
||||
class EventCommentFieldInline(admin.TabularInline):
|
||||
model = EventCommentField
|
||||
|
||||
|
||||
class EventOptionAdmin(admin.ModelAdmin):
|
||||
search_fields = ('event__title', 'name')
|
||||
inlines = [
|
||||
EventOptionChoiceInline,
|
||||
]
|
||||
|
||||
|
||||
class EventAdmin(admin.ModelAdmin):
|
||||
search_fields = ('title', 'location', 'description')
|
||||
inlines = [
|
||||
EventOptionInline,
|
||||
EventCommentFieldInline,
|
||||
]
|
||||
|
||||
|
||||
class EventRegistrationAdmin(admin.ModelAdmin):
|
||||
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')
|
||||
|
||||
|
||||
class PetitCoursAbilityAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'matiere', 'niveau', 'agrege')
|
||||
search_fields = ('user__username', 'user__first_name', 'user__last_name',
|
||||
|
@ -133,8 +94,6 @@ class PetitCoursDemandeAdmin(admin.ModelAdmin):
|
|||
|
||||
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(PetitCoursSubject)
|
||||
admin.site.register(PetitCoursAbility, PetitCoursAbilityAdmin)
|
||||
|
@ -142,4 +101,3 @@ admin.site.register(PetitCoursAttribution, PetitCoursAttributionAdmin)
|
|||
admin.site.register(PetitCoursAttributionCounter,
|
||||
PetitCoursAttributionCounterAdmin)
|
||||
admin.site.register(PetitCoursDemande, PetitCoursDemandeAdmin)
|
||||
admin.site.register(EventRegistration, EventRegistrationAdmin)
|
||||
|
|
|
@ -2,7 +2,10 @@ from django.contrib import admin
|
|||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from .models import Profile, Club
|
||||
from .models import (
|
||||
Profile, Club, Event,
|
||||
EventOption, EventCommentField, EventOptionChoice
|
||||
)
|
||||
|
||||
|
||||
# ---
|
||||
|
@ -19,6 +22,9 @@ class UserProfileAdmin(UserAdmin):
|
|||
ProfileInline,
|
||||
]
|
||||
|
||||
admin.site.unregister(User)
|
||||
admin.site.register(User, UserProfileAdmin)
|
||||
|
||||
|
||||
# ---
|
||||
# Clubs
|
||||
|
@ -29,5 +35,35 @@ class ClubAdmin(admin.ModelAdmin):
|
|||
pass
|
||||
|
||||
|
||||
admin.site.unregister(User)
|
||||
admin.site.register(User, UserProfileAdmin)
|
||||
# ---
|
||||
# Events
|
||||
# ---
|
||||
|
||||
class EventOptionChoiceInline(admin.TabularInline):
|
||||
model = EventOptionChoice
|
||||
|
||||
|
||||
class EventOptionInline(admin.TabularInline):
|
||||
model = EventOption
|
||||
show_change_link = True
|
||||
|
||||
|
||||
class EventCommentFieldInline(admin.TabularInline):
|
||||
model = EventCommentField
|
||||
|
||||
|
||||
@admin.register(EventOption)
|
||||
class EventOptionAdmin(admin.ModelAdmin):
|
||||
search_fields = ('event__title', 'name')
|
||||
inlines = [
|
||||
EventOptionChoiceInline,
|
||||
]
|
||||
|
||||
|
||||
@admin.register(Event)
|
||||
class EventAdmin(admin.ModelAdmin):
|
||||
search_fields = ['title', 'location', 'description']
|
||||
inlines = [
|
||||
EventOptionInline,
|
||||
EventCommentFieldInline,
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue