diff options
Diffstat (limited to 'sublab_project')
-rw-r--r-- | sublab_project/calendarium/admin.py | 7 |
1 files changed, 7 insertions, 0 deletions
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) |