Skip to content

Commit

Permalink
Moved to bika.extras
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunga001 committed Sep 20, 2023
1 parent 8e377b8 commit 4581196
Showing 1 changed file with 5 additions and 50 deletions.
55 changes: 5 additions & 50 deletions src/bika/lims/controlpanel/bika_analysisprofiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from plone.app.layout.globals.interfaces import IViewView
from senaite.core.interfaces import IHideActionsMenu
from zope.interface.declarations import implements
from zope.i18n.locales import locales


# TODO: Separate content and view into own modules!
Expand Down Expand Up @@ -70,8 +69,6 @@ def __init__(self, context, request):
self.show_select_row = False
self.show_select_column = True
self.pagesize = 25
self.currency_symbol = self.get_currency_symbol()
self.decimal_mark = self.get_decimal_mark()

self.columns = collections.OrderedDict((
("Title", {
Expand All @@ -80,15 +77,13 @@ def __init__(self, context, request):
("Description", {
"title": _("Description"),
"index": "Description",
"toggle": True,}),
"toggle": True,
}),
("ProfileKey", {
"title": _("Profile Key"),
"sortable": False,
"toggle": True,}),
("Price", {
"title": _("Price"),
"sortable": False,
"toggle": True,}),
"toggle": True,
}),
))

self.review_states = [
Expand All @@ -112,40 +107,6 @@ def __init__(self, context, request):
},
]

if not self.context.bika_setup.getShowPrices():
for i in range(len(self.review_states)):
self.review_states[i]["columns"].remove("Price")
del self.columns['Price']


def get_decimal_mark(self):
"""Returns the decimal mark
"""
return self.context.bika_setup.getDecimalMark()


def get_currency_symbol(self):
"""Returns the locale currency symbol
"""
currency = self.context.bika_setup.getCurrency()
locale = locales.getLocale("en")
locale_currency = locale.numbers.currencies.get(currency)
if locale_currency is None:
return "$"
return locale_currency.symbol


def format_price(self, price):
"""Formats the price with the set decimal mark and correct currency
"""
return u"{} {}{}{:02d}".format(
self.currency_symbol,
price[0],
self.decimal_mark,
price[1],
)


def folderitem(self, obj, item, index):
"""Service triggered each time an item is iterated in folderitems.
The use of this service prevents the extra-loops in child objects.
Expand All @@ -158,17 +119,11 @@ def folderitem(self, obj, item, index):
title = obj.Title()
description = obj.Description()
url = obj.absolute_url()
user_roles = api.get_current_user().getRoles()
if "Manager" in user_roles:
financial_permissions = True
else:
financial_permissions = False

item["replace"]["Title"] = get_link(url, value=title)
item["Description"] = description
item["ProfileKey"] = obj.getProfileKey()
if financial_permissions:
item["Price"] = self.format_price(obj.AnalysisProfilePrice)

return item


Expand Down

0 comments on commit 4581196

Please sign in to comment.