Skip to content

Commit

Permalink
fix: Use email or name when building community list view (#7203)
Browse files Browse the repository at this point in the history
* fix: Use email or name when building community list view

instead of email

* test: add test case

* chore: remove debug

* fix: use name in community list menu when no active email is found

---------

Co-authored-by: Jennifer Richards <[email protected]>
  • Loading branch information
microamp and jennifer-richards authored Sep 16, 2024
1 parent cc1eade commit 9d583ab
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
13 changes: 10 additions & 3 deletions ietf/community/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@ def email_or_name_set(self, person):
return [e for e in Email.objects.filter(person=person)] + \
[a for a in Alias.objects.filter(person=person)]

def test_view_list(self):
person = self.complex_person(user__username='plain')
def do_view_list_test(self, person):
draft = WgDraftFactory()

# without list
for id in self.email_or_name_set(person):
url = urlreverse(ietf.community.views.view_list, kwargs={ "email_or_name": id })
Expand All @@ -134,6 +132,15 @@ def test_view_list(self):
self.assertEqual(r.status_code, 200, msg=f"id='{id}', url='{url}'")
self.assertContains(r, draft.name)

def test_view_list(self):
person = self.complex_person(user__username='plain')
self.do_view_list_test(person)

def test_view_list_without_active_email(self):
person = self.complex_person(user__username='plain')
person.email_set.update(active=False)
self.do_view_list_test(person)

def test_manage_personal_list(self):
person = self.complex_person(user__username='plain')
ad = Person.objects.get(user__username='ad')
Expand Down
1 change: 1 addition & 0 deletions ietf/community/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def view_list(request, email_or_name=None):
'meta': meta,
'can_manage_list': can_manage_community_list(request.user, clist),
'subscribed': subscribed,
"email_or_name": email_or_name,
})

@login_required
Expand Down
8 changes: 4 additions & 4 deletions ietf/templates/community/list_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<div class="btn-group" role="group" aria-labelledby="list-feeds">
<a class="btn btn-primary"
title="Feed of all changes"
href="{% if clist.group %}{% url "ietf.community.views.feed" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.feed" email_or_name=clist.person.email_address %}{% endif %}">
href="{% if clist.group %}{% url "ietf.community.views.feed" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.feed" email_or_name=email_or_name %}{% endif %}">
<i class="bi bi-rss"></i> All changes
</a>
<a class="btn btn-primary"
title="Feed of only significant state changes"
href="{% if clist.group %}{% url "ietf.community.views.feed" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.feed" email_or_name=clist.person.email_address %}{% endif %}?significant=1">
href="{% if clist.group %}{% url "ietf.community.views.feed" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.feed" email_or_name=email_or_name %}{% endif %}?significant=1">
<i class="bi bi-rss"></i> Significant
</a>
</div>
{% if clist.pk != None %}
<a class="btn btn-primary"
href="{% if clist.group %}{% url "ietf.community.views.subscription" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.subscription" email_or_name=clist.person.email_address %}{% endif %}">
href="{% if clist.group %}{% url "ietf.community.views.subscription" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.subscription" email_or_name=email_or_name %}{% endif %}">
<i class="bi bi-envelope"></i>
{% if subscribed %}
Change subscription
Expand All @@ -24,7 +24,7 @@
</a>
{% endif %}
<a class="btn btn-primary"
href="{% if clist.group %}{% url "ietf.community.views.export_to_csv" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.export_to_csv" email_or_name=clist.person.email_address %}{% endif %}">
href="{% if clist.group %}{% url "ietf.community.views.export_to_csv" acronym=clist.group.acronym %}{% else %}{% url "ietf.community.views.export_to_csv" email_or_name=email_or_name %}{% endif %}">
<i class="bi bi-file-ruled"></i> Export as CSV
</a>
</div>
2 changes: 1 addition & 1 deletion ietf/templates/community/view_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>{{ clist.long_name }}</h1>
{% bootstrap_messages %}
{% if can_manage_list %}
<a class="btn btn-primary my-3"
href="{% url "ietf.community.views.manage_list" email_or_name=clist.person.email_address %}">
href="{% url "ietf.community.views.manage_list" email_or_name=email_or_name %}">
<i class="bi bi-gear"></i>
Manage list
</a>
Expand Down

0 comments on commit 9d583ab

Please sign in to comment.