Skip to content

Commit 01461d1

Browse files
committed
Make sure group state is set when approving charters for non-WGs
- Legacy-Id: 7565
1 parent 25d37c0 commit 01461d1

1 file changed

Lines changed: 40 additions & 28 deletions

File tree

ietf/doc/views_charter.py

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def change_state(request, name, option=None):
157157
elif charter_state.slug == "iesgrev":
158158
create_ballot_if_not_open(charter, login, "approve")
159159
elif charter_state.slug == "approved":
160+
change_group_state_after_charter_approval(group, login)
160161
fix_charter_revision_after_approval(charter, login)
161162

162163
if charter_state.slug == "infrev" and clean["initial_time"] and clean["initial_time"] != 0:
@@ -167,19 +168,23 @@ def change_state(request, name, option=None):
167168

168169
return redirect('doc_view', name=charter.name)
169170
else:
170-
if option == "recharter" and group.type_id == "wg":
171-
hide = ['initial_time', 'charter_state', 'message']
172-
init = dict()
173-
elif option == "initcharter" and group.type_id == "wg":
174-
hide = ['charter_state']
175-
init = dict(initial_time=1, message='%s has initiated chartering of the proposed %s:\n "%s" (%s).' % (login.plain_name(), group.type.name, group.name, group.acronym))
176-
elif option == "abandon":
171+
hide = ['initial_time']
172+
s = charter.get_state()
173+
init = dict(charter_state=s.pk if s and option != "recharter" else None)
174+
175+
if option == "abandon":
177176
hide = ['initial_time', 'charter_state']
178-
init = dict(message='%s has abandoned the chartering effort on the %s:\n "%s" (%s).' % (login.plain_name(), group.type.name, group.name, group.acronym))
179-
else:
180-
hide = ['initial_time']
181-
s = charter.get_state()
182-
init = dict(charter_state=s.pk if s else None)
177+
178+
if group.type_id == "wg":
179+
if option == "recharter":
180+
hide = ['initial_time', 'charter_state', 'message']
181+
init = dict()
182+
elif option == "initcharter":
183+
hide = ['charter_state']
184+
init = dict(initial_time=1, message='%s has initiated chartering of the proposed %s:\n "%s" (%s).' % (login.plain_name(), group.type.name, group.name, group.acronym))
185+
elif option == "abandon":
186+
hide = ['initial_time', 'charter_state']
187+
init = dict(message='%s has abandoned the chartering effort on the %s:\n "%s" (%s).' % (login.plain_name(), group.type.name, group.name, group.acronym))
183188
form = ChangeStateForm(hide=hide, initial=init, group=group)
184189

185190
prev_charter_state = None
@@ -586,6 +591,26 @@ def ballot_writeupnotes(request, name):
586591
),
587592
context_instance=RequestContext(request))
588593

594+
def change_group_state_after_charter_approval(group, by):
595+
new_state = GroupStateName.objects.get(slug="active")
596+
if group.state == new_state:
597+
return None
598+
599+
save_group_in_history(group)
600+
group.state = new_state
601+
group.time = datetime.datetime.now()
602+
group.save()
603+
604+
# create an event for the group state change, too
605+
e = ChangeStateGroupEvent(group=group, type="changed_state")
606+
e.time = group.time
607+
e.by = by
608+
e.state_id = "active"
609+
e.desc = "Charter approved, group active"
610+
e.save()
611+
612+
return e
613+
589614
def fix_charter_revision_after_approval(charter, by):
590615
# according to spec, 00-02 becomes 01, so copy file and record new revision
591616
try:
@@ -637,22 +662,9 @@ def approve(request, name):
637662

638663
change_description = e.desc
639664

640-
new_state = GroupStateName.objects.get(slug="active")
641-
if group.state != new_state:
642-
save_group_in_history(group)
643-
group.state = new_state
644-
group.time = e.time
645-
group.save()
646-
647-
# create an event for the wg state change, too
648-
e = ChangeStateGroupEvent(group=group, type="changed_state")
649-
e.time = group.time
650-
e.by = login
651-
e.state_id = "active"
652-
e.desc = "Charter approved, group active"
653-
e.save()
654-
655-
change_description += " and %s state has been changed to %s" % (group.type.name, new_state.name)
665+
group_state_change_event = change_group_state_after_charter_approval(group, login)
666+
if group_state_change_event:
667+
change_description += " and group state has been changed to %s" % group.state.name
656668

657669
e = add_state_change_event(charter, login, prev_charter_state, new_charter_state)
658670

0 commit comments

Comments
 (0)