Bring GroupHistory up to date, add history for roles too
- Legacy-Id: 3278
This commit is contained in:
parent
3491c78909
commit
20e780c276
|
@ -6,13 +6,12 @@ from redesign.person.models import Email, Person
|
|||
|
||||
import datetime
|
||||
|
||||
class Group(models.Model):
|
||||
class GroupInfo(models.Model):
|
||||
time = models.DateTimeField(default=datetime.datetime.now) # should probably have auto_now=True
|
||||
name = models.CharField(max_length=80)
|
||||
acronym = models.CharField(max_length=16, db_index=True)
|
||||
state = models.ForeignKey(GroupStateName, null=True)
|
||||
type = models.ForeignKey(GroupTypeName, null=True)
|
||||
charter = models.OneToOneField('doc.Document', related_name='chartered_group', blank=True, null=True)
|
||||
parent = models.ForeignKey('Group', blank=True, null=True)
|
||||
ad = models.ForeignKey(Person, blank=True, null=True)
|
||||
list_email = models.CharField(max_length=64, blank=True)
|
||||
|
@ -21,11 +20,29 @@ class Group(models.Model):
|
|||
comments = models.TextField(blank=True)
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
class Group(GroupInfo):
|
||||
# we keep charter separate
|
||||
charter = models.OneToOneField('doc.Document', related_name='chartered_group', blank=True, null=True)
|
||||
|
||||
def latest_event(self, *args, **filter_args):
|
||||
"""Get latest group event with filter arguments, e.g.
|
||||
d.latest_event(type="xyz")."""
|
||||
e = GroupEvent.objects.filter(group=self).filter(**filter_args).order_by('-time', '-id')[:1]
|
||||
return e[0] if e else None
|
||||
|
||||
# This will record the new state and the date it occurred for any changes
|
||||
# to a group. The group acronym must be unique and is the invariant used
|
||||
# to select group history from this table.
|
||||
class GroupHistory(GroupInfo):
|
||||
group = models.ForeignKey('Group', related_name='group_history')
|
||||
charter = models.ForeignKey('doc.Document', related_name='chartered_group_history_set', blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural="group histories"
|
||||
|
||||
class GroupURL(models.Model):
|
||||
group = models.ForeignKey(Group)
|
||||
|
@ -63,33 +80,6 @@ class GroupEvent(models.Model):
|
|||
class Meta:
|
||||
ordering = ['-time', 'id']
|
||||
|
||||
# This will actually be extended from Groups, but that requires Django 1.0
|
||||
# This will record the new state and the date it occurred for any changes
|
||||
# to a group. The group acronym must be unique and is the invariant used
|
||||
# to select group history from this table.
|
||||
# FIXME: this class needs to be updated
|
||||
class GroupHistory(models.Model):
|
||||
group = models.ForeignKey('Group', related_name='group_history')
|
||||
# Event related
|
||||
time = models.DateTimeField()
|
||||
comment = models.TextField()
|
||||
who = models.ForeignKey(Email, related_name='group_changes')
|
||||
# inherited from Group:
|
||||
name = models.CharField(max_length=64)
|
||||
acronym = models.CharField(max_length=16)
|
||||
state = models.ForeignKey(GroupStateName)
|
||||
type = models.ForeignKey(GroupTypeName)
|
||||
charter = models.ForeignKey('doc.Document', related_name='chartered_group_history')
|
||||
parent = models.ForeignKey('Group')
|
||||
chairs = models.ManyToManyField(Email, related_name='chaired_groups_history')
|
||||
list_email = models.CharField(max_length=64)
|
||||
list_pages = models.CharField(max_length=64)
|
||||
comments = models.TextField(blank=True)
|
||||
def __unicode__(self):
|
||||
return self.group.name
|
||||
class Meta:
|
||||
verbose_name_plural="Doc histories"
|
||||
|
||||
class Role(models.Model):
|
||||
name = models.ForeignKey(RoleName)
|
||||
group = models.ForeignKey(Group)
|
||||
|
@ -97,4 +87,13 @@ class Role(models.Model):
|
|||
auth = models.CharField(max_length=255, blank=True) # unused?
|
||||
def __unicode__(self):
|
||||
return u"%s is %s in %s" % (self.email.get_name(), self.name.name, self.group.acronym)
|
||||
|
||||
|
||||
class RoleHistory(models.Model):
|
||||
name = models.ForeignKey(RoleName)
|
||||
group = models.ForeignKey(GroupHistory)
|
||||
email = models.ForeignKey(Email, help_text="Email address used by person for this role")
|
||||
auth = models.CharField(max_length=255, blank=True) # unused?
|
||||
def __unicode__(self):
|
||||
return u"%s is %s in %s" % (self.email.get_name(), self.name.name, self.group.acronym)
|
||||
|
||||
|
|
Loading…
Reference in a new issue