Skip to content

Commit

Permalink
Merge pull request #729 from euphorie/scrum-2142-certificates-overview
Browse files Browse the repository at this point in the history
Add certificates overview
  • Loading branch information
reinhardt authored May 8, 2024
2 parents d8bb7a7 + b6c0430 commit aff4520
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions src/euphorie/client/browser/certificates.py
Original file line number Diff line number Diff line change
@@ -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()
9 changes: 9 additions & 0 deletions src/euphorie/client/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@
layer="euphorie.client.interfaces.IClientSkinLayer"
/>

<browser:page
name="certificates"
for="euphorie.client.country.IClientCountry"
class=".certificates.View"
template="templates/certificates.pt"
permission="euphorie.client.ViewSurvey"
layer="euphorie.client.interfaces.IClientSkinLayer"
/>

<browser:page
name="training-certificate-inner"
for="euphorie.client.adapters.session_traversal.ITraversedSurveySession"
Expand Down
55 changes: 55 additions & 0 deletions src/euphorie/client/browser/templates/certificates.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:meta="http://xml.zope.org/namespaces/meta"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
meta:interpolation="true"
metal:use-macro="context/@@shell/macros/shell"
i18n:domain="euphorie"
>

<!-- The equivalent template in the Jekyll prototype is /certificates -->

<body>
<metal:slot fill-slot="content">
<div id="content-pane">
<metal:homescreen_navigation use-macro="here/view/macros/homescreen_navigation">
<metal:slot fill-slot="view_options" />
<metal:slot fill-slot="quick_functions" />
</metal:homescreen_navigation>
<div id="application-content">
<div class="portlet">
<div class="content">
<tal:year tal:repeat="item view/my_certificates">
<tal:year tal:define="
year python:item[0];
sessions python:item[1];
">
<h2 class="separation-title">
${year}
</h2>
<div class="certificate-overview col-3">
<tal:session tal:repeat="info sessions">
<figure class="certificate-preview">
<a class="certificate pat-auto-scale pat-inject"
href="${info/link}"
data-pat-inject="source: #content; target: #content; history: record"
tal:condition="nocall:info/content"
>
<tal:certificate replace="structure info/content" />
</a>
</figure>
</tal:session>

</div>
</tal:year>
</tal:year>
</div>
</div>
</div>
</div>
</metal:slot>

</body>
</html>
6 changes: 4 additions & 2 deletions src/euphorie/client/browser/templates/sessions-dashboard.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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</a>
<a class="pat-inject"
-->
<a class="pat-inject ${python:'current' if dashboard_tab=='certificates' else None}"
href="${here/absolute_url}/certificates"
data-pat-inject="history: record; source: #application-content; target: #application-content && source: #toolbar-functions-area::element; target: #toolbar-functions-area::element"
tal:condition="webhelpers/show_certificates_tab"
i18n:translate="label_certificates"
>Certificates</a>
-->
<a class="pat-inject ${python:'current' if dashboard_tab=='organisation' else None}"
href="${here/absolute_url}/@@organisation"
data-pat-inject="history: record; source: #application-content; target: #application-content &amp;&amp; source: #toolbar-functions-area::element; target: #toolbar-functions-area::element"
Expand Down
15 changes: 15 additions & 0 deletions src/euphorie/client/browser/templates/training_certificate_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
>
<metal:slot fill-slot="content">
<div id="content-pane">
<div class="pat-toolbar"
id="certificate-toolbar"
>
<div class="toolbar-section quick-navigation"
tal:define="
country nocall:here/webhelpers/country_obj;
"
>
<a class="pat-back-button pat-inject"
href="${country/absolute_url}/certificates"
data-pat-inject="history: record; source: #content; target: #content;"
i18n:translate="label_certificates"
>Certificates</a>
</div>
</div>
<div class="container">
<div class="row">
<div class="eight columns">
Expand Down
7 changes: 6 additions & 1 deletion src/euphorie/client/browser/webhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit aff4520

Please sign in to comment.