Skip to content

Commit

Permalink
Merge pull request #5575 from ietf-tools/main
Browse files Browse the repository at this point in the history
chore: merge main to the release branch for next release
  • Loading branch information
rjsparks authored May 4, 2023
2 parents bef11af + 8af8a91 commit e32b453
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 83 deletions.
49 changes: 26 additions & 23 deletions dev/coverage-action/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev/coverage-action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"luxon": "3.3.0"
},
"devDependencies": {
"eslint": "8.37.0",
"eslint": "8.39.0",
"eslint-config-standard": "17.0.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-node": "11.1.0",
Expand Down
44 changes: 43 additions & 1 deletion ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
ConflictReviewFactory, WgDraftFactory, IndividualDraftFactory, WgRfcFactory,
IndividualRfcFactory, StateDocEventFactory, BallotPositionDocEventFactory,
BallotDocEventFactory, DocumentAuthorFactory, NewRevisionDocEventFactory,
StatusChangeFactory, BofreqFactory, DocExtResourceFactory)
StatusChangeFactory, BofreqFactory, DocExtResourceFactory, RgDraftFactory)
from ietf.doc.forms import NotifyForm
from ietf.doc.fields import SearchableDocumentsField
from ietf.doc.utils import create_ballot_if_not_open, uppercase_std_abbreviated_name
Expand Down Expand Up @@ -2819,3 +2819,45 @@ def test_notify_validation(self):
self.assertFalse(f.is_valid())
self.assertTrue("Invalid addresses" in f.errors["notify"][0])
self.assertTrue("Duplicate addresses" in f.errors["notify"][0])

class CanRequestConflictReviewTests(TestCase):
def test_gets_request_conflict_review_action_button(self):
ise_draft = IndividualDraftFactory(stream_id="ise")
irtf_draft = RgDraftFactory()

# This is blunt, trading off precision for time. A more thorough test would ensure
# that the text is in a button and that the correct link is absent/present as well.

target_string = "Begin IETF conflict review"

url = urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=irtf_draft.name))
r = self.client.get(url)
self.assertNotContains(r, target_string)
self.client.login(username="secretary", password="secretary+password")
r = self.client.get(url)
self.assertContains(r, target_string)
self.client.logout()
self.client.login(username="irtf-chair", password="irtf-chair+password")
r = self.client.get(url)
self.assertContains(r, target_string)
self.client.logout()
self.client.login(username="ise-chair", password="ise-chair+password")
r = self.client.get(url)
self.assertNotContains(r, target_string)
self.client.logout()

url = urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=ise_draft.name))
r = self.client.get(url)
self.assertNotContains(r, target_string)
self.client.login(username="secretary", password="secretary+password")
r = self.client.get(url)
self.assertContains(r, target_string)
self.client.logout()
self.client.login(username="irtf-chair", password="irtf-chair+password")
r = self.client.get(url)
self.assertNotContains(r, target_string)
self.client.logout()
self.client.login(username="ise-chair", password="ise-chair+password")
r = self.client.get(url)
self.assertContains(r, target_string)

20 changes: 14 additions & 6 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,20 @@ def document_main(request, name, rev=None, document_html=False):
urlreverse('ietf.doc.views_ballot.close_rsab_ballot', kwargs=dict(name=doc.name))
))

if (doc.get_state_slug() not in ["rfc", "expired"] and doc.stream_id in ("ise", "irtf")
and has_role(request.user, ("Secretariat", "IRTF Chair")) and not conflict_reviews and not snapshot):
label = "Begin IETF Conflict Review"
if not doc.intended_std_level:
label += " (note that intended status is not set)"
actions.append((label, urlreverse('ietf.doc.views_conflict_review.start_review', kwargs=dict(name=doc.name))))
if (
doc.get_state_slug() not in ["rfc", "expired"]
and not conflict_reviews
and not snapshot
):
if (
doc.stream_id == "ise" and has_role(request.user, ("Secretariat", "ISE"))
) or (
doc.stream_id == "irtf" and has_role(request.user, ("Secretariat", "IRTF Chair"))
):
label = "Begin IETF conflict review" # Note that the template feeds this through capfirst_allcaps
if not doc.intended_std_level:
label += " (note that intended status is not set)"
actions.append((label, urlreverse('ietf.doc.views_conflict_review.start_review', kwargs=dict(name=doc.name))))

if doc.get_state_slug() not in ["rfc", "expired"] and not snapshot:
if can_request_rfc_publication(request.user, doc):
Expand Down
46 changes: 36 additions & 10 deletions ietf/ietfauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,42 @@ def create_account(request):
new_account_email = form.cleaned_data[
"email"
] # This will be lowercase if form.is_valid()

user = User.objects.filter(username__iexact=new_account_email)
email = Email.objects.filter(address__iexact=new_account_email)
if user.exists() or email.exists():
person_to_contact = user.first().person if user else email.first().person
to_email = person_to_contact.email_address()
if to_email:
send_account_creation_exists_email(request, new_account_email, to_email)
else:
raise ValidationError(f"Account for {new_account_email} exists, but cannot email it")
email_is_known = False # do we already know of the new_account_email address?

# Find an existing Person to contact, if one exists
person_to_contact = None
user = User.objects.filter(username__iexact=new_account_email).first()
if user is not None:
email_is_known = True
try:
person_to_contact = user.person
except User.person.RelatedObjectDoesNotExist:
# User.person is a OneToOneField so it raises an exception if the field is null
pass # leave person_to_contact as None
if person_to_contact is None:
email = Email.objects.filter(address__iexact=new_account_email).first()
if email is not None:
email_is_known = True
# Email.person is a ForeignKey, so its value is None if the field is null
person_to_contact = email.person
# Get a "good" email to contact the existing Person
to_email = person_to_contact.email_address() if person_to_contact else None

if to_email:
# We have a "good" email - send instructions to it
send_account_creation_exists_email(request, new_account_email, to_email)
elif email_is_known:
# Either a User or an Email matching new_account_email is in the system but we do not have a
# "good" email to use to contact its owner. Fail so the user can contact the secretariat to sort
# things out.
form.add_error(
"email",
ValidationError(
f"Unable to create account for {new_account_email}. Please contact "
f"the Secretariat at {settings.SECRETARIAT_SUPPORT_EMAIL} for assistance."
),
)
new_account_email = None # Indicate to the template that we failed to create the requested account
else:
# For the IETF 113 Registration period (at least) we are lowering the
# barriers for account creation to the simple email round-trip check
Expand Down
37 changes: 19 additions & 18 deletions ietf/static/js/ietf.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,25 +255,26 @@ $(document)

// Bootstrap doesn't load modals via href anymore, so let's do it ourselves.
// See https://stackoverflow.com/a/48934494/2240756
// Instead of attaching to the modal elements as in that example, though,
// listen on document and filter with the .modal selector. This allows handling
// of modals that are added dynamically (e.g., list.js apparently replaces DOM
// elements with identical copies, minus any attached listeners).
$(document)
.ready(function () {
$('.modal')
.on('show.bs.modal', function (e) {
var button = $(e.relatedTarget);
if (!$(button)
.attr("href")) {
return;
}
var loc = $(button)
.attr("href")
.trim();
// load content from value of button href
if (loc !== undefined && loc !== "#") {
$(this)
.find('.modal-content')
.load(loc);
}
});
.on('show.bs.modal', '.modal', function (e) {
var button = $(e.relatedTarget);
if (!$(button)
.attr("href")) {
return;
}
var loc = $(button)
.attr("href")
.trim();
// load content from value of button href
if (loc !== undefined && loc !== "#") {
$(this)
.find('.modal-content')
.load(loc);
}
});

// Handle history snippet expansion.
Expand Down
Loading

0 comments on commit e32b453

Please sign in to comment.