fix: Return NomComs, not Groups, from active_nomcoms filter (#5726)
* fix: Return NomComs, not Groups, from active_nomcoms filter * fix: deduplicate and order nomcoms in active_nomcoms filter
This commit is contained in:
parent
c12f810dd4
commit
3391166aaf
|
@ -2,7 +2,7 @@ from django import template
|
|||
|
||||
import debug # pyflakes:ignore
|
||||
|
||||
from ietf.group.models import Group
|
||||
from ietf.nomcom.models import NomCom
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -19,14 +19,15 @@ def active_nomcoms(user):
|
|||
if not (user and hasattr(user, "is_authenticated") and user.is_authenticated):
|
||||
return []
|
||||
|
||||
groups = []
|
||||
|
||||
groups.extend(Group.objects.filter(
|
||||
role__person__user=user,
|
||||
type_id='nomcom',
|
||||
state__slug='active').distinct().select_related("type"))
|
||||
|
||||
return groups
|
||||
return list(
|
||||
NomCom.objects.filter(
|
||||
group__role__person__user=user,
|
||||
group__type_id='nomcom', # just in case...
|
||||
group__state__slug='active',
|
||||
)
|
||||
.distinct()
|
||||
.order_by("group__acronym")
|
||||
)
|
||||
|
||||
@register.inclusion_tag('person/person_link.html')
|
||||
def role_person_link(role, **kwargs):
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if user|active_nomcoms %}
|
||||
{% with user|active_nomcoms as nomcoms %}{% if nomcoms %}
|
||||
{% if flavor == 'top' %}
|
||||
<li><hr class="dropdown-divider">
|
||||
</li>
|
||||
|
@ -179,15 +179,15 @@
|
|||
<li {% if flavor == 'top' %}class="dropdown-header"{% else %}class="nav-item fw-bolder"{% endif %}>
|
||||
NomComs
|
||||
</li>
|
||||
{% for g in user|active_nomcoms %}
|
||||
{% for nomcom in nomcoms %}
|
||||
<li>
|
||||
<a class="dropdown-item {% if flavor != 'top' %}text-wrap link-primary{% endif %}"
|
||||
href="{% url "ietf.nomcom.views.private_index" g.nomcom_set.first.year %}">
|
||||
{{ g.acronym|capfirst }}
|
||||
href="{% url "ietf.nomcom.views.private_index" nomcom.year %}">
|
||||
{{ nomcom|capfirst }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}{% endwith %}
|
||||
{% endif %}
|
||||
{% if flavor == 'top' %}
|
||||
<li><hr class="dropdown-divider">
|
||||
|
|
Loading…
Reference in a new issue