From 7e960881ae6cbcd709538dcd73e4fd89e33507d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Zapke-Gru=CC=88ndemann?= Date: Wed, 4 Jan 2012 23:58:44 +0100 Subject: Added model, admin, tests and tasks for calendarium. --- sublab_project/calendarium/admin.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 sublab_project/calendarium/admin.py (limited to 'sublab_project/calendarium/admin.py') diff --git a/sublab_project/calendarium/admin.py b/sublab_project/calendarium/admin.py new file mode 100644 index 0000000..f94a34d --- /dev/null +++ b/sublab_project/calendarium/admin.py @@ -0,0 +1,20 @@ +from django.contrib import admin + +from models import Event + + +class EventAdmin(admin.ModelAdmin): + list_display = ('name', 'start', 'end', 'source') + list_filter = ('source',) + search_fields = ['name', 'description'] + date_hierachy = 'start' + + def save_model(self, request, obj, form, change): + """Sets the source to "admin". + """ + if not obj.id: + obj.source = Event.SOURCE_ADMIN + obj.save() + + +admin.site.register(Event, EventAdmin) -- cgit v1.2.1