Bugs/issue11 #12

Merged
merged 6 commits into from Aug 9, 2011
@@ -291,7 +291,7 @@ def variations_count(self):
"""
returns the number of variations that this event has
"""
- if self.__class__.varied_by:
+ if getattr(self.__class__,'varied_by',None):
try:
return self.variations.count()
except: # if none have been created, there is no such thing as self.variations, so return 0
@@ -64,4 +64,4 @@ def __unicode__(self):
class Meta:
abstract = True
- ordering = ['unvaried_event__title', 'reason']
+ ordering = ['unvaried_event', 'reason']
@@ -382,7 +382,7 @@ def occurrences_after(self, after=None):
next = generator.next()
yield occ_replacer.get_occurrence(next)
- def save(self):
+ def save(self,*args,**kwargs):
# if the occurrence generator changes, we must not break the link with persisted occurrences
if self.id: # must already exist
saved_self = self.__class__.objects.get(pk=self.id)
@@ -411,5 +411,5 @@ def save(self):
occ.unvaried_end_time = unvaried_end.time()
occ.save()
- super(OccurrenceGeneratorBase, self).save()
+ super(OccurrenceGeneratorBase, self).save(*args,**kwargs)
@@ -514,3 +514,24 @@ def _test_combo(result, first_start_date, repeat_until=None, rule=weekly):
rule=None,
result=0
)
+
+
+ def test_clean_with_variation(self):
+ """ a model with variations defined can be cleaned """
+
+ evt = BroadcastEvent.objects.create(presenter = "Jimmy McBigmouth", studio=2)
+
+ #have we got the FKs in place
+ self.assertTrue(hasattr(BroadcastEventVariation, 'unvaried_event'))
+ self.assertTrue(hasattr(evt, 'variations'))
+ # let's try it out
+ var_event = evt.create_variation(presenter = "Amy Sub")
+ evt.full_clean()
+
+ def test_clean_with_no_varied_event_defined(self):
+ """ a model with no variations defined can be cleaned """
+
+ subject = 'Effective Time Management for Django Programmers'
+ lesson = LessonEvent.objects.create(subject=subject)
+ self.assertFalse(hasattr(lesson,'variations'))
+ lesson.full_clean()
View
@@ -1,2 +1,4 @@
django-countries==1.0.3
-vobject==0.8.1c
+# need to use python-dateutil <2.x for python2.x
+python-dateutil==1.5
+vobject==0.8.1c
View
@@ -20,7 +20,7 @@
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Utilities'],
- install_requires=['setuptools', 'vobject', 'python-dateutil'],
+ install_requires=['setuptools', 'vobject', 'python-dateutil==1.5'],
license='BSD',
test_suite = "eventtools.tests",
)