Skip to content

Commit 76bcab6

Browse files
committed
Show formal languages used on new submissions and make the field
editable, also add it to the test with a simple JSON example - Legacy-Id: 12662
1 parent f4555c4 commit 76bcab6

7 files changed

Lines changed: 48 additions & 7 deletions

File tree

ietf/submit/forms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from ietf.ipr.mail import utc_from_string
2222
from ietf.meeting.models import Meeting
2323
from ietf.message.models import Message
24+
from ietf.name.models import FormalLanguageName
2425
from ietf.submit.models import Submission, Preapproval
2526
from ietf.submit.utils import validate_submission_rev, validate_submission_document_date
2627
from ietf.submit.parsers.pdf_parser import PDFParser
@@ -376,13 +377,14 @@ class EditSubmissionForm(forms.ModelForm):
376377
rev = forms.CharField(label=u'Revision', max_length=2, required=True)
377378
document_date = forms.DateField(required=True)
378379
pages = forms.IntegerField(required=True)
380+
formal_languages = forms.ModelMultipleChoiceField(queryset=FormalLanguageName.objects.filter(used=True), widget=forms.CheckboxSelectMultiple, required=False)
379381
abstract = forms.CharField(widget=forms.Textarea, required=True)
380382

381383
note = forms.CharField(label=mark_safe(u'Comment to the Secretariat'), widget=forms.Textarea, required=False)
382384

383385
class Meta:
384386
model = Submission
385-
fields = ['title', 'rev', 'document_date', 'pages', 'abstract', 'note']
387+
fields = ['title', 'rev', 'document_date', 'pages', 'formal_languages', 'abstract', 'note']
386388

387389
def clean_rev(self):
388390
rev = self.cleaned_data["rev"]

ietf/submit/test_submission.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ Internet-Draft Testing Tests %(month)s %(year)s
6161
Table of Contents
6262

6363
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
64-
2. Security Considerations . . . . . . . . . . . . . . . . . . . 2
65-
3. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 2
64+
2. Yang . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
65+
3. JSON example . . . . . . . . . . . . . . . . . . . . . . . . 2
66+
4. Security Considerations . . . . . . . . . . . . . . . . . . . 2
67+
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 2
6668
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 2
6769

6870
1. Introduction
@@ -169,11 +171,19 @@ Table of Contents
169171

170172
<CODE ENDS>
171173

172-
3. Security Considerations
174+
3. JSON example
175+
176+
The JSON object should look like this:
177+
178+
{
179+
"test": 1234
180+
}
181+
182+
4. Security Considerations
173183

174184
There are none.
175185

176-
4. IANA Considerations
186+
5. IANA Considerations
177187

178188
No new registrations for IANA.
179189

ietf/submit/test_submission.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ module ietf-mpls {
137137
</figure>
138138
</section>
139139

140+
<section anchor="JSON" title="JSON example">
141+
<t>
142+
The JSON object should look like this:
143+
144+
{
145+
"test": 1234
146+
}
147+
</t>
148+
</section>
140149
<section anchor="Security" title="Security Considerations">
141150
<t>
142151
There are none.

ietf/submit/tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from ietf.group.utils import setup_default_community_list_for_group
1919
from ietf.meeting.models import Meeting
2020
from ietf.message.models import Message
21+
from ietf.name.models import FormalLanguageName
2122
from ietf.person.models import Person, Email
2223
from ietf.person.factories import UserFactory, PersonFactory
2324
from ietf.submit.models import Submission, Preapproval
@@ -251,6 +252,7 @@ def submit_new_wg(self, formats):
251252
self.assertEqual(draft.authors.count(), 1)
252253
self.assertEqual(draft.authors.all()[0].get_name(), "Author Name")
253254
self.assertEqual(draft.authors.all()[0].address, "author@example.com")
255+
self.assertEqual(set(draft.formal_languages.all()), set(FormalLanguageName.objects.filter(slug="json")))
254256
self.assertEqual(draft.relations_that_doc("replaces").count(), 1)
255257
self.assertTrue(draft.relations_that_doc("replaces").first().target, replaced_alias)
256258
self.assertEqual(draft.relations_that_doc("possibly-replaces").count(), 1)

ietf/submit/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ def post_submission(request, submission, approvedDesc):
253253

254254
update_authors(draft, submission)
255255

256+
draft.formal_languages = submission.formal_languages.all()
257+
256258
trouble = rebuild_reference_relations(draft, filename=os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.txt' % (submission.name, submission.rev)))
257259
if trouble:
258260
log('Rebuild_reference_relations trouble: %s'%trouble)

ietf/submit/views.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ def edit_submission(request, submission_id, access_token=None):
449449
# trigger validation of all forms
450450
validations = [edit_form.is_valid(), submitter_form.is_valid(), replaces_form.is_valid()] + [ f.is_valid() for f in author_forms ]
451451
if all(validations):
452+
changed_fields = []
453+
452454
submission.submitter = submitter_form.cleaned_line()
453455
replaces = replaces_form.cleaned_data.get("replaces", [])
454456
submission.replaces = ",".join(o.name for o in replaces)
@@ -463,12 +465,18 @@ def edit_submission(request, submission_id, access_token=None):
463465
submission.state = DraftSubmissionStateName.objects.get(slug="manual")
464466
submission.save()
465467

468+
formal_languages_changed = False
469+
if set(submission.formal_languages.all()) != set(edit_form.cleaned_data["formal_languages"]):
470+
submission.formal_languages = edit_form.cleaned_data["formal_languages"]
471+
formal_languages_changed = True
472+
466473
send_manual_post_request(request, submission, errors)
467474

468-
changed_fields = [
475+
changed_fields += [
469476
submission._meta.get_field(f).verbose_name
470477
for f in list(edit_form.fields.keys()) + ["submitter", "authors"]
471-
if getattr(submission, f) != getattr(prev_submission, f)
478+
if (f == "formal_languages" and formal_languages_changed)
479+
or getattr(submission, f) != getattr(prev_submission, f)
472480
]
473481

474482
if changed_fields:

ietf/templates/submit/submission_status.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ <h2>Meta-data from the submission</h2>
229229
<th>File size</th>
230230
<td>{{ submission.file_size|filesizeformat }}</td>
231231
</tr>
232+
233+
<tr>
234+
<th>Formal languages used</th>
235+
<td>
236+
{% for l in submission.formal_languages.all %}{{ l.name }}{% if not forloop.last %}, {% endif %}{% empty %}None{% endfor %}
237+
{% if errors.formal_languages %}<p class="text-danger"><b>{{ errors.formal_languages }}</b></p>{% endif %}
238+
</td>
239+
</tr>
232240
</table>
233241

234242
{% if can_edit %}

0 commit comments

Comments
 (0)