Skip to content

Commit

Permalink
Remove grant year ranges from profile card display
Browse files Browse the repository at this point in the history
Including grant year ranges created a mismatch between the years
listed and the name of the grant shown, which was only the
most recent one.

See #197
  • Loading branch information
thatbudakguy committed Nov 4, 2020
1 parent 61a98a3 commit dcad38e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion cdhweb/people/templates/people/snippets/profile_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
{% if grant %}
{# NOTE: for unknown reasons, on qa these are not returned as date objects; handle either date or YYYY-MM-DD string#}
<p>{% if profile.first_start and profile.last_end %}
{# NOTE: not using start year because it creates incorrect display values; see issue 197 #}
{% firstof profile.first_start.year profile.first_start|slice:":4" as start_year %}
{% firstof profile.last_end.year profile.last_end|slice:":4" as end_year %}
{{ start_year }}{% if start_year != end_year %}–{{ end_year }}{% endif %}
{{ end_year }}
{% elif not grant.is_current %}{{ grant.years }}{% endif %}
{# special case for faculty fellowship display #}
{% if grant.grant_type.grant_type == 'Faculty Fellowship' %}Faculty Fellow{% else %}
Expand Down
16 changes: 9 additions & 7 deletions cdhweb/people/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ def test_affiliates(self):

# faculty person with co-PI: Research Lead should be affiliate
co_pi = Person.objects.create(username='copi')
co_pi_profile = Profile.objects.create(user=co_pi, title="Co-PI", pu_status='fac')
co_pi_role, _created = Role.objects.get_or_create(title='Co-PI: Research Lead')
co_pi_profile = Profile.objects.create(
user=co_pi, title="Co-PI", pu_status='fac')
co_pi_role, _created = Role.objects.get_or_create(
title='Co-PI: Research Lead')
s_co_grant = Grant.objects.get(pk=4)
s_co = Project.objects.get(slug='sco')
Membership.objects.create(
Expand Down Expand Up @@ -526,12 +528,12 @@ def test_affiliates_list(self):
response = self.client.get(reverse('people:affiliates'))
assert fac.profile in response.context['current']

# should display name and date range from latest grant
# should display name and date from latest grant
grant = fac.latest_grant
self.assertContains(response, '{} Grant Recipient'.format(
grant.grant_type.grant_type))
self.assertContains(response, '{}–{}'.format(
grant.start_date.year, grant.end_date.year))
self.assertContains(response, '{} {} Grant Recipient'.format(
grant.end_date.year,
grant.grant_type.grant_type), html=True
)

# non current grant - should shift to past list
grant.end_date = date(2018, 1, 1)
Expand Down

0 comments on commit dcad38e

Please sign in to comment.