Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
9514ee8e
Commit
9514ee8e
authored
May 16, 2017
by
Ayush Tiwari
Committed by
Ayush Tiwari
Nov 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add create, delete, update functions for portal_skins selection list
parent
299e9b0c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
2 deletions
+124
-2
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+100
-0
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+24
-2
No files found.
product/ERP5/Document/BusinessManager.py
View file @
9514ee8e
...
...
@@ -761,6 +761,9 @@ class BusinessItem(XMLObject):
delattr
(
obj
,
'__ac_local_roles__'
)
container
.
_setObject
(
object_id
,
obj
,
suppress_events
=
True
)
obj
=
container
.
_getOb
(
object_id
)
skin_tool
=
portal
.
portal_skins
if
obj
.
aq_parent
.
meta_type
==
'CMF Skins Tool'
:
registerSkinFolder
(
skin_tool
,
obj
)
def
unrestrictedResolveValue
(
self
,
context
=
None
,
path
=
''
,
default
=
_MARKER
,
restricted
=
0
):
...
...
@@ -982,3 +985,100 @@ class BusinessPropertyItem(XMLObject):
obj
.
_delPropValue
(
property_name
)
if
int
(
self
.
getProperty
(
'item_sign'
))
==
1
:
obj
.
setProperty
(
property_name
,
property_value
,
property_type
)
def
registerSkinFolder
(
skin_tool
,
skin_folder
):
request
=
skin_tool
.
REQUEST
# XXX: Getting parameter from request instead of dialog is bad
# XXX: This is even non consistent with rest of parameters selected by user
# (like update_translation or update_catalog)
register_skin_selection
=
request
.
get
(
'your_register_skin_selection'
,
1
)
reorder_skin_selection
=
request
.
get
(
'your_reorder_skin_selection'
,
1
)
skin_layer_list
=
request
.
get
(
'your_skin_layer_list'
,
skin_tool
.
getSkinSelections
())
skin_folder_id
=
skin_folder
.
getId
()
try
:
skin_selection_list
=
skin_folder
.
getProperty
(
'business_template_registered_skin_selections'
,
skin_tool
.
getSkinSelections
()
)
except
AttributeError
:
skin_selection_list
=
skin_tool
.
getSkinSelections
()
if
isinstance
(
skin_selection_list
,
basestring
):
skin_selection_list
=
skin_selection_list
.
split
()
def
skin_sort_key
(
skin_folder_id
):
obj
=
skin_tool
.
_getOb
(
skin_folder_id
,
None
)
if
obj
is
None
:
return
0
,
skin_folder_id
return
-
obj
.
getProperty
(
'business_template_skin_layer_priority'
,
obj
.
meta_type
==
'Filesystem Directory View'
and
-
1
or
0
),
skin_folder_id
for
skin_name
in
skin_selection_list
:
if
(
skin_name
not
in
skin_tool
.
getSkinSelections
())
and
\
register_skin_selection
:
createSkinSelection
(
skin_tool
,
skin_name
)
# add newly created skins to list of skins we care for
skin_layer_list
.
append
(
skin_name
)
selection
=
skin_tool
.
getSkinPath
(
skin_name
)
or
''
selection_list
=
selection
.
split
(
','
)
if
(
skin_folder_id
not
in
selection_list
):
selection_list
.
insert
(
0
,
skin_folder_id
)
if
reorder_skin_selection
:
# Sort by skin priority and ID
selection_list
.
sort
(
key
=
skin_sort_key
)
if
(
skin_name
in
skin_layer_list
):
skin_tool
.
manage_skinLayers
(
skinpath
=
selection_list
,
skinname
=
skin_name
,
add_skin
=
1
)
skin_tool
.
getPortalObject
().
changeSkin
(
None
)
def
createSkinSelection
(
skin_tool
,
skin_name
):
# This skin selection does not exist, so we create a new one.
# We'll initialize it with all skin folders, unless:
# - they explictly define a list of
# "business_template_registered_skin_selections", and we
# are not in this list.
# - they are not registered in the default skin selection
skin_path
=
''
for
skin_folder
in
skin_tool
.
objectValues
():
if
skin_name
in
skin_folder
.
getProperty
(
'business_template_registered_skin_selections'
,
(
skin_name
,
)):
if
skin_folder
.
getId
()
in
\
skin_tool
.
getSkinPath
(
skin_tool
.
getDefaultSkin
()):
if
skin_path
:
skin_path
=
'%s,%s'
%
(
skin_path
,
skin_folder
.
getId
())
else
:
skin_path
=
skin_folder
.
getId
()
# add newly created skins to list of skins we care for
skin_tool
.
addSkinSelection
(
skin_name
,
skin_path
)
skin_tool
.
getPortalObject
().
changeSkin
(
None
)
def
deleteSkinSelection
(
skin_tool
,
skin_name
):
# Do not delete default skin
if
skin_tool
.
getDefaultSkin
()
!=
skin_name
:
for
skin_folder
in
skin_tool
.
objectValues
():
try
:
if
skin_name
in
skin_folder
.
getProperty
(
'business_template_registered_skin_selections'
,
()):
break
except
AttributeError
:
pass
else
:
skin_tool
.
manage_skinLayers
(
chosen
=
[
skin_name
],
del_skin
=
1
)
skin_tool
.
getPortalObject
().
changeSkin
(
None
)
def
unregisterSkinFolderId
(
skin_tool
,
skin_folder_id
,
skin_selection_list
):
for
skin_selection
in
skin_selection_list
:
selection
=
skin_tool
.
getSkinPath
(
skin_selection
)
selection
=
selection
.
split
(
','
)
if
(
skin_folder_id
in
selection
):
selection
.
remove
(
skin_folder_id
)
skin_tool
.
manage_skinLayers
(
skinpath
=
tuple
(
selection
),
skinname
=
skin_selection
,
add_skin
=
1
)
deleteSkinSelection
(
skin_tool
,
skin_selection
)
skin_tool
.
getPortalObject
().
changeSkin
(
None
)
product/ERP5/Tool/TemplateTool.py
View file @
9514ee8e
...
...
@@ -649,6 +649,13 @@ class TemplateTool (BaseTool):
#category_path_list.append('portal_categories/'+base_category+'/**')
template_path_list
.
extend
(
category_path_list
)
# Adding business template skin selection property on the portal_tempaltes
template_skin_selection_list
=
import_template
.
getTemplateRegisteredSkinSelectionList
()
selection_list
=
[]
for
selection
in
template_skin_selection_list
:
skin
,
selection
=
selection
.
split
(
' | '
)
selection_list
.
append
(
'portal_skins/%s#business_template_registered_skin_selections'
%
skin
)
# For portal_skins, we export the folder
portal_skin_list
=
import_template
.
getTemplateSkinIdList
()
portal_skin_path_list
=
[]
...
...
@@ -772,6 +779,7 @@ class TemplateTool (BaseTool):
)
template_path_list
.
extend
(
property_path_list
)
template_path_list
.
extend
(
selection_list
)
template_path_list
=
self
.
cleanTemplatePathList
(
template_path_list
)
migrated_bm
.
setProperty
(
'template_path_list'
,
template_path_list
)
...
...
@@ -1004,7 +1012,7 @@ class TemplateTool (BaseTool):
if
repository
.
endswith
(
'/bt5'
):
property_dict_list
.
append
(
bp_dict
)
bm_dict
=
{
bm_dict
_1
=
{
'copyright_list'
:
[
'Copyright (c) 2001-2017 Nexedi SA'
],
'dependency_list'
:
[],
'description'
:
''
,
...
...
@@ -1016,8 +1024,22 @@ class TemplateTool (BaseTool):
'provision_list'
:
[
'erp5_catalog'
],
'title'
:
'erp5_mysql_innodb_catalog'
,
'version'
:
'1.0'
}
bm_dict_2
=
{
'copyright_list'
:
[
'Copyright (c) 2001-2017 Nexedi SA'
],
'dependency_list'
:
[
'erp5_core'
],
'description'
:
''
,
'force_install'
:
0
,
'id'
:
'erp5_xhtml_style'
,
'license'
:
'GPL'
,
'revision'
:
''
,
'test_dependency_list'
:
[],
'provision_list'
:
[
'erp5_view_style'
],
'title'
:
'erp5_xhtml_style'
,
'version'
:
'1.0'
}
if
repository
.
endswith
(
'/bootstrap'
):
property_dict_list
.
append
(
bm_dict
)
property_dict_list
.
append
(
bm_dict
_1
)
self
.
repository_dict
[
repository
]
=
tuple
(
property_dict_list
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment