fix: restore ability to create status change documents (#5963)

* fix: restore ability to create status change documents

Fixes #5962

* chore: address review comment
This commit is contained in:
Robert Sparks 2023-07-22 14:40:38 -05:00 committed by GitHub
parent 5f8fca68f4
commit f82988d8b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 13 deletions

View file

@ -14,7 +14,7 @@ from textwrap import wrap
from django.conf import settings
from django.urls import reverse as urlreverse
from ietf.doc.factories import DocumentFactory, IndividualRfcFactory, WgRfcFactory
from ietf.doc.factories import DocumentFactory, IndividualRfcFactory, WgRfcFactory, DocEventFactory
from ietf.doc.models import ( Document, DocAlias, State, DocEvent,
BallotPositionDocEvent, NewRevisionDocEvent, TelechatDocEvent, WriteupDocEvent )
from ietf.doc.utils import create_ballot_if_not_open
@ -86,6 +86,16 @@ class StatusChangeTests(TestCase):
status_change = Document.objects.get(name='status-change-imaginary-new2')
self.assertIsNone(status_change.ad)
# Verify that the right thing happens if a control along the way uppercases RFC
r = self.client.post(url,dict(
document_name="imaginary-new3",title="A new imaginary status change",
create_in_state=state_strpk,notify='ipu@ietf.org',new_relation_row_blah="RFC9999",
statchg_relation_row_blah="tois")
)
self.assertEqual(r.status_code, 302)
status_change = Document.objects.get(name='status-change-imaginary-new3')
self.assertTrue(status_change.relateddocument_set.filter(relationship__slug='tois',target__name='rfc9999'))
def test_change_state(self):
@ -289,7 +299,19 @@ class StatusChangeTests(TestCase):
self.assertEqual(r.status_code,200)
self.assertContains(r, 'RFC9999 from Proposed Standard to Internet Standard')
self.assertContains(r, 'RFC9998 from Informational to Historic')
q = PyQuery(r.content)
self.assertEqual(len(q("button[name='send_last_call_request']")), 1)
# Make sure request LC isn't offered with no responsible AD.
doc.ad = None
doc.save_with_history([DocEventFactory(doc=doc)])
r = self.client.get(url)
self.assertEqual(r.status_code,200)
q = PyQuery(r.content)
self.assertEqual(len(q("button[name='send_last_call_request']")), 0)
doc.ad = Person.objects.get(name='Ad No2')
doc.save_with_history([DocEventFactory(doc=doc)])
# request last call
messages_before = len(outbox)
r = self.client.post(url,dict(last_call_text='stuff',send_last_call_request='Save+and+Request+Last+Call'))

View file

@ -418,7 +418,7 @@ def clean_helper(form, formtype):
rfc_fields = {}
status_fields={}
for k in sorted(form.data.keys()):
v = form.data[k]
v = form.data[k].lower()
if k.startswith('new_relation_row'):
if re.match(r'\d{1,4}',v):
v = 'rfc'+v
@ -685,7 +685,7 @@ def last_call(request, name):
form = LastCallTextForm(initial=dict(last_call_text=escape(last_call_event.text)))
if request.method == 'POST':
if "save_last_call_text" in request.POST or "send_last_call_request" in request.POST:
if "save_last_call_text" in request.POST or ("send_last_call_request" in request.POST and status_change.ad is not None):
form = LastCallTextForm(request.POST)
if form.is_valid():
events = []

View file

@ -11,6 +11,11 @@
<br>
<small class="text-body-secondary">{{ doc }}</small>
</h1>
{% if doc.ad is None %}
<div class="alert alert-warning my-3">
A responsible AD must be set before last call can be requested.
</div>
{% endif %}
<form class="my-3 edit-last-call-text" method="post">
{% csrf_token %}
{% bootstrap_form last_call_form %}
@ -18,15 +23,17 @@
class="btn btn-primary"
name="save_last_call_text"
value="Save Last Call Text">Save text</button>
<button type="submit"
class="btn btn-warning"
name="send_last_call_request"
value="Save and Request Last Call">
Save text &amp; request last call
</button>
{% if user|has_role:"Secretariat" %}
<a class="btn btn-warning"
href="{% url 'ietf.doc.views_ballot.make_last_call' name=doc.name %}">Issue last call</a>
{% if doc.ad is not None %}
<button type="submit"
class="btn btn-warning"
name="send_last_call_request"
value="Save and Request Last Call">
Save text &amp; request last call
</button>
{% if user|has_role:"Secretariat" %}
<a class="btn btn-warning"
href="{% url 'ietf.doc.views_ballot.make_last_call' name=doc.name %}">Issue last call</a>
{% endif %}
{% endif %}
<button type="submit"
class="btn btn-danger"