Skip to content

Commit

Permalink
Merge pull request #2 from aleray/api-tidy
Browse files Browse the repository at this point in the history
Thanks, aleray:

I fixed a bug which was preventing existing pages from being changed (among other things). The other thing I've done is adding an show_generator kwarg in Event Admin in case one doesn't want to show generator inlines.
  • Loading branch information
cogat committed Jun 17, 2012
2 parents 9e2162f + 2f84e74 commit a0f68c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions eventtools/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()))

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion eventtools/models/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a0f68c2

Please sign in to comment.