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
This commit is contained in:
Ole Laursen 2017-01-17 13:52:16 +00:00
parent f4555c4269
commit 76bcab6efc
7 changed files with 48 additions and 7 deletions

View file

@ -21,6 +21,7 @@ from ietf.doc.fields import SearchableDocAliasesField
from ietf.ipr.mail import utc_from_string
from ietf.meeting.models import Meeting
from ietf.message.models import Message
from ietf.name.models import FormalLanguageName
from ietf.submit.models import Submission, Preapproval
from ietf.submit.utils import validate_submission_rev, validate_submission_document_date
from ietf.submit.parsers.pdf_parser import PDFParser
@ -376,13 +377,14 @@ class EditSubmissionForm(forms.ModelForm):
rev = forms.CharField(label=u'Revision', max_length=2, required=True)
document_date = forms.DateField(required=True)
pages = forms.IntegerField(required=True)
formal_languages = forms.ModelMultipleChoiceField(queryset=FormalLanguageName.objects.filter(used=True), widget=forms.CheckboxSelectMultiple, required=False)
abstract = forms.CharField(widget=forms.Textarea, required=True)
note = forms.CharField(label=mark_safe(u'Comment to the Secretariat'), widget=forms.Textarea, required=False)
class Meta:
model = Submission
fields = ['title', 'rev', 'document_date', 'pages', 'abstract', 'note']
fields = ['title', 'rev', 'document_date', 'pages', 'formal_languages', 'abstract', 'note']
def clean_rev(self):
rev = self.cleaned_data["rev"]

View file

@ -61,8 +61,10 @@ Internet-Draft Testing Tests %(month)s %(year)s
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Security Considerations . . . . . . . . . . . . . . . . . . . 2
3. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 2
2. Yang . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. JSON example . . . . . . . . . . . . . . . . . . . . . . . . 2
4. Security Considerations . . . . . . . . . . . . . . . . . . . 2
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 2
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 2
1. Introduction
@ -169,11 +171,19 @@ Table of Contents
<CODE ENDS>
3. Security Considerations
3. JSON example
The JSON object should look like this:
{
"test": 1234
}
4. Security Considerations
There are none.
4. IANA Considerations
5. IANA Considerations
No new registrations for IANA.

View file

@ -137,6 +137,15 @@ module ietf-mpls {
</figure>
</section>
<section anchor="JSON" title="JSON example">
<t>
The JSON object should look like this:
{
"test": 1234
}
</t>
</section>
<section anchor="Security" title="Security Considerations">
<t>
There are none.

View file

@ -18,6 +18,7 @@ from ietf.group.models import Group
from ietf.group.utils import setup_default_community_list_for_group
from ietf.meeting.models import Meeting
from ietf.message.models import Message
from ietf.name.models import FormalLanguageName
from ietf.person.models import Person, Email
from ietf.person.factories import UserFactory, PersonFactory
from ietf.submit.models import Submission, Preapproval
@ -251,6 +252,7 @@ class SubmitTests(TestCase):
self.assertEqual(draft.authors.count(), 1)
self.assertEqual(draft.authors.all()[0].get_name(), "Author Name")
self.assertEqual(draft.authors.all()[0].address, "author@example.com")
self.assertEqual(set(draft.formal_languages.all()), set(FormalLanguageName.objects.filter(slug="json")))
self.assertEqual(draft.relations_that_doc("replaces").count(), 1)
self.assertTrue(draft.relations_that_doc("replaces").first().target, replaced_alias)
self.assertEqual(draft.relations_that_doc("possibly-replaces").count(), 1)

View file

@ -253,6 +253,8 @@ def post_submission(request, submission, approvedDesc):
update_authors(draft, submission)
draft.formal_languages = submission.formal_languages.all()
trouble = rebuild_reference_relations(draft, filename=os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.txt' % (submission.name, submission.rev)))
if trouble:
log('Rebuild_reference_relations trouble: %s'%trouble)

View file

@ -449,6 +449,8 @@ def edit_submission(request, submission_id, access_token=None):
# trigger validation of all forms
validations = [edit_form.is_valid(), submitter_form.is_valid(), replaces_form.is_valid()] + [ f.is_valid() for f in author_forms ]
if all(validations):
changed_fields = []
submission.submitter = submitter_form.cleaned_line()
replaces = replaces_form.cleaned_data.get("replaces", [])
submission.replaces = ",".join(o.name for o in replaces)
@ -463,12 +465,18 @@ def edit_submission(request, submission_id, access_token=None):
submission.state = DraftSubmissionStateName.objects.get(slug="manual")
submission.save()
formal_languages_changed = False
if set(submission.formal_languages.all()) != set(edit_form.cleaned_data["formal_languages"]):
submission.formal_languages = edit_form.cleaned_data["formal_languages"]
formal_languages_changed = True
send_manual_post_request(request, submission, errors)
changed_fields = [
changed_fields += [
submission._meta.get_field(f).verbose_name
for f in list(edit_form.fields.keys()) + ["submitter", "authors"]
if getattr(submission, f) != getattr(prev_submission, f)
if (f == "formal_languages" and formal_languages_changed)
or getattr(submission, f) != getattr(prev_submission, f)
]
if changed_fields:

View file

@ -229,6 +229,14 @@
<th>File size</th>
<td>{{ submission.file_size|filesizeformat }}</td>
</tr>
<tr>
<th>Formal languages used</th>
<td>
{% for l in submission.formal_languages.all %}{{ l.name }}{% if not forloop.last %}, {% endif %}{% empty %}None{% endfor %}
{% if errors.formal_languages %}<p class="text-danger"><b>{{ errors.formal_languages }}</b></p>{% endif %}
</td>
</tr>
</table>
{% if can_edit %}