From 44f42cdb3a52653daa9d44db6ba8436810fa92f4 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Fri, 20 Sep 2019 11:30:04 +0000 Subject: [PATCH] Undid the previous commit - Legacy-Id: 16735 --- changelog | 17 -------- ietf/doc/views_doc.py | 10 ++--- ietf/settings.py | 5 --- ietf/submit/forms.py | 5 +-- ietf/submit/test_submission.xml | 41 +++++++++++--------- ietf/submit/tests.py | 5 +-- ietf/submit/utils.py | 32 ++++----------- ietf/templates/submit/submission_status.html | 18 ++++----- 8 files changed, 46 insertions(+), 87 deletions(-) diff --git a/changelog b/changelog index 454303738..77a83ede2 100644 --- a/changelog +++ b/changelog @@ -1,20 +1,3 @@ -ietfdb (6.101.1) ietf; urgency=medium - - * Added a link from the datatracker RFC pages to the new RFC rendereings - with inline errata on the RFC-Editor webpage (where available). - - * Updated rfc-editor sync code to recognize the new Tooling Issue queue - state. - - * Updated ietf.sync.rfceditor.parse_index() to use the new rfc-index - schema (changed placement of the page-count element). - - * Added code to catch a form error regularly caused by form spam and - return a failure instead of triggering a server 500. - - -- Henrik Levkowetz 15 Sep 2019 11:35:29 +0000 - - ietfdb (6.101.0) ietf; urgency=medium **IANA expert review tracking, new constraints labelling** diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 93e80d663..1aa240af2 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -206,7 +206,7 @@ def document_main(request, name, rev=None): # file types base_path = os.path.join(settings.RFC_PATH, name + ".") - possible_types = settings.RFC_FILE_TYPES + possible_types = ["txt", "pdf", "ps"] found_types = [t for t in possible_types if os.path.exists(base_path + t)] base = "https://www.rfc-editor.org/rfc/" @@ -220,7 +220,7 @@ def document_main(request, name, rev=None): file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf")) if "txt" in found_types: - file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + name)) + file_urls.append(("html", settings.TOOLS_ID_HTML_URL + name)) if doc.tags.filter(slug="errata"): file_urls.append(("with errata", settings.RFC_EDITOR_INLINE_ERRATA_URL.format(rfc_number=rfc_number))) @@ -236,8 +236,8 @@ def document_main(request, name, rev=None): # file types base_path = os.path.join(settings.INTERNET_DRAFT_PATH, doc.name + "-" + doc.rev + ".") - possible_types = settings.IDSUBMIT_FILE_TYPES - found_types = [t for t in possible_types if os.path.exists(base_path + t)] + possible_types = ["pdf", "xml", "ps"] + found_types = ["txt"] + [t for t in possible_types if os.path.exists(base_path + t)] if not snapshot and doc.get_state_slug() == "active": base = settings.IETF_ID_URL @@ -251,7 +251,7 @@ def document_main(request, name, rev=None): if "pdf" not in found_types: file_urls.append(("pdf", settings.TOOLS_ID_PDF_URL + doc.name + "-" + doc.rev + ".pdf")) - file_urls.append(("htmlized", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev)) + file_urls.append(("html", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev)) # latest revision latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision") diff --git a/ietf/settings.py b/ietf/settings.py index e89ee42b6..70f241282 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -780,20 +780,15 @@ IDSUBMIT_CHECKER_CLASSES = ( IDSUBMIT_MANUAL_STAGING_DIR = '/tmp/' - IDSUBMIT_FILE_TYPES = ( 'txt', - 'html', 'xml', 'pdf', 'ps', ) -RFC_FILE_TYPES = IDSUBMIT_FILE_TYPES - IDSUBMIT_MAX_DRAFT_SIZE = { 'txt': 2*1024*1024, # Max size of txt draft file in bytes 'xml': 3*1024*1024, # Max size of xml draft file in bytes - 'html': 4*1024*1024, 'pdf': 6*1024*1024, 'ps' : 6*1024*1024, } diff --git a/ietf/submit/forms.py b/ietf/submit/forms.py index 8c93cc65a..8e12ce676 100644 --- a/ietf/submit/forms.py +++ b/ietf/submit/forms.py @@ -352,15 +352,12 @@ class SubmissionBaseUploadForm(forms.Form): class SubmissionManualUploadForm(SubmissionBaseUploadForm): xml = forms.FileField(label='.xml format', required=False) # xml field with required=False instead of True txt = forms.FileField(label='.txt format', required=False) - # We won't permit html upload until we can verify that the content - # reasonably matches the text and/or xml upload: - # html = forms.FileField(label='.html format', required=False) pdf = forms.FileField(label='.pdf format', required=False) ps = forms.FileField(label='.ps format', required=False) def __init__(self, request, *args, **kwargs): super(SubmissionManualUploadForm, self).__init__(request, *args, **kwargs) - self.formats = settings.IDSUBMIT_FILE_TYPES + self.formats = ['txt', 'pdf', 'xml', 'ps', ] self.base_formats = ['txt', 'xml', ] def clean_txt(self): diff --git a/ietf/submit/test_submission.xml b/ietf/submit/test_submission.xml index 5c05ffc16..c147589b6 100644 --- a/ietf/submit/test_submission.xml +++ b/ietf/submit/test_submission.xml @@ -1,13 +1,12 @@ - - + + - - + %(title)s - Test Centre Inc. +
42 Some Road @@ -17,7 +16,7 @@ %(email)s
- + %(group)s @@ -25,16 +24,18 @@
+ -
- Introduction +
This document describes a protocol for testing tests.
-
- Yang - +
+ + file "ietf-yang-metadata@2016-08-05.yang" module ietf-yang-metadata { @@ -121,10 +122,13 @@ module ietf-yang-metadata { } } -]]> + + ]]> + +
-
- JSON example + +
The JSON object should look like this: @@ -133,18 +137,17 @@ module ietf-yang-metadata { }
-
- Security Considerations +
There are none.
-
- IANA Considerations +
No new registrations for IANA.
- + + diff --git a/ietf/submit/tests.py b/ietf/submit/tests.py index 4a7e55eff..d87d73885 100644 --- a/ietf/submit/tests.py +++ b/ietf/submit/tests.py @@ -64,7 +64,6 @@ def submission_file(name, rev, group, format, templatename, author=None, email=N expiration=(datetime.date.today() + datetime.timedelta(days=100)).strftime("%d %B, %Y"), year=year, month=datetime.date.today().strftime("%B"), - day=datetime.date.today().strftime("%d"), name="%s-%s" % (name, rev), group=group or "", author=author.ascii if ascii else author.name, @@ -152,8 +151,6 @@ class SubmitTests(TestCase): status_url = r["Location"] for format in formats: self.assertTrue(os.path.exists(os.path.join(self.staging_dir, "%s-%s.%s" % (name, rev, format)))) - if format == 'xml': - self.assertTrue(os.path.exists(os.path.join(self.staging_dir, "%s-%s.%s" % (name, rev, 'html')))) self.assertEqual(Submission.objects.filter(name=name).count(), 1) submission = Submission.objects.get(name=name) if len(submission.authors) != 1: @@ -1687,7 +1684,7 @@ class ApiSubmitTests(TestCase): self.assertContains(r, expected, status_code=400) def test_api_submit_failed_idnits(self): - r, author, name = self.post_submission('00', year="2010") + r, author, name = self.post_submission('00', year="1900") expected = "Document date must be within 3 days of submission date" self.assertContains(r, expected, status_code=400) diff --git a/ietf/submit/utils.py b/ietf/submit/utils.py index 07c510db2..37ddc1f2b 100644 --- a/ietf/submit/utils.py +++ b/ietf/submit/utils.py @@ -528,14 +528,16 @@ def cancel_submission(submission): remove_submission_files(submission) def rename_submission_files(submission, prev_rev, new_rev): - for ext in settings.IDSUBMIT_FILE_TYPES: + from ietf.submit.forms import SubmissionManualUploadForm + for ext in list(SubmissionManualUploadForm.base_fields.keys()): source = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.%s' % (submission.name, prev_rev, ext)) dest = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.%s' % (submission.name, new_rev, ext)) if os.path.exists(source): os.rename(source, dest) def move_files_to_repository(submission): - for ext in settings.IDSUBMIT_FILE_TYPES: + from ietf.submit.forms import SubmissionManualUploadForm + for ext in list(SubmissionManualUploadForm.base_fields.keys()): source = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.%s' % (submission.name, submission.rev, ext)) dest = os.path.join(settings.IDSUBMIT_REPOSITORY_PATH, '%s-%s.%s' % (submission.name, submission.rev, ext)) if os.path.exists(source): @@ -621,21 +623,17 @@ def get_draft_meta(form, saved_files): abstract = None file_size = None if form.cleaned_data['xml']: - try: - xmlroot = form.xmltree.getroot() - xml_version = xmlroot.get('version', '2') - if xml_version == '3': - prep = xml2rfc.PrepToolWriter(form.xmltree, quiet=True) - form.xmltree.tree = prep.prep() - except Exception as e: - raise ValidationError("Error from xml2rfc: %s" % e) if not ('txt' in form.cleaned_data and form.cleaned_data['txt']): file_name['txt'] = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.txt' % (form.filename, form.revision)) try: + xmlroot = form.xmltree.getroot() + xml_version = xmlroot.get('version', '2') if xml_version != '3': pagedwriter = xml2rfc.PaginatedTextRfcWriter(form.xmltree, quiet=True) pagedwriter.write(file_name['txt']) else: + prep = xml2rfc.PrepToolWriter(form.xmltree, quiet=True) + form.xmltree.tree = prep.prep() writer = xml2rfc.TextWriter(form.xmltree, quiet=True) writer.write(file_name['txt']) log.log("In %s: xml2rfc %s generated %s from %s (version %s)" % @@ -647,20 +645,6 @@ def get_draft_meta(form, saved_files): except Exception as e: raise ValidationError("Error from xml2rfc: %s" % e) file_size = os.stat(file_name['txt']).st_size - try: - if xml_version == '3': - file_name['html'] = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s.html' % (form.filename, form.revision)) - writer = xml2rfc.HtmlWriter(form.xmltree, quiet=True) - writer.write(file_name['html']) - form.file_types.append('.html') - log.log("In %s: xml2rfc %s generated %s from %s (version %s)" % - ( os.path.dirname(file_name['xml']), - xml2rfc.__version__, - os.path.basename(file_name['html']), - os.path.basename(file_name['xml']), - xml_version)) - except Exception as e: - raise ValidationError("Error from xml2rfc: %s" % e) # Some meta-information, such as the page-count, can only # be retrieved from the generated text file. Provide a # parsed draft object to get at that kind of information. diff --git a/ietf/templates/submit/submission_status.html b/ietf/templates/submit/submission_status.html index 981de304c..ee2f1ad41 100644 --- a/ietf/templates/submit/submission_status.html +++ b/ietf/templates/submit/submission_status.html @@ -152,7 +152,7 @@ {% show_submission_files submission %} {% if errors.files %} -

{{ errors.files|safe }}

+

{{ errors.files|safe }}

{% endif %} @@ -164,7 +164,7 @@ {% if errors.rev %} -

{{ errors.rev }}

+

{{ errors.rev }}

{% endif %} @@ -174,7 +174,7 @@ {{ submission.group|default:"Individual Submission" }} {% if errors.group %} -

{{ errors.group }}

+

{{ errors.group }}

{% endif %} @@ -184,7 +184,7 @@ {{ submission.document_date }} {% if errors.document_date %} -

{{ errors.document_date }}

+

{{ errors.document_date }}

{% endif %} @@ -198,7 +198,7 @@ Title {{ submission.title|default:"" }} - {% if errors.title %}

{{ errors.title }}

{% endif %} + {% if errors.title %}

{{ errors.title }}

{% endif %} @@ -206,7 +206,7 @@ Authors {{ submission.authors|length }} author{{ submission.authors|pluralize }} - {% if errors.authors %}

{{ errors.authors|safe }}

{% endif %} + {% if errors.authors %}

{{ errors.authors|safe }}

{% endif %} @@ -244,7 +244,7 @@ Abstract {{ submission.abstract|linebreaksbr }} - {% if errors.abstract %}

{{ errors.abstract }}

{% endif %} + {% if errors.abstract %}

{{ errors.abstract }}

{% endif %} @@ -252,7 +252,7 @@ Pages {{ submission.pages }} - {% if errors.pages %}

{{ errors.pages }}

{% endif %} + {% if errors.pages %}

{{ errors.pages }}

{% endif %} @@ -265,7 +265,7 @@ Formal languages used {% for l in submission.formal_languages.all %}{{ l.name }}{% if not forloop.last %}, {% endif %}{% empty %}None recognized{% endfor %} - {% if errors.formal_languages %}

{{ errors.formal_languages }}

{% endif %} + {% if errors.formal_languages %}

{{ errors.formal_languages }}

{% endif %}