Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links to partitions for Internal Use are displayed in partitions viewlet #1511

Merged
merged 2 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Changelog

**Fixed**

- #1511 Links to partitions for Internal Use are displayed in partitions viewlet
- #1505 Manage Analyses Form re-applies partitioned Analyses back to the Root
- #1503 Avoid duplicate CSS IDs in multi-column Add form
- #1501 Fix Attribute Error in Reference Sample Popup
Expand Down
14 changes: 14 additions & 0 deletions bika/lims/browser/analyses/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ def before_render(self):
super(AnalysesView, self).before_render()
self.request.set("disable_plone.rightcolumn", 1)

@property
@viewcache.memoize
def show_partitions(self):
"""Returns whether the partitions must be displayed or not
"""
if api.get_current_client():
# Current user is a client contact
return api.get_setup().getShowPartitions()
return True

@viewcache.memoize
def analysis_remarks_enabled(self):
"""Check if analysis remarks are enabled
Expand Down Expand Up @@ -1183,6 +1193,10 @@ def _folder_item_partition(self, analysis_brain, item):

sample_id = analysis_brain.getRequestID
if sample_id != api.get_id(self.context):
if not self.show_partitions:
# Do not display the link
return

part_url = analysis_brain.getRequestURL
url = get_link(part_url, value=sample_id, **{"class": "small"})
title = item["replace"].get("Service") or item["Service"]
Expand Down
15 changes: 12 additions & 3 deletions bika/lims/browser/viewlets/analysisrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,20 @@ class PrimaryAnalysisRequestViewlet(ViewletBase):
def get_partitions(self):
"""Returns whether this viewlet is visible or not
"""
partitions = []

# If current user is a client contact, rely on Setup's ShowPartitions
if api.get_current_client():
client = api.get_current_client()
if client:
if not api.get_setup().getShowPartitions():
return []
return self.context.getDescendants()
return partitions

partitions = self.context.getDescendants()
if client:
# Do not display partitions for Internal use
return filter(lambda part: not part.getInternalUse(), partitions)

return partitions


class PartitionAnalysisRequestViewlet(ViewletBase):
Expand Down