Skip to content

Commit

Permalink
Do not display the panic viewlet if user does not have ViewResults pe…
Browse files Browse the repository at this point in the history
…rmission
  • Loading branch information
xispa committed Jun 16, 2020
1 parent 2512112 commit 7987632
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/senaite/panic/browser/templates/panic_alert_viewlet.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div tal:omit-tag=""
tal:condition="python:view.in_panic"
tal:condition="python:view.available()"
tal:define="
plone_view context/@@plone;
portal_url nocall:context/portal_url;
Expand Down
10 changes: 10 additions & 0 deletions src/senaite/panic/browser/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

from bika.lims import api
from bika.lims.interfaces import IAnalysisRequest
from bika.lims.permissions import ViewResults
from bika.lims.utils import check_permission


class PanicAlertViewlet(ViewletBase):
Expand All @@ -45,6 +47,14 @@ def is_client_contact(self):
"""
return api.get_current_client() is not None

def available(self):
"""Returns whether the viewlet has to be rendered
"""
# Do not display if user does not have ViewResults permission
if check_permission(ViewResults, api.get_object(self.context)):
return self.in_panic
return False

@property
def in_panic(self):
"""Returns whether the Sample has at least one analysis
Expand Down

0 comments on commit 7987632

Please sign in to comment.