|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# |
|
3
|
|
|
# This file is part of SENAITE.CORE. |
|
4
|
|
|
# |
|
5
|
|
|
# SENAITE.CORE is free software: you can redistribute it and/or modify it |
|
6
|
|
|
# under the terms of the GNU General Public License as published by the |
|
7
|
|
|
# Free Software Foundation, version 2. |
|
8
|
|
|
# |
|
9
|
|
|
# This program is distributed in the hope that it will be useful, but |
|
10
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
11
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12
|
|
|
# for more details. |
|
13
|
|
|
# |
|
14
|
|
|
# You should have received a copy of the GNU General Public License along |
|
15
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., |
|
16
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
17
|
|
|
# |
|
18
|
|
|
# Copyright 2018-2025 by it's authors. |
|
19
|
|
|
# Some rights reserved, see README and LICENSE. |
|
20
|
|
|
|
|
21
|
|
|
from bika.lims import api |
|
22
|
|
|
from bika.lims import senaiteMessageFactory as _ |
|
23
|
|
|
from bika.lims.interfaces import IBikaSetup |
|
24
|
|
|
from plone.app.layout.viewlets import ViewletBase |
|
25
|
|
|
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile |
|
26
|
|
|
from senaite.core.interfaces import ISetup |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
class SetupLegacyLinkViewlet(ViewletBase): |
|
30
|
|
|
"""Viewlet that displays a link between DX and AT setup forms |
|
31
|
|
|
""" |
|
32
|
|
|
index = ViewPageTemplateFile("templates/setup_legacy_link.pt") |
|
33
|
|
|
|
|
34
|
|
|
def available(self): |
|
35
|
|
|
"""Returns True if the viewlet should be displayed |
|
36
|
|
|
""" |
|
37
|
|
|
return True |
|
38
|
|
|
|
|
39
|
|
|
def get_target_url(self): |
|
40
|
|
|
"""Returns the URL to the other setup form |
|
41
|
|
|
""" |
|
42
|
|
|
# Check if we're on the DX SENAITE Setup |
|
43
|
|
|
if ISetup.providedBy(self.context): |
|
44
|
|
|
# Link to the old Bika Setup (AT) |
|
45
|
|
|
bika_setup = api.get_bika_setup() |
|
46
|
|
|
if bika_setup: |
|
47
|
|
|
return "{}/edit".format(api.get_url(bika_setup)) |
|
48
|
|
|
|
|
49
|
|
|
# Check if we're on the AT Bika Setup |
|
50
|
|
|
elif IBikaSetup.providedBy(self.context): |
|
51
|
|
|
# Link to the new SENAITE Setup (DX) |
|
52
|
|
|
senaite_setup = api.get_senaite_setup() |
|
53
|
|
|
if senaite_setup: |
|
54
|
|
|
return "{}/edit".format(api.get_url(senaite_setup)) |
|
55
|
|
|
|
|
56
|
|
|
return None |
|
57
|
|
|
|
|
58
|
|
|
def get_link_text(self): |
|
59
|
|
|
"""Returns the appropriate link text |
|
60
|
|
|
""" |
|
61
|
|
|
# Check if we're on the DX SENAITE Setup |
|
62
|
|
|
if ISetup.providedBy(self.context): |
|
63
|
|
|
return _("Legacy LIMS Setup") |
|
64
|
|
|
|
|
65
|
|
|
# Check if we're on the AT Bika Setup |
|
66
|
|
|
elif IBikaSetup.providedBy(self.context): |
|
67
|
|
|
return _("New LIMS Setup") |
|
68
|
|
|
|
|
69
|
|
|
return "" |
|
70
|
|
|
|