66
77import datetime
88
9- class Group (models .Model ):
9+ class GroupInfo (models .Model ):
1010 time = models .DateTimeField (default = datetime .datetime .now ) # should probably have auto_now=True
1111 name = models .CharField (max_length = 80 )
1212 acronym = models .CharField (max_length = 16 , db_index = True )
1313 state = models .ForeignKey (GroupStateName , null = True )
1414 type = models .ForeignKey (GroupTypeName , null = True )
15- charter = models .OneToOneField ('doc.Document' , related_name = 'chartered_group' , blank = True , null = True )
1615 parent = models .ForeignKey ('Group' , blank = True , null = True )
1716 ad = models .ForeignKey (Person , blank = True , null = True )
1817 list_email = models .CharField (max_length = 64 , blank = True )
@@ -21,11 +20,29 @@ class Group(models.Model):
2120 comments = models .TextField (blank = True )
2221 def __unicode__ (self ):
2322 return self .name
23+
24+ class Meta :
25+ abstract = True
26+
27+ class Group (GroupInfo ):
28+ # we keep charter separate
29+ charter = models .OneToOneField ('doc.Document' , related_name = 'chartered_group' , blank = True , null = True )
30+
2431 def latest_event (self , * args , ** filter_args ):
2532 """Get latest group event with filter arguments, e.g.
2633 d.latest_event(type="xyz")."""
2734 e = GroupEvent .objects .filter (group = self ).filter (** filter_args ).order_by ('-time' , '-id' )[:1 ]
2835 return e [0 ] if e else None
36+
37+ # This will record the new state and the date it occurred for any changes
38+ # to a group. The group acronym must be unique and is the invariant used
39+ # to select group history from this table.
40+ class GroupHistory (GroupInfo ):
41+ group = models .ForeignKey ('Group' , related_name = 'group_history' )
42+ charter = models .ForeignKey ('doc.Document' , related_name = 'chartered_group_history_set' , blank = True , null = True )
43+
44+ class Meta :
45+ verbose_name_plural = "group histories"
2946
3047class GroupURL (models .Model ):
3148 group = models .ForeignKey (Group )
@@ -63,38 +80,20 @@ def __unicode__(self):
6380 class Meta :
6481 ordering = ['-time' , 'id' ]
6582
66- # This will actually be extended from Groups, but that requires Django 1.0
67- # This will record the new state and the date it occurred for any changes
68- # to a group. The group acronym must be unique and is the invariant used
69- # to select group history from this table.
70- # FIXME: this class needs to be updated
71- class GroupHistory (models .Model ):
72- group = models .ForeignKey ('Group' , related_name = 'group_history' )
73- # Event related
74- time = models .DateTimeField ()
75- comment = models .TextField ()
76- who = models .ForeignKey (Email , related_name = 'group_changes' )
77- # inherited from Group:
78- name = models .CharField (max_length = 64 )
79- acronym = models .CharField (max_length = 16 )
80- state = models .ForeignKey (GroupStateName )
81- type = models .ForeignKey (GroupTypeName )
82- charter = models .ForeignKey ('doc.Document' , related_name = 'chartered_group_history' )
83- parent = models .ForeignKey ('Group' )
84- chairs = models .ManyToManyField (Email , related_name = 'chaired_groups_history' )
85- list_email = models .CharField (max_length = 64 )
86- list_pages = models .CharField (max_length = 64 )
87- comments = models .TextField (blank = True )
88- def __unicode__ (self ):
89- return self .group .name
90- class Meta :
91- verbose_name_plural = "Doc histories"
92-
9383class Role (models .Model ):
9484 name = models .ForeignKey (RoleName )
9585 group = models .ForeignKey (Group )
9686 email = models .ForeignKey (Email , help_text = "Email address used by person for this role" )
9787 auth = models .CharField (max_length = 255 , blank = True ) # unused?
9888 def __unicode__ (self ):
9989 return u"%s is %s in %s" % (self .email .get_name (), self .name .name , self .group .acronym )
90+
91+
92+ class RoleHistory (models .Model ):
93+ name = models .ForeignKey (RoleName )
94+ group = models .ForeignKey (GroupHistory )
95+ email = models .ForeignKey (Email , help_text = "Email address used by person for this role" )
96+ auth = models .CharField (max_length = 255 , blank = True ) # unused?
97+ def __unicode__ (self ):
98+ return u"%s is %s in %s" % (self .email .get_name (), self .name .name , self .group .acronym )
10099
0 commit comments