diff --git a/eventtools/admin.py b/eventtools/admin.py index ec41e66b..77135e83 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())) @@ -362,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: 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