Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bf81e33
feat: DraftAliasGenerator class
jennifer-richards Jan 30, 2024
c6ed428
refactor: Avoid circular imports
jennifer-richards Jan 30, 2024
e4a902a
feat: Add draft_aliases API endpoint
jennifer-richards Jan 30, 2024
8d0a533
feat: Add @requires_api_token decorator
jennifer-richards Jan 30, 2024
d61ce80
feat: Add token auth to draft_aliases endpoint
jennifer-richards Jan 30, 2024
83dc67c
feat: draft-aliases-from-json.py script
jennifer-richards Jan 31, 2024
965d97e
chore: Remove unused cruft
jennifer-richards Jan 31, 2024
d380867
refactor: Avoid shadowing "draft" name
jennifer-richards Jan 31, 2024
37df13e
fix: Suppress empty lists from DraftAliasGenerator
jennifer-richards Jan 31, 2024
e5197b9
refactor: Use a GET instead of POST
jennifer-richards Jan 31, 2024
e30ed3d
feat: GroupAliasGenerator class
jennifer-richards Feb 1, 2024
cc1cb55
feat: group aliases API view
jennifer-richards Feb 1, 2024
f299308
fix: Handle domains array correctly
jennifer-richards Feb 1, 2024
110ebf6
fix: Suppress empty group aliases
jennifer-richards Feb 1, 2024
06d73eb
refactor: Generalize aliases-from-json.py script
jennifer-richards Feb 1, 2024
28dcdf7
refactor: Same output fmt for draft and group alias apis
jennifer-richards Feb 1, 2024
2b08802
feat: Sort addresses for stability
jennifer-richards Feb 1, 2024
24b929a
fix: Add "anything" virtual alias
jennifer-richards Feb 1, 2024
811c6b8
Merge branch 'main' into celery-cronch-runner
jennifer-richards Feb 6, 2024
510fb32
test: Test requires_api_token decorator
jennifer-richards Feb 6, 2024
3862a15
feat: Harden is_valid_token against misconfig
jennifer-richards Feb 6, 2024
25bd4b1
test: Test is_valid_token
jennifer-richards Feb 6, 2024
bbaec7d
test: Test draft_aliases view
jennifer-richards Feb 6, 2024
cec54d5
test: Test group_aliases view
jennifer-richards Feb 6, 2024
2d2353c
test: Test DraftAliasGenerator
jennifer-richards Feb 6, 2024
69be6a0
fix: ise group is type "ise" in test data
jennifer-richards Feb 6, 2024
c315f31
test: Fix logic in testManagementCommand
jennifer-richards Feb 7, 2024
ede43c3
test: Test GroupAliasGenerator
jennifer-richards Feb 7, 2024
405d4e0
fix: Suppress empty -ads alias
jennifer-richards Feb 7, 2024
aa1edd4
test: Fix group acronym copy/paste error
jennifer-richards Feb 7, 2024
4a80e30
test: Check draft .notify alias generation
jennifer-richards Feb 7, 2024
ceb52a1
test: Cover get_draft_notify_emails()
jennifer-richards Feb 7, 2024
b715d72
Merge branch 'main' into celery-cronch-runner
jennifer-richards Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: group aliases API view
  • Loading branch information
jennifer-richards committed Feb 1, 2024
commit cc1cb55829f655f993af16cecf19132915307e37
3 changes: 3 additions & 0 deletions ietf/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
url(r'^v2/person/person', api_views.ApiV2PersonExportView.as_view()),
#
# --- Custom API endpoints, sorted alphabetically ---
# Email alias information for drafts
url(r'^doc/draft-aliases/$', api_views.draft_aliases),
# GPRD: export of personal information for the logged-in person
url(r'^export/personal-information/$', api_views.PersonalInformationExportView.as_view()),
# Email alias information for groups
url(r'^group/group-aliases/$', api_views.group_aliases),
# Let IESG members set positions programmatically
url(r'^iesg/position', views_ballot.api_set_position),
# Let Meetecho set session video URLs
Expand Down
22 changes: 21 additions & 1 deletion ietf/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from ietf.api.serializer import JsonExportMixin
from ietf.api.ietf_utils import is_valid_token, requires_api_token
from ietf.doc.utils import DraftAliasGenerator, fuzzy_find_documents
from ietf.group.utils import GroupAliasGenerator
from ietf.ietfauth.views import send_account_creation_email
from ietf.ietfauth.utils import role_required
from ietf.meeting.models import Meeting
Expand Down Expand Up @@ -455,7 +456,7 @@ def directauth(request):
return HttpResponse(status=405)


@requires_api_token
@requires_api_token("ietf.api.views.email_aliases")
@csrf_exempt
def draft_aliases(request):
if request.method == "GET":
Expand All @@ -467,3 +468,22 @@ def draft_aliases(request):
}
)
return HttpResponse(status=405)


@requires_api_token("ietf.api.views.email_aliases")
@csrf_exempt
def group_aliases(request):
if request.method == "GET":
return JsonResponse(
{
"aliases": [
{
"alias": alias,
"domains": domains,
"addresses": address_list,
}
for alias, domains, address_list in GroupAliasGenerator()
]
}
)
return HttpResponse(status=405)
16 changes: 8 additions & 8 deletions ietf/group/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,29 +396,29 @@ def __iter__(self):

# Research groups, teams, and programs do not have -ads lists
if not g in self.no_ad_group_types:
yield name + "-ads", domains, get_group_ad_emails(e)
yield name + "-ads", domains, list(get_group_ad_emails(e))
# All group types have -chairs lists
yield name + "-chairs", domains, get_group_role_emails(
yield name + "-chairs", domains, list(get_group_role_emails(
e, ["chair", "secr"]
)
))

# The area lists include every chair in active working groups in the area
areas = Group.objects.filter(type="area").all()
active_areas = areas.filter(state__in=self.active_states)
for area in active_areas:
name = area.acronym
area_ad_emails = get_group_role_emails(area, ["pre-ad", "ad", "chair"])
yield name + "-ads", "ietf", area_ad_emails
yield name + "-chairs", "ietf", get_child_group_role_emails(
yield name + "-ads", "ietf", list(area_ad_emails)
yield name + "-chairs", "ietf", list(get_child_group_role_emails(
area, ["chair", "secr"]
) | area_ad_emails
) | area_ad_emails)

# Other groups with chairs that require Internet-Draft submission approval
gtypes = GroupTypeName.objects.values_list("slug", flat=True)
special_groups = Group.objects.filter(
type__features__req_subm_approval=True, acronym__in=gtypes, state="active"
)
for group in special_groups:
yield group.acronym + "-chairs", "ietf", get_group_role_emails(
yield group.acronym + "-chairs", "ietf", list(get_group_role_emails(
group, ["chair", "delegate"]
)
))