fix: Use correct group type in session request email response (#5275)

* fix: Use correct group type in session request email response

Fixes #2120

* Address review comments

* Address review comments
This commit is contained in:
Lars Eggert 2023-03-07 18:15:47 +02:00 committed by GitHub
parent ddcfb09ab8
commit 98c24d1bb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 12 deletions

View file

@ -3,6 +3,7 @@
import datetime
import inflect
from collections import defaultdict, OrderedDict
from django.conf import settings
@ -105,18 +106,29 @@ def get_lock_message(meeting=None):
meeting = get_meeting(days=14)
return meeting.session_request_lock_message
def get_requester_text(person,group):
'''
This function takes a Person object and a Group object and returns the text to use in the
session request notification email, ie. Joe Smith, a Chair of the ancp working group
'''
roles = group.role_set.filter(name__in=('chair','secr'),person=person)
def get_requester_text(person, group):
"""
This function takes a Person object and a Group object and returns the text to use
in the session request notification email, ie. Joe Smith, a Chair of the ancp
working group
"""
roles = group.role_set.filter(name__in=("chair", "secr", "ad"), person=person)
if roles:
return '%s, a %s of the %s working group' % (person.ascii, roles[0].name, group.acronym)
if group.parent and group.parent.role_set.filter(name='ad',person=person):
return '%s, a %s Area Director' % (person.ascii, group.parent.acronym.upper())
if person.role_set.filter(name='secr',group__acronym='secretariat'):
return '%s, on behalf of the %s working group' % (person.ascii, group.acronym)
rolename = str(roles[0].name)
return "%s, %s of the %s %s" % (
person.name,
inflect.engine().a(rolename),
group.acronym.upper(),
group.type.verbose_name,
)
if person.role_set.filter(name="secr", group__acronym="secretariat"):
return "%s, on behalf of the %s %s" % (
person.name,
group.acronym.upper(),
group.type.verbose_name,
)
def save_conflicts(group, meeting, conflicts, name):
'''

View file

@ -1,5 +1,5 @@
{% load ams_filters %}
{{ header }} meeting session request has just been submitted by {{ requester }}.
{% filter wordwrap:78 %}{{ header }} meeting session request has just been submitted by {{ requester }}.{% endfilter %}
{% include "includes/session_info.txt" %}

View file

@ -35,6 +35,7 @@ gunicorn>=20.1.0
hashids>=1.3.1
html2text>=2020.1.16 # Used only to clean comment field of secr/sreq
html5lib>=1.1 # Only used in tests
inflect>= 6.0.2
jsonfield>=3.1.0 # for SubmissionCheck. This is https://github.com/bradjasper/django-jsonfield/.
jwcrypto>=1.2 # for signed notifications - this is aspirational, and is not really used.
logging_tree>=1.9 # Used only by the showloggers management command