From ed96cee2e4c5e872838d58a981c4582dc7584bb0 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Mon, 14 May 2012 18:21:34 +0000 Subject: [PATCH] Add listing of recently approved drafts to approval page by request from Barry Leiba. - Legacy-Id: 4420 --- ietf/submit/tests.py | 3 +++ ietf/submit/utils.py | 11 ++++++++++- ietf/submit/views.py | 7 ++++++- ietf/templates/submit/approvals.html | 26 +++++++++++++++++++++++--- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ietf/submit/tests.py b/ietf/submit/tests.py index 8779a0849..a0990eae7 100644 --- a/ietf/submit/tests.py +++ b/ietf/submit/tests.py @@ -373,10 +373,12 @@ class ApprovalsTestCase(django.test.TestCase): IdSubmissionDetail.objects.create(filename="draft-ietf-mars-foo", group_acronym_id=Group.objects.get(acronym="mars").pk, + submission_date=datetime.date.today(), revision="00", status_id=POSTED) IdSubmissionDetail.objects.create(filename="draft-ietf-mars-bar", group_acronym_id=Group.objects.get(acronym="mars").pk, + submission_date=datetime.date.today(), revision="00", status_id=INITIAL_VERSION_APPROVAL_REQUESTED) @@ -389,6 +391,7 @@ class ApprovalsTestCase(django.test.TestCase): self.assertEquals(len(q('.approvals a:contains("draft-ietf-mars-bar")')), 1) self.assertEquals(len(q('.preapprovals td:contains("draft-ietf-mars-foo")')), 0) self.assertEquals(len(q('.preapprovals td:contains("draft-ietf-mars-baz")')), 1) + self.assertEquals(len(q('.recently-approved a:contains("draft-ietf-mars-foo")')), 1) def test_add_preapproval(self): make_test_data() diff --git a/ietf/submit/utils.py b/ietf/submit/utils.py index 541752aca..f57f13a90 100644 --- a/ietf/submit/utils.py +++ b/ietf/submit/utils.py @@ -466,7 +466,7 @@ def get_approvable_submissions(user): if has_role(user, "Secretariat"): return res - # those we can reach as chairs + # those we can reach as chair return res.filter(group_acronym__role__name="chair", group_acronym__role__person__user=user) def get_preapprovals(user): @@ -484,7 +484,16 @@ def get_preapprovals(user): return res +def get_recently_approved(user, since): + if not user.is_authenticated(): + return [] + res = IdSubmissionDetail.objects.distinct().filter(status__in=[POSTED, POSTED_BY_SECRETARIAT], submission_date__gte=since, revision="00").order_by('-submission_date') + if has_role(user, "Secretariat"): + return res + + # those we can reach as chair + return res.filter(group_acronym__role__name="chair", group_acronym__role__person__user=user) class DraftValidation(object): diff --git a/ietf/submit/views.py b/ietf/submit/views.py index 7c864a9fc..c5659e2c9 100644 --- a/ietf/submit/views.py +++ b/ietf/submit/views.py @@ -261,10 +261,15 @@ def approvals(request): approvals = get_approvable_submissions(request.user) preapprovals = get_preapprovals(request.user) + days = 30 + recently_approved = get_recently_approved(request.user, datetime.date.today() - datetime.timedelta(days=days)) + return render_to_response('submit/approvals.html', {'selected': 'approvals', 'approvals': approvals, - 'preapprovals': preapprovals }, + 'preapprovals': preapprovals, + 'recently_approved': recently_approved, + 'days': days }, context_instance=RequestContext(request)) diff --git a/ietf/templates/submit/approvals.html b/ietf/templates/submit/approvals.html index c643f37ef..d4a1c6207 100644 --- a/ietf/templates/submit/approvals.html +++ b/ietf/templates/submit/approvals.html @@ -3,8 +3,8 @@ {% block morecss %} {{ block.super }} -table.approvals td, table.preapprovals td, -table.approvals th, table.preapprovals th { text-align: left; padding-right: 8px; padding-bottom: 4px; } +table.approvals td, table.preapprovals td, table.recently-approved td, +table.approvals th, table.preapprovals th, table.recently-approved th { text-align: left; padding-right: 8px; padding-bottom: 4px; } table.preapprovals tr td a.cancel { visibility: hidden; } table.preapprovals tr:hover { background-color: #eee; } @@ -34,7 +34,7 @@ table.preapprovals tr:hover td a.cancel { visibility: visible; } {% endif %} -

Pre-approved submissions not yet used

+

Pre-approved drafts not yet submitted

{% if user|has_role:"Secretariat,WG Chair" %}

You can add a pre-approval.

@@ -61,4 +61,24 @@ table.preapprovals tr:hover td a.cancel { visibility: visible; } {% endif %} +

Approved drafts within the past {{ days }} days

+ +{% if not recently_approved %} +

No drafts approved.

+{% else %} + + + + + + +{% for d in recently_approved %} + + + + +{% endfor %} +
DraftSubmitted
{{ d.filename }}{{ d.submission_date }}
+{% endif %} + {% endblock %}