@@ -123,7 +123,8 @@ class RecurrenceRule(AbstractBaseModel):
123
123
def __str__ (self ):
124
124
return self .description
125
125
126
- class EventType (PluralTitleSlugMixin ):
126
+
127
+ class AbstractEventType (PluralTitleSlugMixin ):
127
128
is_public = models .BooleanField (
128
129
"Show to public?" ,
129
130
default = True ,
@@ -142,12 +143,16 @@ def swatch(self, color_only=False):
142
143
""" ).render (Context ({'o' : self , 'color_only' : color_only }))
143
144
144
145
class Meta :
146
+ abstract = True
145
147
# changing the verbose name rather than renaming because model rename
146
148
# migrations are sloooooow
147
149
verbose_name = "Event category"
148
150
verbose_name_plural = "Event categories"
149
151
150
152
153
+ class EventType (AbstractEventType ):
154
+ pass
155
+
151
156
152
157
@encoding .python_2_unicode_compatible
153
158
class EventBase (PolymorphicModel , AbstractBaseModel , ICEkitContentsMixin ,
@@ -168,7 +173,8 @@ class EventBase(PolymorphicModel, AbstractBaseModel, ICEkitContentsMixin,
168
173
objects = EventManager ()
169
174
170
175
primary_type = models .ForeignKey (
171
- EventType , blank = True , null = True ,
176
+ 'icekit_events.EventType' ,
177
+ blank = True , null = True ,
172
178
verbose_name = "Primary category" ,
173
179
help_text = "The primary category of this event: Talk, workshop, etc. Only "
174
180
"'public' event categories can be primary." ,
@@ -614,7 +620,7 @@ class GeneratorException(Exception):
614
620
615
621
616
622
@encoding .python_2_unicode_compatible
617
- class EventRepeatsGenerator (AbstractBaseModel ):
623
+ class AbstractEventRepeatsGenerator (AbstractBaseModel ):
618
624
"""
619
625
A model storing the information and features required to generate a set
620
626
of repeating datetimes for a given repeat rule.
@@ -633,7 +639,7 @@ class EventRepeatsGenerator(AbstractBaseModel):
633
639
explicitly is most likely the easiest way to ensure this.
634
640
"""
635
641
event = models .ForeignKey (
636
- EventBase ,
642
+ 'icekit_events. EventBase' ,
637
643
db_index = True ,
638
644
editable = False ,
639
645
related_name = 'repeat_generators' ,
@@ -661,6 +667,7 @@ class EventRepeatsGenerator(AbstractBaseModel):
661
667
)
662
668
663
669
class Meta :
670
+ abstract = True
664
671
ordering = ['pk' ] # Order by PK, essentially in creation order
665
672
666
673
def __str__ (self ):
@@ -782,7 +789,7 @@ def save(self, *args, **kwargs):
782
789
self .end = zero_datetime (self .end ) \
783
790
+ timedelta (days = 1 , microseconds = - 1 )
784
791
785
- super (EventRepeatsGenerator , self ).save (* args , ** kwargs )
792
+ super (AbstractEventRepeatsGenerator , self ).save (* args , ** kwargs )
786
793
787
794
@property
788
795
def duration (self ):
@@ -792,23 +799,27 @@ def duration(self):
792
799
return self .end - self .start
793
800
794
801
802
+ class EventRepeatsGenerator (AbstractEventRepeatsGenerator ):
803
+ pass
804
+
805
+
795
806
@encoding .python_2_unicode_compatible
796
- class Occurrence (AbstractBaseModel ):
807
+ class AbstractOccurrence (AbstractBaseModel ):
797
808
"""
798
809
A specific occurrence of an Event with start and end date times, and
799
810
a reference back to the owner event that contains all the other data.
800
811
"""
801
812
objects = OccurrenceManager ()
802
813
803
814
event = models .ForeignKey (
804
- EventBase ,
815
+ 'icekit_events. EventBase' ,
805
816
db_index = True ,
806
817
editable = False ,
807
818
related_name = 'occurrences' ,
808
819
on_delete = models .CASCADE
809
820
)
810
821
generator = models .ForeignKey (
811
- EventRepeatsGenerator ,
822
+ 'icekit_events. EventRepeatsGenerator' ,
812
823
blank = True , null = True ,
813
824
on_delete = models .SET_NULL
814
825
)
@@ -850,6 +861,7 @@ class Occurrence(AbstractBaseModel):
850
861
blank = True , null = True , editable = False )
851
862
852
863
class Meta :
864
+ abstract = True
853
865
ordering = ['start' , '-is_all_day' , 'event' , 'pk' ]
854
866
855
867
def time_range_string (self ):
@@ -911,7 +923,7 @@ def save(self, *args, **kwargs):
911
923
self .original_start = self .start
912
924
if not self .original_end :
913
925
self .original_end = self .end
914
- super (Occurrence , self ).save (* args , ** kwargs )
926
+ super (AbstractOccurrence , self ).save (* args , ** kwargs )
915
927
916
928
# TODO Return __str__ as title for now, improve it later
917
929
def title (self ):
@@ -927,6 +939,10 @@ def get_absolute_url(self):
927
939
return self .event .get_occurrence_url (self )
928
940
929
941
942
+ class Occurrence (AbstractOccurrence ):
943
+ pass
944
+
945
+
930
946
def get_occurrence_times_for_event (event ):
931
947
"""
932
948
Return a tuple with two sets containing the (start, end) *naive* datetimes
0 commit comments