Skip to content

Commit

Permalink
Move charters for replaced groups to a new replaced state. Close any …
Browse files Browse the repository at this point in the history
…outstanding ballots on them. Fixes #2889, #2873, and #1286. Commit ready for merge.

 - Legacy-Id: 17396
  • Loading branch information
rjsparks committed Mar 6, 2020
1 parent 92b2f06 commit 79bb245
Show file tree
Hide file tree
Showing 6 changed files with 14,359 additions and 14,274 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# Copyright The IETF Trust 2020, All Rights Reserved
# Generated by Django 1.11.28 on 2020-03-03 13:54
from __future__ import unicode_literals

from django.db import migrations

def forward(apps, schema_editor):

Person = apps.get_model('person', 'Person')

Document = apps.get_model('doc','Document')
State = apps.get_model('doc','State')
BallotDocEvent = apps.get_model('doc','BallotDocEvent')

replaced_state = State.objects.create(type_id='charter', slug='replaced', name='Replaced', used=True, desc="This charter's group was replaced.", order = 0)
by = Person.objects.get(name='(System)')

for doc in Document.objects.filter(type_id='charter',states__type_id='charter',states__slug__in=['intrev','extrev'],group__state='replaced'):
doc.states.remove(*list(doc.states.filter(type_id='charter')))
doc.states.add(replaced_state)
ballot = BallotDocEvent.objects.filter(doc=doc, type__in=('created_ballot', 'closed_ballot')).order_by('-time', '-id').first()
if ballot and ballot.type == 'created_ballot':
e = BallotDocEvent(type="closed_ballot", doc=doc, rev=doc.rev, by=by)
e.ballot_type = ballot.ballot_type
e.desc = 'Closed "%s" ballot' % e.ballot_type.name
e.save()


def reverse(apps, schema_editor):
pass

class Migration(migrations.Migration):

dependencies = [
('doc', '0029_add_ipr_event_types'),
('person', '0009_auto_20190118_0725'),
]

operations = [
migrations.RunPython(forward, reverse),
]
21 changes: 18 additions & 3 deletions ietf/doc/utils_charter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2011-2019, All Rights Reserved
# Copyright The IETF Trust 2011-2020, All Rights Reserved
# -*- coding: utf-8 -*-


Expand All @@ -17,7 +17,8 @@

import debug # pyflakes:ignore

from ietf.doc.models import NewRevisionDocEvent, WriteupDocEvent
from ietf.doc.models import NewRevisionDocEvent, WriteupDocEvent, State, StateDocEvent
from ietf.doc.utils import close_open_ballots
from ietf.group.models import ChangeStateGroupEvent
from ietf.name.models import GroupStateName
from ietf.utils.history import find_history_active_at
Expand Down Expand Up @@ -246,4 +247,18 @@ def generate_issue_ballot_mail(request, doc, ballot):
)
)


def replace_charter_of_replaced_group(group, by):

assert group.state_id == 'replaced'

charter = group.charter

if charter:

close_open_ballots(charter, by)

replaced_state = State.objects.get(type_id='charter', slug='replaced')
charter.set_state(replaced_state)
state_change_event = StateDocEvent.objects.create(state_type_id='charter', state=replaced_state, doc=charter, rev=charter.rev, by=by, type="changed_state", desc="Charter's group has been replaced")

charter.save_with_history([state_change_event])
4 changes: 2 additions & 2 deletions ietf/doc/views_search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright The IETF Trust 2009-2019, All Rights Reserved
# Copyright The IETF Trust 2009-2020, All Rights Reserved
# -*- coding: utf-8 -*-
#
# Some parts Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
Expand Down Expand Up @@ -354,7 +354,7 @@ def ad_dashboard_sort_key(doc):
state = State.objects.get(type__slug='draft-iesg',slug='ad-eval')
return "1%d%s" % (state.order,seed)

if doc.type.slug=='charter':
if doc.type.slug=='charter' and doc.get_state_slug('charter') != 'replaced':
if doc.get_state_slug('charter') in ('notrev','infrev'):
return "100%s" % seed
elif doc.get_state_slug('charter') == 'intrev':
Expand Down
15 changes: 14 additions & 1 deletion ietf/group/tests_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from ietf.community.models import CommunityList
from ietf.community.utils import reset_name_contains_index_for_rule
from ietf.doc.factories import WgDraftFactory, CharterFactory
from ietf.doc.factories import WgDraftFactory, CharterFactory, BallotDocEventFactory
from ietf.doc.models import Document, DocAlias, DocEvent, State
from ietf.doc.utils_charter import charter_name_for_group
from ietf.group.factories import (GroupFactory, RoleFactory, GroupEventFactory,
Expand Down Expand Up @@ -758,6 +758,19 @@ def test_conclude(self):
group = Group.objects.get(acronym=group.acronym)
self.assertEqual(group.state_id, "active")

def test_replace(self):
group = GroupFactory(state_id='bof')
charter = CharterFactory(group=group, states=[('charter','intrev')])
BallotDocEventFactory(doc=charter, ballot_type__doc_type_id='draft', ballot_type__slug='r-extrev')
url = urlreverse('ietf.group.views.edit', kwargs=dict(group_type=group.type_id, acronym=group.acronym, action="edit", field="state"))
self.client.login(username='secretary',password='secretary+password')
self.client.post(url, dict(state='replaced'))
group = Group.objects.get(pk=group.pk)
self.assertEqual(group.state_id, 'replaced')
self.assertEqual(group.charter.get_state_slug('charter'), 'replaced')
self.assertEqual(group.charter.active_ballot(), None)


def test_add_comment(self):
group = GroupFactory(acronym="mars",parent=GroupFactory(type_id='area'))
RoleFactory(group=group,person=Person.objects.get(user__username='ad'),name_id='ad')
Expand Down
4 changes: 3 additions & 1 deletion ietf/group/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
from ietf.doc.models import DocTagName, State, DocAlias, RelatedDocument, Document
from ietf.doc.templatetags.ietf_filters import clean_whitespace
from ietf.doc.utils import get_chartering_type, get_tags_for_stream_id
from ietf.doc.utils_charter import charter_name_for_group
from ietf.doc.utils_charter import charter_name_for_group, replace_charter_of_replaced_group
from ietf.doc.utils_search import prepare_document_table
#
from ietf.group.dot import make_dot
Expand Down Expand Up @@ -1029,6 +1029,8 @@ def diff(attr, name):
for attr, new, desc in changes:
if attr == 'state':
ChangeStateGroupEvent.objects.create(group=group, time=group.time, state=new, by=request.user.person, type="changed_state", desc=desc)
if new.slug == 'replaced':
replace_charter_of_replaced_group(group=group, by=request.user.person)
else:
GroupEvent.objects.create(group=group, time=group.time, by=request.user.person, type="info_changed", desc=desc)

Expand Down
Loading

0 comments on commit 79bb245

Please sign in to comment.