Changed draft submission to not require an email round-trip when the submitter is logged in. Added corresponding test cases.
- Legacy-Id: 16749
This commit is contained in:
parent
466bd0675e
commit
3939c0b88c
|
@ -68,8 +68,10 @@ def submission_file(name, rev, group, format, templatename, author=None, email=N
|
|||
name="%s-%s" % (name, rev),
|
||||
group=group or "",
|
||||
author=author.ascii if ascii else author.name,
|
||||
asciiAuthor=author.ascii,
|
||||
initials=author.initials(),
|
||||
surname=author.ascii_parts()[3] if ascii else author.name_parts()[3],
|
||||
asciiSurname=author.ascii_parts()[3],
|
||||
email=email,
|
||||
title=title,
|
||||
)
|
||||
|
@ -158,7 +160,7 @@ class SubmitTests(TestCase):
|
|||
submission = Submission.objects.get(name=name)
|
||||
if len(submission.authors) != 1:
|
||||
sys.stderr.write("\nAuthor extraction failure.\n")
|
||||
sys.stderr.write(("Author name used in test: %s\n"%author).encode('utf8'))
|
||||
sys.stderr.write(six.ensure_text("Author name used in test: %s\n"%author))
|
||||
sys.stderr.write("Author ascii name: %s\n" % author.ascii)
|
||||
sys.stderr.write("Author initials: %s\n" % author.initials())
|
||||
self.assertEqual(len(submission.authors), 1)
|
||||
|
@ -594,6 +596,51 @@ class SubmitTests(TestCase):
|
|||
def test_submit_new_individual_txt_xml(self):
|
||||
self.submit_new_individual(["txt", "xml"])
|
||||
|
||||
def submit_new_individual_logged_in(self, formats):
|
||||
# submit new -> supply submitter info -> done
|
||||
|
||||
name = "draft-authorname-testing-logged-in"
|
||||
rev = "00"
|
||||
group = None
|
||||
|
||||
author = PersonFactory()
|
||||
username = author.user.email
|
||||
self.client.login(username=username, password=username+"+password")
|
||||
|
||||
status_url, author = self.do_submission(name, rev, group, formats, author=author)
|
||||
|
||||
# supply submitter info, then draft should be be ready for email auth
|
||||
mailbox_before = len(outbox)
|
||||
r = self.supply_extra_metadata(name, status_url, author.name, username, replaces="")
|
||||
|
||||
self.assertEqual(r.status_code, 302)
|
||||
status_url = r["Location"]
|
||||
r = self.client.get(status_url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertContains(r, "New version accepted")
|
||||
|
||||
self.assertEqual(len(outbox), mailbox_before+2)
|
||||
announcement_email = outbox[-2]
|
||||
self.assertIn(name, announcement_email["Subject"])
|
||||
self.assertIn('I-D Action:', announcement_email["Subject"])
|
||||
self.assertIn('i-d-announce', announcement_email["To"])
|
||||
notification_email = outbox[-1]
|
||||
self.assertIn(name, notification_email["Subject"])
|
||||
self.assertIn("New Version Notification", notification_email["Subject"])
|
||||
self.assertIn(author.email().address.lower(), notification_email["To"])
|
||||
|
||||
draft = Document.objects.get(docalias__name=name)
|
||||
self.assertEqual(draft.rev, rev)
|
||||
new_revision = draft.latest_event()
|
||||
self.assertEqual(new_revision.type, "new_revision")
|
||||
self.assertEqual(new_revision.by.name, author.name)
|
||||
|
||||
def test_submit_new_logged_in_txt(self):
|
||||
self.submit_new_individual_logged_in(["txt"])
|
||||
|
||||
def test_submit_new_logged_in_xml(self):
|
||||
self.submit_new_individual_logged_in(["xml"])
|
||||
|
||||
def test_submit_update_individual(self):
|
||||
IndividualDraftFactory(name='draft-ietf-random-thing', states=[('draft','rfc')], other_aliases=['rfc9999',], pages=5)
|
||||
ad=Person.objects.get(user__username='ad')
|
||||
|
@ -1047,7 +1094,7 @@ class SubmitTests(TestCase):
|
|||
for e in author.email_set.all():
|
||||
e.delete()
|
||||
|
||||
files = {"txt": submission_file(name, rev, group, "txt", "test_submission.txt", author=author, ascii=False)[0] }
|
||||
files = {"txt": submission_file(name, rev, group, "txt", "test_submission.txt", author=author, ascii=True)[0] }
|
||||
|
||||
# submit
|
||||
url = urlreverse('ietf.submit.views.upload_submission')
|
||||
|
|
|
@ -653,6 +653,8 @@ def get_draft_meta(form, saved_files):
|
|||
if xml_version == '3':
|
||||
prep = xml2rfc.PrepToolWriter(form.xmltree, quiet=True)
|
||||
form.xmltree.tree = prep.prep()
|
||||
if form.xmltree.tree == None:
|
||||
raise ValidationError("Error from xml2rfc (prep): %s" % prep.errors)
|
||||
except Exception as e:
|
||||
raise ValidationError("Error from xml2rfc (prep): %s" % e)
|
||||
if not ('txt' in form.cleaned_data and form.cleaned_data['txt']):
|
||||
|
|
|
@ -34,7 +34,8 @@ from ietf.submit.models import (Submission, Preapproval,
|
|||
from ietf.submit.utils import ( approvable_submissions_for_user, preapprovals_for_user,
|
||||
recently_approved_by_user, validate_submission, create_submission_event, docevent_from_submission,
|
||||
post_submission, cancel_submission, rename_submission_files, remove_submission_files, get_draft_meta,
|
||||
get_submission, fill_in_submission, apply_checkers, send_confirmation_emails, save_files )
|
||||
get_submission, fill_in_submission, apply_checkers, send_confirmation_emails, save_files,
|
||||
get_person_from_name_email )
|
||||
from ietf.stats.utils import clean_country_name
|
||||
from ietf.utils.accesstoken import generate_access_token
|
||||
from ietf.utils.log import log
|
||||
|
@ -74,6 +75,8 @@ def upload_submission(request):
|
|||
form = SubmissionManualUploadForm(request=request)
|
||||
form._errors = {}
|
||||
form._errors["__all__"] = form.error_class(["There was a failure converting the xml file to text -- please verify that your xml file is valid. (%s)" % e.message])
|
||||
if debug.debug:
|
||||
raise
|
||||
else:
|
||||
form = SubmissionManualUploadForm(request=request)
|
||||
|
||||
|
@ -258,6 +261,7 @@ def submission_status(request, submission_id, access_token=None):
|
|||
submitter_form = SubmitterForm(request.POST, prefix="submitter")
|
||||
replaces_form = ReplacesForm(request.POST, name=submission.name)
|
||||
validations = [submitter_form.is_valid(), replaces_form.is_valid()]
|
||||
|
||||
if all(validations):
|
||||
submission.submitter = submitter_form.cleaned_line()
|
||||
replaces = replaces_form.cleaned_data.get("replaces", [])
|
||||
|
@ -276,13 +280,25 @@ def submission_status(request, submission_id, access_token=None):
|
|||
post_submission(request, submission, desc)
|
||||
create_submission_event(request, submission, desc)
|
||||
else:
|
||||
sent_to, desc, docDesc = send_confirmation_emails(request, submission, requires_group_approval, requires_prev_authors_approval)
|
||||
msg = "Set submitter to \"%s\", replaces to %s and %s" % (
|
||||
submission.submitter,
|
||||
", ".join(prettify_std_name(r.name) for r in replaces) if replaces else "(none)",
|
||||
desc)
|
||||
create_submission_event(request, submission, msg)
|
||||
docevent_from_submission(request, submission, docDesc, who="(System)")
|
||||
doc = submission.existing_document()
|
||||
prev_authors = [] if not doc else [ author.person for author in doc.documentauthor_set.all() ]
|
||||
curr_authors = [ get_person_from_name_email(author["name"], author.get("email")) for author in submission.authors ]
|
||||
|
||||
if request.user.is_authenticated and request.user.person in (prev_authors if prev_authors else curr_authors):
|
||||
# go directly to posting submission
|
||||
docevent_from_submission(request, submission, desc="Uploaded new revision", who=request.user.person)
|
||||
|
||||
desc = "New version accepted (logged-in submitter: %s)" % request.user.person
|
||||
post_submission(request, submission, desc)
|
||||
create_submission_event(request, submission, desc)
|
||||
else:
|
||||
sent_to, desc, docDesc = send_confirmation_emails(request, submission, requires_group_approval, requires_prev_authors_approval)
|
||||
msg = "Set submitter to \"%s\", replaces to %s and %s" % (
|
||||
submission.submitter,
|
||||
", ".join(prettify_std_name(r.name) for r in replaces) if replaces else "(none)",
|
||||
desc)
|
||||
create_submission_event(request, submission, msg)
|
||||
docevent_from_submission(request, submission, docDesc, who="(System)")
|
||||
|
||||
if access_token:
|
||||
return redirect("ietf.submit.views.submission_status", submission_id=submission.pk, access_token=access_token)
|
||||
|
|
Loading…
Reference in a new issue