Skip to content

Commit

Permalink
Dashboard tab marker is now set via pat-navigation.
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Sep 27, 2022
1 parent 3f52502 commit 49bd341
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 49 deletions.
4 changes: 3 additions & 1 deletion docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
14.2.0 (unreleased)
-------------------

- Dashboard tab marker is now set via pat-navigation.
[reinhardt, thet]
- Upgrade Patternslib to 9.5.0.
[thet]
- Export/import training questions
Expand All @@ -27,7 +29,7 @@ Changelog
[ale-rt]
- Measures that are deleted in the CMS stay visible in the client.
[reinhardt]
- Improved dashboard tab marker.
- Tool overview on country level.
[reinhardt]
- Remove the home and help link when the user is not authenticated
[ale-rt]
Expand Down
9 changes: 4 additions & 5 deletions src/euphorie/client/browser/templates/sessions-dashboard.pt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<div class="pat-toolbar"
id="tools-toolbar"
tal:define="
dashboard_tab webhelpers/get_dashboard_tab;
is_anonymous webhelpers/anonymous;
"
>
Expand All @@ -27,16 +26,16 @@
<nav class="pat-tabs pat-button-cluster pat-navigation"
id="homescreen-sections"
>
<a class="icon icon-gauge pat-inject ${python:'current' if dashboard_tab=='dashboard' else None}"
<a class="icon icon-gauge pat-inject"
href="${here/absolute_url}"
data-pat-inject="history: record; source: #application-content; target: #application-content &amp;&amp; source: #toolbar-functions-area::element; target: #toolbar-functions-area::element"
>Home</a>
<a class="pat-inject ${python:'current' if dashboard_tab=='surveys' else None}"
<a class="pat-inject"
href="${here/absolute_url}/surveys"
data-pat-inject="history: record; source: #application-content; target: #application-content &amp;&amp; source: #toolbar-functions-area::element; target: #toolbar-functions-area::element"
i18n:translate="label_tools"
>Tools</a>
<a class="pat-inject ${python:'current' if dashboard_tab=='assessments' else None}"
<a class="pat-inject"
href="${here/absolute_url}/assessments"
data-pat-inject="history: record; source: #application-content; target: #application-content &amp;&amp; source: #toolbar-functions-area::element; target: #toolbar-functions-area::element"
i18n:translate="label_assessments"
Expand All @@ -51,7 +50,7 @@
data-pat-inject="history: record; source: #application-content; target: #application-content && source: #toolbar-functions-area::element; target: #toolbar-functions-area::element"
>Certificates</a>
-->
<a class="pat-inject ${python:'current' if dashboard_tab=='organisation' else None}"
<a class="pat-inject"
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"
i18n:translate=""
Expand Down
7 changes: 0 additions & 7 deletions src/euphorie/client/browser/webhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class WebHelpers(BrowserView):

group_model = Group
survey_session_model = SurveySession
dashboard_tabs = ["surveys", "assessments", "organisation"]

def to_decimal(self, value):
"""Transform value in to a decimal"""
Expand Down Expand Up @@ -611,12 +610,6 @@ def get_phase(self):
head, tail = path.split(head)
return ""

def get_dashboard_tab(self):
tail = path.split(self.request.PATH_INFO.rstrip("/"))[-1].lstrip("@@")
if tail in self.dashboard_tabs:
return tail
return "dashboard"

@property
def came_from_param(self):
if self.came_from:
Expand Down
36 changes: 0 additions & 36 deletions src/euphorie/client/tests/test_webhelpers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# coding=utf-8
from euphorie.client import model
from euphorie.client.browser.webhelpers import WebHelpers
from euphorie.client.tests.utils import addAccount
from euphorie.client.tests.utils import addSurvey
from euphorie.content.tests.utils import BASIC_SURVEY
from euphorie.testing import EuphorieIntegrationTestCase
from plone import api
from plone.app.testing.interfaces import SITE_OWNER_NAME
from unittest import TestCase


class TestWebhelpers(EuphorieIntegrationTestCase):
Expand Down Expand Up @@ -478,37 +476,3 @@ def test_can_view_session(self):
with api.env.adopt_user(user=account3):
with self._get_view("webhelpers", traversed_session1) as view:
self.assertFalse(view.can_view_session)


class TestWebhelpersUnit(TestCase):
def get_webhelpers(self, path):
class DummyRequest:
def __init__(self, path):
self.PATH_INFO = path

return WebHelpers(None, DummyRequest(path))

def test_get_dashboard_tab(self):
webhelpers = self.get_webhelpers(
"/VirtualHostBase/https/oira.local:443/VirtualHostRoot/_vh_daimler"
"/Plone/client/de/assessments"
)
self.assertEqual(webhelpers.get_dashboard_tab(), "assessments")

webhelpers = self.get_webhelpers(
"/VirtualHostBase/https/oira.local:443/VirtualHostRoot/_vh_daimler"
"/Plone/client/de/assessments/"
)
self.assertEqual(webhelpers.get_dashboard_tab(), "assessments")

webhelpers = self.get_webhelpers(
"/VirtualHostBase/https/oira.local:443/VirtualHostRoot/_vh_daimler"
"/Plone/client/de/@@assessments"
)
self.assertEqual(webhelpers.get_dashboard_tab(), "assessments")

webhelpers = self.get_webhelpers(
"/VirtualHostBase/https/oira.local:443/VirtualHostRoot/_vh_daimler"
"/Plone/client/de/@@assessments/"
)
self.assertEqual(webhelpers.get_dashboard_tab(), "assessments")

0 comments on commit 49bd341

Please sign in to comment.