Repository: ietf-tools/datatracker

Issue:
Dragdrop handles appear on session detail page even when not logged in
At views like https://datatracker.ietf.org/meeting/115/session/stir, if the user doesn't have permission to change the slide order, the handles and tooltips for the handles should not be in the html.


Discussion:

Resolving patch:
diff --git a/ietf/person/factories.py b/ietf/person/factories.py
--- a/ietf/person/factories.py
+++ b/ietf/person/factories.py
@@ -65,7 +65,10 @@ class Meta:
 
     user = factory.SubFactory(UserFactory)
     name = factory.LazyAttribute(lambda p: normalize_name('%s %s'%(p.user.first_name, p.user.last_name)))
-    ascii = factory.LazyAttribute(lambda p: force_text(unidecode_name(p.name)))
+    # Some i18n names, e.g., "शिला के.सी." have a dot at the end that is also part of the ASCII, e.g., "Shilaa Kesii."
+    # That trailing dot breaks extract_authors(). Avoid this issue by stripping the dot from the ASCII.
+    # Some others have a trailing semicolon (e.g., "உயிரோவியம் தங்கராஐ;") - strip those, too.
+    ascii = factory.LazyAttribute(lambda p: force_text(unidecode_name(p.name)).rstrip(".;"))
 
     class Params:
         with_bio = factory.Trait(biography = "\n\n".join(fake.paragraphs())) # type: ignore
diff --git a/ietf/utils/draft.py b/ietf/utils/draft.py
--- a/ietf/utils/draft.py
+++ b/ietf/utils/draft.py
@@ -592,8 +592,8 @@ def extract_authors(self):
             "honor" : r"(?:[A-Z]\.|Dr\.?|Dr\.-Ing\.|Prof(?:\.?|essor)|Sir|Lady|Dame|Sri)",
             "prefix": r"([Dd]e|Hadi|van|van de|van der|Ver|von|[Ee]l)",
             "suffix": r"(jr.?|Jr.?|II|2nd|III|3rd|IV|4th)",
-            "first" : r"([A-Z][-A-Za-z'`~]*)(( ?\([A-Z][-A-Za-z'`~]*\))?(\.?[- ]{1,2}[A-Za-z'`~]+)*)",
-            "last"  : r"([-A-Za-z'`~]{2,})",
+            "first" : r"([A-Z][-A-Za-z'`~,]*)(( ?\([A-Z][-A-Za-z'`~,]*\))?(\.?[- ]{1,2}[A-Za-z'`~]+)*)",
+            "last"  : r"([-A-Za-z'`~,]+)",  # single-letter last names exist
             "months": r"(January|February|March|April|May|June|July|August|September|October|November|December)",
             "mabbr" : r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.?",
             }
@@ -658,7 +658,12 @@ def dotexp(s):
 
             # permit insertion of middle names between first and last, and
             # add possible honorific and suffix information
-            authpat = r"(?:^| and )(?:%(hon)s ?)?(['`]*%(first)s\S*( +[^ ]+)* +%(last)s)( *\(.*|,( [A-Z][-A-Za-z0-9]*)?| %(suffix)s| [A-Z][a-z]+)?" % {"hon":hon, "first":first, "last":last, "suffix":suffix,}
+            if last:
+                authpat = r"(?:^| and )((?:%(hon)s ?)?['`]*%(first)s\S*( +[^ ]+)* +%(last)s(?: %(suffix)s)?)( *\(.*|,( [A-Z][-A-Za-z0-9]*)?| [A-Z][a-z]+)?" % {"hon":hon, "first":first, "last":last, "suffix":suffix,}
+            else:
+                # handle single-word names
+                authpat = r"(?:^| and )((?:%(hon)s ?)?['`]*%(first)s\S*( +[^ ]+)*(?: %(suffix)s)?)( *\(.*|,( [A-Z][-A-Za-z0-9]*)?| [A-Z][a-z]+)?" % {"hon":hon, "first":first, "suffix":suffix,}
+
             return authpat
 
         authors = []
@@ -812,7 +817,7 @@ def dotexp(s):
                 author = author[:-len(suffix)].strip()
             else:
                 suffix = None
-            if "," in author:
+            if ", " in author:
                 last, first = author.split(",",1)
                 author = "%s %s" % (first.strip(), last.strip())
             if not " " in author:
@@ -820,8 +825,9 @@ def dotexp(s):
                     first, last = author.rsplit(".", 1)
                     first += "."
                 else:
-                    author = "[A-Z].+ " + author
-                    first, last = author.rsplit(" ", 1)
+                    # handle single-word names
+                    first = author
+                    last = ""
             else:
                 if "." in author:
                     first, last = author.rsplit(".", 1)
@@ -899,10 +905,14 @@ def dotexp(s):
                                                 #else:
                                                 #    fullname = author_match
                                                 fullname = re.sub(" +", " ", fullname)
-                                                if left == firstname:
-                                                    given_names, surname = fullname.rsplit(None, 1)
+                                                if re.search(r"\s", fullname):
+                                                    if left == firstname:
+                                                        given_names, surname = fullname.rsplit(None, 1)
+                                                    else:
+                                                        surname, given_names = fullname.split(None, 1)
                                                 else:
-                                                    surname, given_names = fullname.split(None, 1)
+                                                    # handle single-word names
+                                                    given_names, surname = (fullname, "")
                                                 if " " in given_names:
                                                     first, middle = given_names.split(None, 1)
                                                 else:


Test patch:
diff --git a/ietf/submit/test_submission.txt b/ietf/submit/test_submission.txt
--- a/ietf/submit/test_submission.txt
+++ b/ietf/submit/test_submission.txt
@@ -2,7 +2,7 @@
 
 
 
-Network Working Group                                            %(initials)s %(surname)s
+Network Working Group             %(firstpagename)37s
 Internet-Draft                                          Test Centre Inc.
 Intended status: Informational                                %(month)s %(year)s
 Expires: %(expiration)s
@@ -10,7 +10,6 @@ Expires: %(expiration)s
 
                              %(title)s
                          %(name)s
-
 Abstract
 
    This document describes how to test tests.
diff --git a/ietf/submit/tests.py b/ietf/submit/tests.py
--- a/ietf/submit/tests.py
+++ b/ietf/submit/tests.py
@@ -107,6 +107,10 @@ def submission_file(name_in_doc, name_in_post, group, templatename, author=None,
     if year is None:
         year = _today.strftime("%Y")
 
+    # extract_authors() cuts the author line off at the first space past 80 characters
+    # very long factory-generated names can hence be truncated, causing a failure
+    # ietf/submit/test_submission.txt was changed so that 37-character names and shorter will work
+    # this may need further adjustment if longer names still cause failures
     submission_text = template % dict(
             date=_today.strftime("%d %B %Y"),
             expiration=(_today + datetime.timedelta(days=100)).strftime("%d %B, %Y"),
@@ -119,6 +123,7 @@ def submission_file(name_in_doc, name_in_post, group, templatename, author=None,
             asciiAuthor=author.ascii,
             initials=author.initials(),
             surname=author.ascii_parts()[3] if ascii else author.name_parts()[3],
+            firstpagename=f"{author.initials()} {author.ascii_parts()[3] if ascii else author.name_parts()[3]}",
             asciiSurname=author.ascii_parts()[3],
             email=email,
             title=title,