Skip to content

Commit 6c1e87b

Browse files
committed
Move milestones branch out of the way to prepare for merge with trunk to get latest charter changes in
[[Split portion of a mixed commit.]] - Legacy-Id: 4514.1
1 parent 37172f3 commit 6c1e87b

35 files changed

Lines changed: 3643 additions & 377 deletions

ietf/doc/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ class DocReminder(models.Model):
311311
# WG events
312312
("changed_group", "Changed group"),
313313
("changed_protocol_writeup", "Changed protocol writeup"),
314+
("changed_charter_milestone", "Changed charter milestone"),
314315

315316
# charter events
316317
("initial_review", "Set initial review time"),

ietf/group/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ class GroupHistoryAdmin(admin.ModelAdmin):
116116
admin.site.register(GroupHistory, GroupHistoryAdmin)
117117

118118
class GroupMilestoneAdmin(admin.ModelAdmin):
119-
list_display = ["group", "desc", "expected_due_date", "time"]
120-
search_fields = ["group__name", "group__acronym", "desc"]
119+
list_display = ["group", "desc", "due", "resolved", "time"]
120+
search_fields = ["group__name", "group__acronym", "desc", "resolved"]
121121
raw_id_fields = ["group"]
122122

123123
admin.site.register(GroupMilestone, GroupMilestoneAdmin)

ietf/group/migrations/0001_initial.py

Lines changed: 481 additions & 0 deletions
Large diffs are not rendered by default.

ietf/group/migrations/0002_auto__add_milestonegroupevent__del_field_groupmilestone_expected_due_d.py

Lines changed: 361 additions & 0 deletions
Large diffs are not rendered by default.

ietf/group/migrations/0003_fixup_milestone.py

Lines changed: 331 additions & 0 deletions
Large diffs are not rendered by default.

ietf/group/migrations/0004_auto__del_field_groupmilestone_done_date__del_field_groupmilestone_don.py

Lines changed: 322 additions & 0 deletions
Large diffs are not rendered by default.

ietf/group/migrations/0005_auto__add_groupmilestonehistory.py

Lines changed: 349 additions & 0 deletions
Large diffs are not rendered by default.

ietf/group/migrations/__init__.py

Whitespace-only changes.

ietf/group/models.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,31 @@ class GroupURL(models.Model):
6060
def __unicode__(self):
6161
return u"%s (%s)" % (self.url, self.name)
6262

63-
class GroupMilestone(models.Model):
63+
class GroupMilestoneInfo(models.Model):
6464
group = models.ForeignKey(Group)
65-
desc = models.TextField(verbose_name="Description")
66-
expected_due_date = models.DateField()
67-
done = models.BooleanField()
68-
done_date = models.DateField(null=True, blank=True)
65+
# a group has two sets of milestones, current milestones
66+
# (active/under review/deleted) and charter milestones (active
67+
# during a charter/recharter event), events for charter milestones
68+
# are stored on the charter document
69+
state = models.ForeignKey(GroupMilestoneStateName)
70+
desc = models.CharField(verbose_name="Description", max_length=500)
71+
due = models.DateField()
72+
resolved = models.CharField(max_length=50, blank=True, help_text="Explanation of why milestone is resolved (usually \"Done\"), or empty if still due")
6973
time = models.DateTimeField(auto_now=True)
74+
75+
docs = models.ManyToManyField('doc.Document', blank=True)
76+
7077
def __unicode__(self):
7178
return self.desc[:20] + "..."
7279
class Meta:
73-
ordering = ['expected_due_date']
80+
abstract = True
81+
ordering = ['due', 'id']
82+
83+
class GroupMilestone(GroupMilestoneInfo):
84+
pass
85+
86+
class GroupMilestoneHistory(GroupMilestoneInfo):
87+
milestone = models.ForeignKey(GroupMilestone, related_name="history_set")
7488

7589
class GroupStateTransitions(models.Model):
7690
"""Captures that a group has overriden the default available
@@ -86,6 +100,7 @@ def __unicode__(self):
86100
("changed_state", "Changed state"),
87101
("added_comment", "Added comment"),
88102
("info_changed", "Changed metadata"),
103+
("changed_milestone", "Changed milestone"),
89104
]
90105

91106
class GroupEvent(models.Model):
@@ -105,6 +120,9 @@ class Meta:
105120
class ChangeStateGroupEvent(GroupEvent):
106121
state = models.ForeignKey(GroupStateName)
107122

123+
class MilestoneGroupEvent(GroupEvent):
124+
milestone = models.ForeignKey(GroupMilestone)
125+
108126
class Role(models.Model):
109127
name = models.ForeignKey(RoleName)
110128
group = models.ForeignKey(Group)

ietf/group/utils.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,21 @@
33
from django.conf import settings
44

55
from ietf.group.models import *
6+
from ietf.utils.history import get_history_object_for, copy_many_to_many_for_history
67

78

89
def save_group_in_history(group):
9-
def get_model_fields_as_dict(obj):
10-
return dict((field.name, getattr(obj, field.name))
11-
for field in obj._meta.fields
12-
if field is not obj._meta.pk)
13-
14-
# copy fields
15-
fields = get_model_fields_as_dict(group)
16-
del fields["charter"] # Charter is saved canonically on Group
17-
fields["group"] = group
18-
19-
grouphist = GroupHistory(**fields)
20-
grouphist.save()
10+
h = get_history_object_for(group)
11+
h.save()
2112

2213
# save RoleHistory
2314
for role in group.role_set.all():
2415
rh = RoleHistory(name=role.name, group=grouphist, email=role.email, person=role.person)
2516
rh.save()
2617

27-
# copy many to many
28-
for field in group._meta.many_to_many:
29-
if field.rel.through and field.rel.through._meta.auto_created:
30-
setattr(grouphist, field.name, getattr(group, field.name).all())
18+
copy_many_to_many_for_history(h, group)
3119

32-
return grouphist
20+
return h
3321

3422
def get_charter_text(group):
3523
# get file path from settings. Syntesize file name from path, acronym, and suffix
@@ -55,3 +43,12 @@ def get_charter_text(group):
5543
except BaseException:
5644
desc = 'Error Loading Work Group Description'
5745
return desc
46+
47+
def save_milestone_in_history(milestone):
48+
h = get_history_object_for(milestone)
49+
h.milestone = milestone
50+
h.save()
51+
52+
copy_many_to_many_for_history(h, milestone)
53+
54+
return h

0 commit comments

Comments
 (0)