internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ietf-tools/datatracker

Issue:
Race condition when submitting a completed review
### Describe the issue

If a review is posted to `/doc/<draft name>/reviewrequest/<request id>/complete/` more than once, a server error may occur instead of a more helpful outcome. This situation should give meaningful feedback, even if that's just instructions to ask for help out of band.

The offending code is in `doc/views_review.py` near line 715
```
                if not Document.objects.filter(name=review_name).exists():
                    review = Document.objects.create(name=review_name,type_id='review',group=team)
                    DocAlias.objects.create(name=review_name).docs.add(review)
                else:
```
This needs to deal with the possibility that a review does not exist when the `.exists()` test is made but does exist when `.create()` is called.

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/views_review.py b/ietf/doc/views_review.py
--- a/ietf/doc/views_review.py
+++ b/ietf/doc/views_review.py
@@ -711,8 +711,11 @@ def complete_review(request, name, assignment_id=None, acronym=None):
                     date_today().isoformat(),
                 ]
                 review_name = "-".join(c for c in name_components if c).lower()
-                if not Document.objects.filter(name=review_name).exists():
-                    review = Document.objects.create(name=review_name,type_id='review',group=team)
+                review, created = Document.objects.get_or_create(
+                    name=review_name,
+                    defaults={'type_id': 'review', 'group': team},
+                )
+                if created:
                     DocAlias.objects.create(name=review_name).docs.add(review)
                 else:
                     messages.warning(request, message='Attempt to save review failed: review document already exists. This most likely occurred because the review was submitted twice in quick succession. If you intended to submit a new review, rather than update an existing one, things are probably OK. Please verify that the shown review is what you expected.')


Test patch:
Repository: ietf-tools/datatracker

Issue:
PDF pagination (still?) broken
### Describe the issue

The page breaks on the PDF of draft-ietf-idr-bgp-ls-flex-algo-09 are a hot mess. This has been true of all the PDFized drafts I've looked at lately, but I was hoping it was only on older ones. Nope, this one is dated July 23, 2022.

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:
This will hopefully be fixed by #4082
Duplicate of #4331 
@jgscudder could you recheck the current version?
@larseggert it's less bad than it was, but the example I looked at, https://datatracker.ietf.org/doc/pdf/draft-ietf-idr-rfc7752bis-14 , still has wrong pagination. :-( In this case page 17 spills onto page 18, page 19 onto page 20, page 30 onto page 31, and so on.

I guess "hot mess" doesn't apply any more though :-) it's just extra pages that have nothing but a footer on them, now.
Ah! The CSS font for the 4th-level headings is too big. Will fix.

Resolving patch:
diff --git a/ietf/doc/models.py b/ietf/doc/models.py
--- a/ietf/doc/models.py
+++ b/ietf/doc/models.py
@@ -618,7 +618,6 @@ def pdfized(self):
             stylesheets.append(finders.find("ietf/css/document_html_txt.css"))
         else:
             text = self.htmlized()
-            stylesheets.append(io.BytesIO(b"body { font-size: 9.2pt; }"))
 
         cache = caches["pdfized"]
         cache_key = name.split(".")[0]


Test patch:
Repository: ietf-tools/datatracker

Issue:
htmlized doc view failing to reverse bibtex URL for some rfcs
### Describe the issue

Retrieving `/doc/html/fyi5` or `/doc/html/fyi27` from production or the sandbox fails with a reverse lookup failure. The former fails with
```
Reverse for 'ietf.doc.views_doc.document_bibtex' with keyword arguments '{'name': 'rfc1178', 'rev': ''}' not found. 1 pattern(s) tried: ['doc/(?P<name>[A-Za-z0-9._+-]+?)(?:/(?P<rev>[0-9]{1,2}(-[0-9]{2})?))?/bibtex/$']
```
The problem is apparently that it is asking for a blank rev- if I leave out the rev parameter entirely, the reverse goes through.

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py
--- a/ietf/doc/views_doc.py
+++ b/ietf/doc/views_doc.py
@@ -162,7 +162,7 @@ def document_main(request, name, rev=None, document_html=False):
     snapshot = False
 
     gh = None
-    if rev != None:
+    if rev:
         # find the entry in the history
         for h in doc.history_set.order_by("-time"):
             if rev == h.rev:


Test patch:
Repository: ietf-tools/datatracker

Issue:
OAuth 2.1 links show OAuth 2.0 (Problem with drafts with version numbers in the name)
### Describe the issue

The links to OAuth 2.1 are now returning the OAuth 2.0 spec. It looks like the `-1` in the URL is being completely ignored. This seems to have changed relatively recently.

https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-07

<img width="1299" alt="image" src="https://user-images.githubusercontent.com/113001/206581066-d13f363e-a27f-40d9-aace-7b8e1e5036c1.png">

Previously this was showing version -07 of the OAuth 2.1 draft. https://web.archive.org/web/20221109125705/https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-07

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)
OAuth 2.1 links show OAuth 2.0 (Problem with drafts with version numbers in the name)
### Describe the issue

The links to OAuth 2.1 are now returning the OAuth 2.0 spec. It looks like the `-1` in the URL is being completely ignored. This seems to have changed relatively recently.

https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-07

<img width="1299" alt="image" src="https://user-images.githubusercontent.com/113001/206581066-d13f363e-a27f-40d9-aace-7b8e1e5036c1.png">

Previously this was showing version -07 of the OAuth 2.1 draft. https://web.archive.org/web/20221109125705/https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-07

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py
--- a/ietf/doc/views_doc.py
+++ b/ietf/doc/views_doc.py
@@ -810,22 +810,20 @@ def document_html(request, name, rev=None):
     if num_found > 1:
         raise Http404("Multiple documents matched: %s" % name)
 
-    if found.matched_name.startswith('rfc') and name != found.matched_name:
-         return redirect('ietf.doc.views_doc.document_html', name=found.matched_name)
-
     doc = found.documents.get()
+    rev = found.matched_rev
+
+    if doc.is_rfc() and rev is None:
+        if not name.startswith('rfc'):
+            return redirect('ietf.doc.views_doc.document_html', name=doc.canonical_name())
 
-    if found.matched_rev or found.matched_name.startswith('rfc'):
-        rev = found.matched_rev
-    else:
-        rev = doc.rev
     if rev:
         doc = doc.history_set.filter(rev=rev).first() or doc.fake_history_obj(rev)
 
     if not os.path.exists(doc.get_file_name()):
         raise Http404("File not found: %s" % doc.get_file_name())
 
-    return document_main(request, name, rev=rev, document_html=True)
+    return document_main(request, name=doc.name, rev=doc.rev if not doc.is_rfc() else None, document_html=True)
 
 def document_pdfized(request, name, rev=None, ext=None):
 


Test patch:
Repository: ietf-tools/datatracker

Issue:
Wrapping issues in ballot modal on narrow screens
### Describe the issue

<img width="582" alt="Screenshot 2022-12-15 at 18 02 42" src="https://user-images.githubusercontent.com/200328/207908976-51568fb5-a3b4-4ccc-8026-8065d13da38d.png">


### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/doc/templatetags/ballot_icon.py b/ietf/doc/templatetags/ballot_icon.py
--- a/ietf/doc/templatetags/ballot_icon.py
+++ b/ietf/doc/templatetags/ballot_icon.py
@@ -140,7 +140,7 @@ def sort_key(t):
         i = i + 1
 
     res.append("</tr></tbody></table></a>")
-    res.append('<div id="modal-%d" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog modal-dialog-scrollable modal-xl"><div class="modal-content"></div></div></div>' % ballot.pk)
+    res.append('<div id="modal-%d" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog modal-dialog-scrollable modal-xl modal-fullscreen-lg-down"><div class="modal-content"></div></div></div>' % ballot.pk)
 
     return mark_safe("".join(res))
 


Test patch:
diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py
--- a/ietf/doc/tests.py
+++ b/ietf/doc/tests.py
@@ -1701,7 +1701,7 @@ def test_document_ballot_popup_unique_anchors_per_doc(self):
             href = q(f'div.balloter-name a[href$="{author_slug}"]').attr('href')
             ids = [
                 target.attr('id')
-                for target in q(f'p.h5[id$="{author_slug}"]').items()
+                for target in q(f'div.h5[id$="{author_slug}"]').items()
             ]
             self.assertEqual(len(ids), 1, 'Should be exactly one link for the balloter')
             self.assertEqual(href, f'#{ids[0]}', 'Anchor href should match ID')
diff --git a/ietf/doc/tests_ballot.py b/ietf/doc/tests_ballot.py
--- a/ietf/doc/tests_ballot.py
+++ b/ietf/doc/tests_ballot.py
@@ -1198,9 +1198,9 @@ def test_ballotpositiondocevent_any_email_sent(self):
         )
 
     def _assertBallotMessage(self, q, balloter, expected):
-        heading = q(f'p.h5[id$="_{slugify(balloter.plain_name())}"]')
+        heading = q(f'div.h5[id$="_{slugify(balloter.plain_name())}"]')
         self.assertEqual(len(heading), 1)
-        # <p.h5/> is followed by a panel with the message of interest, so use next()
+        # <div.h5> is followed by a panel with the message of interest, so use next()
         self.assertEqual(
             len(heading.next().find(
                 f'*[title="{expected}"]'
@@ -1381,4 +1381,4 @@ def test_document_ballot_content_without_send_email_values(self):
         q = PyQuery(content)
         self._assertBallotMessage(q, balloters[0], 'No email send requests for this discuss')
         self._assertBallotMessage(q, balloters[1], 'No ballot position send log available')
-        self._assertBallotMessage(q, old_balloter, 'No ballot position send log available')
\ No newline at end of file
+        self._assertBallotMessage(q, old_balloter, 'No ballot position send log available')
Repository: ietf-tools/datatracker

Issue:
Potential new `datetime` issues
### Describe the issue

See CI failures
* https://github.com/ietf-tools/datatracker/actions/runs/3899998769/jobs/6660186805
* https://github.com/ietf-tools/datatracker/actions/runs/3900011570/jobs/6660211516

There is also this one, which is different but possibly related:
* https://github.com/ietf-tools/datatracker/actions/runs/3900217767/jobs/6660629415

CC @jennifer-richards 

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:
I didn't encounter these during the recent release builds - are they transient or OBE?
Me neither. Transient.
I think it's probably real, the test is using a UTC date to compare with the deadline computed in `DEADLINE_TZINFO` (still PST8PDT). I'd have thought there was enough fuzz in the comparison, but it's easier to fix this than think super hard about that. Will do that now.

Resolving patch:
diff --git a/ietf/iesg/agenda.py b/ietf/iesg/agenda.py
--- a/ietf/iesg/agenda.py
+++ b/ietf/iesg/agenda.py
@@ -17,7 +17,7 @@
 from ietf.doc.utils_search import fill_in_telechat_date
 from ietf.iesg.models import TelechatDate, TelechatAgendaItem
 from ietf.review.utils import review_assignments_to_list_for_docs
-from ietf.utils.timezone import date_today
+from ietf.utils.timezone import date_today, make_aware
 
 def get_agenda_date(date=None):
     if not date:
@@ -26,8 +26,9 @@ def get_agenda_date(date=None):
         except IndexError:
             return date_today()
     else:
+        parsed_date = make_aware(datetime.datetime.strptime(date, "%Y-%m-%d"), settings.TIME_ZONE).date()
         try:
-            return TelechatDate.objects.active().get(date=datetime.datetime.strptime(date, "%Y-%m-%d").date()).date
+            return TelechatDate.objects.active().get(date=parsed_date).date
         except (ValueError, TelechatDate.DoesNotExist):
             raise Http404
 


Test patch:
Repository: ietf-tools/datatracker

Issue:
Possible timezone related failure
### Describe the issue

https://github.com/ietf-tools/datatracker/actions/runs/4071644533/jobs/7013629899

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/group/factories.py b/ietf/group/factories.py
--- a/ietf/group/factories.py
+++ b/ietf/group/factories.py
@@ -10,6 +10,8 @@
 from ietf.group.models import Group, Role, GroupEvent, GroupMilestone, \
                               GroupHistory, RoleHistory
 from ietf.review.factories import ReviewTeamSettingsFactory
+from ietf.utils.timezone import date_today
+
 
 class GroupFactory(factory.django.DjangoModelFactory):
     class Meta:
@@ -68,7 +70,7 @@ class Meta:
 
 class DatedGroupMilestoneFactory(BaseGroupMilestoneFactory):
     group = factory.SubFactory(GroupFactory, uses_milestone_dates=True)
-    due = timezone.now()+datetime.timedelta(days=180)
+    due = date_today() + datetime.timedelta(days=180)
 
 class DatelessGroupMilestoneFactory(BaseGroupMilestoneFactory):
     group = factory.SubFactory(GroupFactory, uses_milestone_dates=False)


Test patch:
Repository: ietf-tools/datatracker

Issue:
Proceedings ignores "notmeet" irtf sessions
### Describe the issue

PR #5005 inadvertently changed the handling of irtf sessions set as 'notmeet'. These are no longer shown on the proceedings. They are left off whether or not they have materials attached to them. Previously, the 'notmeet' flag was ignored for irtf sessions.

For IETF-115, this results in anrw and qirg not being listed on the proceedings.

Need to decide how to display these sessions (and whether they should be included in the first place).

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:
@csperkins - preference?
Research groups should appear in the proceedings listed as "did not meet" if they did not meet at a particular IETF. Research area groups (i.e., ANRW and IRTFOPEN, which I think are labelled differently in the datatracker) should not appear in the proceedings if they don't meet.


Resolving patch:
diff --git a/ietf/meeting/views.py b/ietf/meeting/views.py
--- a/ietf/meeting/views.py
+++ b/ietf/meeting/views.py
@@ -3688,9 +3688,13 @@ def proceedings(request, num=None):
         sessions.filter(name__icontains='plenary')
         .exclude(current_status='notmeet')
     )
-    irtf, _ = organize_proceedings_sessions(
+    irtf_meeting, irtf_not_meeting = organize_proceedings_sessions(
         sessions.filter(group__parent__acronym = 'irtf').order_by('group__acronym')
     )
+    # per Colin (datatracker #5010) - don't report not meeting rags
+    irtf_not_meeting = [item for item in irtf_not_meeting if item["group"].type_id != "rag"]
+    irtf = {"meeting_groups":irtf_meeting, "not_meeting_groups":irtf_not_meeting}
+
     training, _ = organize_proceedings_sessions(
         sessions.filter(group__acronym__in=['edu','iaoc'], type_id__in=['regular', 'other',])
         .exclude(current_status='notmeet')


Test patch:
Repository: ietf-tools/datatracker

Issue:
secr.middleware.dbquery.QueryCountDebugMiddleware is unused.
Is this still needed in the source tree? Can it be removed?
cc @rpcross


Discussion:
I don't see it used anywhere, so yes, can be removed.

Resolving patch:
diff --git a/ietf/secr/middleware/dbquery.py b/ietf/secr/middleware/dbquery.py
deleted file mode 100644
--- a/ietf/secr/middleware/dbquery.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright The IETF Trust 2014-2019, All Rights Reserved
-#import logging
-
-from django.db import connection
-from django.utils.log import getLogger  # type: ignore
-
-
-logger = getLogger(__name__)
-#logger.setLevel(logging.DEBUG)
-#logger.addHandler(logging.FileHandler(settings.SECR_LOG_FILE))
-
-class QueryCountDebugMiddleware(object):
-    """
-    This middleware will log the number of queries run
-    and the total time taken for each request (with a
-    status code of 200). It does not currently support
-    multi-db setups.
-    """
-    def process_response(self, request, response):
-        #assert False, request.path
-        logger.debug('called middleware. %s:%s' % (request.path,len(connection.queries)))
-        if response.status_code == 200:
-            total_time = 0
-            #for query in connection.queries:
-            #    query_time = query.get('time')
-            #    if query_time is None:
-                    # django-debug-toolbar monkeypatches the connection
-                    # cursor wrapper and adds extra information in each
-                    # item in connection.queries. The query time is stored
-                    # under the key "duration" rather than "time" and is
-                    # in milliseconds, not seconds.
-            #        query_time = query.get('duration', 0) / 1000
-            #    total_time += float(query_time)
-            logger.debug('%s: %s queries run, total %s seconds' % (request.path,len(connection.queries), total_time))
-        return response


Test patch:
Repository: ietf-tools/datatracker

Issue:
rswg chairs can't request meeting sessions
Attempts to do so result in:
![image](https://user-images.githubusercontent.com/10996692/217880296-3cdf711c-c72b-49f3-bdaa-0b297c8b94a9.png)
at least for one of the chairs.


Discussion:

Resolving patch:
diff --git a/ietf/ietfauth/utils.py b/ietf/ietfauth/utils.py
--- a/ietf/ietfauth/utils.py
+++ b/ietf/ietfauth/utils.py
@@ -82,6 +82,7 @@ def has_role(user, role_names, *args, **kwargs):
             "Program Lead": Q(person=person,name="lead", group__type="program", group__state="active"),
             "Program Secretary": Q(person=person,name="secr", group__type="program", group__state="active"),
             "Program Chair": Q(person=person,name="chair", group__type="program", group__state="active"),
+            "EDWG Chair": Q(person=person, name="chair", group__type="edwg", group__state="active"),
             "Nomcom Chair": Q(person=person, name="chair", group__type="nomcom", group__acronym__icontains=kwargs.get('year', '0000')),
             "Nomcom Advisor": Q(person=person, name="advisor", group__type="nomcom", group__acronym__icontains=kwargs.get('year', '0000')),
             "Nomcom": Q(person=person, group__type="nomcom", group__acronym__icontains=kwargs.get('year', '0000')),
diff --git a/ietf/secr/sreq/views.py b/ietf/secr/sreq/views.py
--- a/ietf/secr/sreq/views.py
+++ b/ietf/secr/sreq/views.py
@@ -31,7 +31,7 @@
 # Globals
 # -------------------------------------------------
 # TODO: This needs to be replaced with something that pays attention to groupfeatures
-AUTHORIZED_ROLES=('WG Chair','WG Secretary','RG Chair','IAB Group Chair','Area Director','Secretariat','Team Chair','IRTF Chair','Program Chair','Program Lead','Program Secretary')
+AUTHORIZED_ROLES=('WG Chair','WG Secretary','RG Chair','IAB Group Chair','Area Director','Secretariat','Team Chair','IRTF Chair','Program Chair','Program Lead','Program Secretary', 'EDWG Chair')
 
 # -------------------------------------------------
 # Helper Functions


Test patch:
Repository: ietf-tools/datatracker

Issue:
Join meetecho tool from meeting pages
### Description

Would it be possible to get the link to join the in-room meeting tool from a WG's meeting page?

Currently it's faster for me to visit the WG page and navigate to meetings, rather than loading the ITF115 entire agenda and search for a particular group.

So when I'm looking at a page like https://datatracker.ietf.org/wg/oauth/meetings/ or even https://datatracker.ietf.org/meeting/115/session/oauth it would be great to have a link to join the meetecho tool.

This is particularly relevant when I'd like to join the meetecho tool from my computer while in a meeting room, since I don't have an easy way to scan the QR code on the screen into my computer, and there is no alternate link for the QR code visible on the screen to manually enter either.

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:
See also #1954, #2105, and #4722.


Resolving patch:
diff --git a/ietf/context_processors.py b/ietf/context_processors.py
--- a/ietf/context_processors.py
+++ b/ietf/context_processors.py
@@ -3,6 +3,7 @@
 import sys
 import django
 from django.conf import settings
+from django.utils import timezone
 from ietf import __version__, __patch__, __release_branch__, __release_hash__
 
 def server_mode(request):
@@ -44,4 +45,9 @@ def sql_debug(request):
 def settings_info(request):
     return {
         'settings': settings,
-    }
\ No newline at end of file
+    }
+
+def timezone_now(request):
+    return {
+        'timezone_now': timezone.now(),
+    }
diff --git a/ietf/meeting/views.py b/ietf/meeting/views.py
--- a/ietf/meeting/views.py
+++ b/ietf/meeting/views.py
@@ -2341,7 +2341,6 @@ def session_details(request, num, acronym):
                     'can_manage_materials' : can_manage,
                     'can_view_request': can_view_request,
                     'thisweek': datetime_today()-datetime.timedelta(days=7),
-                    'now': timezone.now(),
                     'use_notes': meeting.uses_notes(),
                   })
 
diff --git a/ietf/settings.py b/ietf/settings.py
--- a/ietf/settings.py
+++ b/ietf/settings.py
@@ -372,6 +372,7 @@ def skip_unreadable_post(record):
                 'ietf.context_processors.settings_info',
                 'ietf.secr.context_processors.secr_revision_info',
                 'ietf.context_processors.rfcdiff_base_url',
+                'ietf.context_processors.timezone_now',
             ],
             'loaders': [
                 ('django.template.loaders.cached.Loader', (


Test patch: