From b6c04300e052e797953e0e88fb4b0dfa94c634bd Mon Sep 17 00:00:00 2001 From: Manuel Reinhardt Date: Mon, 6 May 2024 16:13:50 +0200 Subject: [PATCH] Add certificates overview syslabcom/scrum#2142 --- docs/changes.rst | 3 + src/euphorie/client/browser/certificates.py | 25 +++++++++ src/euphorie/client/browser/configure.zcml | 9 +++ .../client/browser/templates/certificates.pt | 55 +++++++++++++++++++ .../browser/templates/sessions-dashboard.pt | 6 +- .../templates/training_certificate_view.pt | 15 +++++ src/euphorie/client/browser/webhelpers.py | 7 ++- 7 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 src/euphorie/client/browser/certificates.py create mode 100644 src/euphorie/client/browser/templates/certificates.pt diff --git a/docs/changes.rst b/docs/changes.rst index 858c201440..9d604c9a0c 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -24,6 +24,9 @@ Changelog - Delete guest account after sessions have been transferred Ref: scrum-2155 +- Add certificates overview + Ref: scrum-2142 + 16.1.2 (2024-03-20) diff --git a/src/euphorie/client/browser/certificates.py b/src/euphorie/client/browser/certificates.py new file mode 100644 index 0000000000..df2ebf2c76 --- /dev/null +++ b/src/euphorie/client/browser/certificates.py @@ -0,0 +1,25 @@ +from plone import api +from plone.memoize.view import memoize +from Products.Five import BrowserView + + +class View(BrowserView): + """Certificates Overview Page""" + + @property + @memoize + def trainings_portlet(self): + return api.content.get_view( + name="portlet-my-trainings", context=self.context, request=self.request + ) + + @property + @memoize + def my_certificates(self): + certificates = {} + for training in self.trainings_portlet.my_certificates: + year = training.time.year + link = f"{training.session.absolute_url()}/@@training-certificate-view" + content = self.trainings_portlet.get_certificate(training.session) + certificates.setdefault(year, []).append({"link": link, "content": content}) + return certificates.items() diff --git a/src/euphorie/client/browser/configure.zcml b/src/euphorie/client/browser/configure.zcml index dec573f3b7..69e29b5ee2 100644 --- a/src/euphorie/client/browser/configure.zcml +++ b/src/euphorie/client/browser/configure.zcml @@ -182,6 +182,15 @@ layer="euphorie.client.interfaces.IClientSkinLayer" /> + + + + + + + + +
+ + + + +
+
+
+ + +

+ ${year} +

+
+ +
+ + + +
+
+ +
+
+
+
+
+
+
+
+ + + diff --git a/src/euphorie/client/browser/templates/sessions-dashboard.pt b/src/euphorie/client/browser/templates/sessions-dashboard.pt index 30d1661795..df6967bd0d 100644 --- a/src/euphorie/client/browser/templates/sessions-dashboard.pt +++ b/src/euphorie/client/browser/templates/sessions-dashboard.pt @@ -53,11 +53,13 @@ href="${here/absolute_url}/trainings" data-pat-inject="history: record; source: #application-content; target: #application-content && source: #toolbar-functions-area::element; target: #toolbar-functions-area::element" >Trainings - + Certificates - -->
+
diff --git a/src/euphorie/client/browser/webhelpers.py b/src/euphorie/client/browser/webhelpers.py index cc629e1f95..16053273c7 100644 --- a/src/euphorie/client/browser/webhelpers.py +++ b/src/euphorie/client/browser/webhelpers.py @@ -106,7 +106,7 @@ class WebHelpers(BrowserView): group_model = Group hide_organisation_tab = False survey_session_model = SurveySession - dashboard_tabs = ["surveys", "assessments", "organisation"] + dashboard_tabs = ["surveys", "assessments", "certificates", "organisation"] navigation_tree_legend = [ {"class": "unvisited", "title": _("Unvisited")}, @@ -257,6 +257,11 @@ def use_help_section(self): # Feature switch, can be overwritten in subclass show_completion_percentage = False + @property + @memoize + def show_certificates_tab(self): + return self.use_training_module + @property @memoize def default_country(self):