Skip to content
This repository

Bugs/issue11 #12

Merged
merged 6 commits into from almost 3 years ago

2 participants

anthony menasse GLAMKit
anthony menasse

this is the fix for #11, it also includes the previous fixes for #5,#6,#7

amenasse added some commits
anthony menasse amenasse peg version of python-dateutils. Fixes #5
workaround for issue where vobjects setup.py is installing an incompatible
version of python-dateutils
a596526
anthony menasse amenasse accept additional args and keyword args to save method. Fixes #6 83b5909
anthony menasse amenasse change default ordering for EventVariationBase. Fixes #7
EventVariationBase no longer orders on a field which may not exist on
the concrete model (title).
baaeb34
anthony menasse amenasse peg python-dateutil version in setup file. Fixes #5
versions of python-dateutil >=2.0 are incompatible with python2.x
6ba0e5b
anthony menasse amenasse Merge branch 'bugs/issue7' into bugs/issue11 a370d5a
anthony menasse amenasse variations_count() no longer crashes if 'varied_by' is not defined. F…
…ixes #11
4596ac1
GLAMKit glamkit merged commit 545f11a into from
GLAMKit glamkit closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 6 unique commits by 1 author.

Jul 01, 2011
anthony menasse amenasse peg version of python-dateutils. Fixes #5
workaround for issue where vobjects setup.py is installing an incompatible
version of python-dateutils
a596526
anthony menasse amenasse accept additional args and keyword args to save method. Fixes #6 83b5909
anthony menasse amenasse change default ordering for EventVariationBase. Fixes #7
EventVariationBase no longer orders on a field which may not exist on
the concrete model (title).
baaeb34
Jul 04, 2011
anthony menasse amenasse peg python-dateutil version in setup file. Fixes #5
versions of python-dateutil >=2.0 are incompatible with python2.x
6ba0e5b
Jul 12, 2011
anthony menasse amenasse Merge branch 'bugs/issue7' into bugs/issue11 a370d5a
anthony menasse amenasse variations_count() no longer crashes if 'varied_by' is not defined. F…
…ixes #11
4596ac1
This page is out of date. Refresh to see the latest.
2  eventtools/models/events.py
@@ -291,7 +291,7 @@ def variations_count(self):
291 291 """
292 292 returns the number of variations that this event has
293 293 """
294   - if self.__class__.varied_by:
  294 + if getattr(self.__class__,'varied_by',None):
295 295 try:
296 296 return self.variations.count()
297 297 except: # if none have been created, there is no such thing as self.variations, so return 0
2  eventtools/models/eventvariations.py
@@ -64,4 +64,4 @@ def __unicode__(self):
64 64
65 65 class Meta:
66 66 abstract = True
67   - ordering = ['unvaried_event__title', 'reason']
  67 + ordering = ['unvaried_event', 'reason']
4 eventtools/models/occurrencegenerators.py
@@ -382,7 +382,7 @@ def occurrences_after(self, after=None):
382 382 next = generator.next()
383 383 yield occ_replacer.get_occurrence(next)
384 384
385   - def save(self):
  385 + def save(self,*args,**kwargs):
386 386 # if the occurrence generator changes, we must not break the link with persisted occurrences
387 387 if self.id: # must already exist
388 388 saved_self = self.__class__.objects.get(pk=self.id)
@@ -411,5 +411,5 @@ def save(self):
411 411 occ.unvaried_end_time = unvaried_end.time()
412 412
413 413 occ.save()
414   - super(OccurrenceGeneratorBase, self).save()
  414 + super(OccurrenceGeneratorBase, self).save(*args,**kwargs)
415 415
21 eventtools/tests/test_models.py
@@ -514,3 +514,24 @@ def _test_combo(result, first_start_date, repeat_until=None, rule=weekly):
514 514 rule=None,
515 515 result=0
516 516 )
  517 +
  518 +
  519 + def test_clean_with_variation(self):
  520 + """ a model with variations defined can be cleaned """
  521 +
  522 + evt = BroadcastEvent.objects.create(presenter = "Jimmy McBigmouth", studio=2)
  523 +
  524 + #have we got the FKs in place
  525 + self.assertTrue(hasattr(BroadcastEventVariation, 'unvaried_event'))
  526 + self.assertTrue(hasattr(evt, 'variations'))
  527 + # let's try it out
  528 + var_event = evt.create_variation(presenter = "Amy Sub")
  529 + evt.full_clean()
  530 +
  531 + def test_clean_with_no_varied_event_defined(self):
  532 + """ a model with no variations defined can be cleaned """
  533 +
  534 + subject = 'Effective Time Management for Django Programmers'
  535 + lesson = LessonEvent.objects.create(subject=subject)
  536 + self.assertFalse(hasattr(lesson,'variations'))
  537 + lesson.full_clean()
4 requirements.txt
... ... @@ -1,2 +1,4 @@
1 1 django-countries==1.0.3
2   -vobject==0.8.1c
  2 +# need to use python-dateutil <2.x for python2.x
  3 +python-dateutil==1.5
  4 +vobject==0.8.1c
2  setup.py
@@ -20,7 +20,7 @@
20 20 'Operating System :: OS Independent',
21 21 'Programming Language :: Python',
22 22 'Topic :: Utilities'],
23   - install_requires=['setuptools', 'vobject', 'python-dateutil'],
  23 + install_requires=['setuptools', 'vobject', 'python-dateutil==1.5'],
24 24 license='BSD',
25 25 test_suite = "eventtools.tests",
26 26 )

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.