From 5a5973c66836f5d6cec3d3dbf897e43f3e351b73 Mon Sep 17 00:00:00 2001 From: Alexandre Leray Date: Tue, 12 Jun 2012 23:05:35 +0200 Subject: [PATCH 1/3] Added the possibility to hide generator inlines One can do: admin.site.register(MyEvent, EventAdmin(MyEvent, show_generator=False)) --- eventtools/admin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eventtools/admin.py b/eventtools/admin.py index ec41e66b..62f06c0b 100644 --- a/eventtools/admin.py +++ b/eventtools/admin.py @@ -228,7 +228,7 @@ class Meta: model = EventModel return _EventForm -def EventAdmin(EventModel, SuperModel=MPTTModelAdmin, show_exclusions=False): +def EventAdmin(EventModel, SuperModel=MPTTModelAdmin, show_exclusions=False, show_generator=True): """ pass in the name of your EventModel subclass to use this admin. """ class _EventAdmin(SuperModel): @@ -241,8 +241,10 @@ class _EventAdmin(SuperModel): def append_eventtools_inlines(self, inline_instances): eventtools_inlines = [ OccurrenceInline(EventModel.OccurrenceModel()), - GeneratorInline(EventModel.GeneratorModel()), ] + if show_generator: + eventtools_inlines.append(GeneratorInline(EventModel.GeneratorModel())) + if show_exclusions: eventtools_inlines.append(ExclusionInline(EventModel.ExclusionModel())) From 416a30805fabfdd4a258626fd7618059b9c12d12 Mon Sep 17 00:00:00 2001 From: Alexandre Leray Date: Thu, 14 Jun 2012 23:47:46 +0200 Subject: [PATCH 2/3] Fixed wrong form_url in EventAdmin change_view() --- eventtools/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventtools/admin.py b/eventtools/admin.py index 62f06c0b..77135e83 100644 --- a/eventtools/admin.py +++ b/eventtools/admin.py @@ -364,7 +364,7 @@ def change_view(self, request, object_id, extra_context={}): 'occurrence_edit_url': self.occurrence_edit_url(event=obj), } extra_context.update(extra_extra_context) - return super(_EventAdmin, self).change_view(request, object_id, extra_context) + return super(_EventAdmin, self).change_view(request, object_id, extra_context=extra_context) return _EventAdmin try: From 2f84e74f3729a7ec1c6bc6fd3593aeb6a1b7a418 Mon Sep 17 00:00:00 2001 From: Alexandre Leray Date: Sun, 17 Jun 2012 00:07:03 +0200 Subject: [PATCH 3/3] Invalid generator rules should throw an exception --- eventtools/models/rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventtools/models/rule.py b/eventtools/models/rule.py index 0ea323a7..a5ab132d 100644 --- a/eventtools/models/rule.py +++ b/eventtools/models/rule.py @@ -110,7 +110,7 @@ def get_rrule(self, dtstart): .replace("%-nthday%", "%s%s" % (minus_n, weekday)) try: return rrule.rrulestr(str(cr), dtstart=dtstart) - except: #Except what? + except ValueError: # eg. unsupported property pass params = self.get_params() frequency = 'rrule.%s' % self.frequency