Skip to content

Commit 236fb3e

Browse files
committed
Make it possible to merge nominations with inactive email addresses in the Nominee Merge form.
- Legacy-Id: 12091
1 parent c236357 commit 236fb3e

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

ietf/nomcom/forms.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,15 @@ def clean_public_key(self):
225225
class MergeNomineeForm(forms.Form):
226226

227227
primary_email = SearchableEmailField(
228-
help_text="Select the email of the Nominee record you want to use as the primary record.")
228+
help_text="Select the email of the Nominee record you want to use as the primary record.",
229+
all_emails = True,
230+
)
229231
secondary_emails = SearchableEmailsField(
230232
help_text="Select all the duplicates that should be consolidated with the primary "
231233
"Nominee record. Nominations already received with any of these email address "
232-
"will be moved to show under the primary address." )
234+
"will be moved to show under the primary address.",
235+
all_emails = True,
236+
)
233237

234238
def __init__(self, *args, **kwargs):
235239
self.nomcom = kwargs.pop('nomcom', None)

ietf/person/fields.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22

33
from collections import Counter
4+
from urllib import urlencode
45

56
from django.utils.html import escape
67
from django import forms
@@ -47,12 +48,14 @@ class SearchablePersonsField(forms.CharField):
4748
def __init__(self,
4849
max_entries=None, # max number of selected objs
4950
only_users=False, # only select persons who also have a user
51+
all_emails=False, # select only active email addresses
5052
model=Person, # or Email
5153
hint_text="Type in name to search for person.",
5254
*args, **kwargs):
5355
kwargs["max_length"] = 1000
5456
self.max_entries = max_entries
5557
self.only_users = only_users
58+
self.all_emails = all_emails
5659
assert model in [ Email, Person ]
5760
self.model = model
5861

@@ -83,8 +86,13 @@ def prepare_value(self, value):
8386
# doing this in the constructor is difficult because the URL
8487
# patterns may not have been fully constructed there yet
8588
self.widget.attrs["data-ajax-url"] = urlreverse("ajax_select2_search_person_email", kwargs={ "model_name": self.model.__name__.lower() })
89+
query_args = {}
8690
if self.only_users:
87-
self.widget.attrs["data-ajax-url"] += "?user=1" # require a Datatracker account
91+
query_args["user"] = "1"
92+
if self.all_emails:
93+
query_args["a"] = "1"
94+
if query_args:
95+
self.widget.attrs["data-ajax-url"] += "?%s" % urlencode(query_args)
8896

8997
return u",".join(str(p.pk) for p in value)
9098

ietf/person/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ def ajax_select2_search(request, model_name):
3434

3535
# require an account at the Datatracker
3636
only_users = request.GET.get("user") == "1"
37+
all_emails = request.GET.get("a", "0") == "1"
3738

3839
if model == Email:
39-
objs = objs.filter(active=True).order_by('person__name').exclude(person=None)
40+
objs = objs.exclude(person=None).order_by('person__name')
41+
if not all_emails:
42+
objs = objs.filter(active=True)
4043
if only_users:
4144
objs = objs.exclude(person__user=None)
4245
elif model == Person:

0 commit comments

Comments
 (0)