|
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 under |
|
6
|
|
|
# the terms of the GNU General Public License as published by the Free Software |
|
7
|
|
|
# Foundation, version 2. |
|
8
|
|
|
# |
|
9
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT |
|
10
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
11
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
12
|
|
|
# details. |
|
13
|
|
|
# |
|
14
|
|
|
# You should have received a copy of the GNU General Public License along with |
|
15
|
|
|
# this program; if not, write to the Free Software Foundation, Inc., 51 |
|
16
|
|
|
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
17
|
|
|
# |
|
18
|
|
|
# Copyright 2018-2020 by it's authors. |
|
19
|
|
|
# Some rights reserved, see README and LICENSE. |
|
20
|
|
|
|
|
21
|
|
|
from OFS.ObjectManager import ObjectManager |
|
22
|
|
|
|
|
23
|
|
|
ADD_SENAITE_SITE = """ |
|
24
|
|
|
<dtml-if expr="_.len(this().getPhysicalPath()) == 1 and len(objectValues('Plone Site')) == 0"> |
|
25
|
|
|
<script type="text/javascript"> |
|
26
|
|
|
var url = location.href.replace(location.pathname, "/@@senaite-addsite?site_id=senaite") |
|
27
|
|
|
location.href = url; |
|
28
|
|
|
</script> |
|
29
|
|
|
</dtml-if> |
|
30
|
|
|
<dtml-if expr="_.len(this().getPhysicalPath()) == 1 and len(objectValues('Plone Site')) > 0"> |
|
31
|
|
|
<!-- Add Plone site action--> |
|
32
|
|
|
<style type="text/css"> |
|
33
|
|
|
.form { margin: 1em auto; text-align:center; } |
|
34
|
|
|
.button {padding:1em 3em;background-color:#337ab7;color:#fff;border-color:#2e6da4;cursor:pointer;font-weight:bold; } |
|
35
|
|
|
input[value='Add Plone Site'] { display:none; } |
|
36
|
|
|
</style> |
|
37
|
|
|
<form class="form" |
|
38
|
|
|
method="get" |
|
39
|
|
|
action="&dtml-URL1;/@@senaite-addsite" |
|
40
|
|
|
target="_top"> |
|
41
|
|
|
<input type="hidden" name="site_id" value="senaite" /> |
|
42
|
|
|
<input class="button" type="submit" value="Install SENAITE LIMS" /> |
|
43
|
|
|
</form> |
|
44
|
|
|
</dtml-if> |
|
45
|
|
|
""" |
|
46
|
|
|
|
|
47
|
|
|
main = ObjectManager.manage_main |
|
48
|
|
|
orig = main.read() |
|
49
|
|
|
pos = orig.find('<!-- Add object widget -->') |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
# Add in our button html at the right position |
|
53
|
|
|
new = orig[:pos] + ADD_SENAITE_SITE + orig[pos:] |
|
54
|
|
|
|
|
55
|
|
|
# Modify the manage_main |
|
56
|
|
|
main.edited_source = new |
|
57
|
|
|
main._v_cooked = main.cook() |
|
58
|
|
|
|