From d33479d440967651640008aaa386adb83603e235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Zapke-Gru=CC=88ndemann?= Date: Thu, 5 Jan 2012 16:16:58 +0100 Subject: Events with source "import" are read only. --- sublab_project/calendarium/admin.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sublab_project/calendarium') diff --git a/sublab_project/calendarium/admin.py b/sublab_project/calendarium/admin.py index f94a34d..b59025e 100644 --- a/sublab_project/calendarium/admin.py +++ b/sublab_project/calendarium/admin.py @@ -16,5 +16,12 @@ class EventAdmin(admin.ModelAdmin): obj.source = Event.SOURCE_ADMIN obj.save() + def get_readonly_fields(self, request, obj=None): + """Sets all fields read only if source is "import". + """ + if obj.source == obj.SOURCE_IMPORT: + return ['name', 'description', 'start', 'end'] + return [] + admin.site.register(Event, EventAdmin) -- cgit v1.2.1