Merge ~ilasc/launchpad:add-expiry-date-to-participation-view into launchpad:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: c712291b5887167669503dbe3148f9b18bca0b20
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/launchpad:add-expiry-date-to-participation-view
Merge into: launchpad:master
Diff against target: 99 lines (+34/-1)
3 files modified
lib/lp/registry/browser/person.py (+3/-1)
lib/lp/registry/browser/tests/test_person.py (+21/-0)
lib/lp/registry/templates/person-participation.pt (+10/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+422121@code.launchpad.net

Commit message

Add team membership expiry date to participation view

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Could you `git commit --amend` your commit message to include a bug link (https://help.launchpad.net/Code/Git#Linking_to_bugs)?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/registry/browser/person.py b/lib/lp/registry/browser/person.py
2index 7005a54..c53195c 100644
3--- a/lib/lp/registry/browser/person.py
4+++ b/lib/lp/registry/browser/person.py
5@@ -1997,9 +1997,11 @@ class PersonParticipationView(LaunchpadView):
6 role = 'Member'
7 # The Person never joined, and can't have a join date.
8 datejoined = None
9+ dateexpires = None
10 else:
11 # The member is a direct member; use the membership data.
12 datejoined = membership.datejoined
13+ dateexpires = membership.dateexpires
14 if membership.personID == team.teamownerID:
15 role = 'Owner'
16 elif membership.status == TeamMembershipStatus.ADMIN:
17@@ -2017,7 +2019,7 @@ class PersonParticipationView(LaunchpadView):
18
19 return dict(
20 displayname=team.displayname, team=team, datejoined=datejoined,
21- role=role, via=via, subscribed=subscribed)
22+ role=role, via=via, subscribed=subscribed, dateexpires=dateexpires)
23
24 @cachedproperty
25 def active_participations(self):
26diff --git a/lib/lp/registry/browser/tests/test_person.py b/lib/lp/registry/browser/tests/test_person.py
27index 1d43c17..ad6bd61 100644
28--- a/lib/lp/registry/browser/tests/test_person.py
29+++ b/lib/lp/registry/browser/tests/test_person.py
30@@ -1,6 +1,10 @@
31 # Copyright 2009-2021 Canonical Ltd. This software is licensed under the
32 # GNU Affero General Public License version 3 (see the file LICENSE).
33
34+from datetime import (
35+ datetime,
36+ timedelta,
37+ )
38 import doctest
39 import email
40 from operator import attrgetter
41@@ -9,6 +13,7 @@ from textwrap import dedent
42 from urllib.parse import urljoin
43
44 from fixtures import FakeLogger
45+import pytz
46 import soupmatchers
47 from storm.store import Store
48 from testscenarios import (
49@@ -1110,6 +1115,22 @@ class TestPersonParticipationView(TestCaseWithFactory):
50 [participation] = self.view.active_participations
51 self.assertEqual('Subscribed', participation['subscribed'])
52
53+ def test__asParticipation_dateexpires(self):
54+ team = self.factory.makeTeam(owner=self.user)
55+ [participation] = self.view.active_participations
56+
57+ self.assertIsNone(participation['dateexpires'])
58+
59+ membership_set = getUtility(ITeamMembershipSet)
60+ membership = membership_set.getByPersonAndTeam(self.user, team)
61+ tomorrow = datetime.now(pytz.timezone('UTC')) + timedelta(days=1)
62+ with person_logged_in(self.user):
63+ membership.setExpirationDate(tomorrow, self.user)
64+ view = create_view(self.user, name='+participation')
65+ [participation] = view.active_participations
66+
67+ self.assertEqual(tomorrow, participation['dateexpires'])
68+
69 def test_active_participations_with_direct_private_team(self):
70 # Users cannot see private teams that they are not members of.
71 owner = self.factory.makePerson()
72diff --git a/lib/lp/registry/templates/person-participation.pt b/lib/lp/registry/templates/person-participation.pt
73index 35f7283..7620fca 100644
74--- a/lib/lp/registry/templates/person-participation.pt
75+++ b/lib/lp/registry/templates/person-participation.pt
76@@ -26,6 +26,7 @@
77 <tr>
78 <th>Team</th>
79 <th>Joined</th>
80+ <th>Expires</th>
81 <th>Role</th>
82 <th>Via</th>
83 <th
84@@ -46,6 +47,15 @@
85 &mdash;
86 </tal:no-date>
87 </td>
88+ <td>
89+ <tal:date condition="not: participation/dateexpires"
90+ tal:replace="participation/dateexpires/fmt:date">
91+ 2005-06-17
92+ </tal:date>
93+ <tal:no-date condition="participation/dateexpires">
94+ &mdash;
95+ </tal:no-date>
96+ </td>
97 <td tal:content="participation/role">
98 Member
99 </td>

Subscribers

People subscribed via source and target branches

to status/vote changes: