Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5_fork
Commits
2e4152f4
Commit
2e4152f4
authored
Jun 25, 2021
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs_appstore_base: refactor app submit publication
parent
2ee339ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
37 deletions
+52
-37
bt5/erp5_officejs_appstore_base/SkinTemplateItem/portal_skins/erp5_officejs_appstore_base/SoftwarePublication_submitSoftwarePublication.py
...ore_base/SoftwarePublication_submitSoftwarePublication.py
+52
-37
No files found.
bt5/erp5_officejs_appstore_base/SkinTemplateItem/portal_skins/erp5_officejs_appstore_base/SoftwarePublication_submitSoftwarePublication.py
View file @
2e4152f4
def
rejectSoftwarePublication
(
software_publication
):
software_publication
.
submit
()
software_publication
.
reject
()
return
def
extractWebManifest
(
html_file
):
html
=
context
.
Base_parseHtml
(
html_file
)
for
tag
in
html
:
if
tag
[
0
]
==
'starttag'
and
tag
[
1
]
==
'link'
and
(
'rel'
,
'manifest'
)
in
tag
[
2
]:
for
attribute
in
tag
[
2
]:
if
attribute
[
0
]
==
'href'
:
return
attribute
[
1
]
def
getBaseDirectory
(
namelist
):
base
=
""
for
name
in
namelist
:
if
"/"
in
name
:
temp_base
=
name
.
split
(
"/"
)[
0
]
if
base
and
base
!=
temp_base
:
base
=
""
break
else
:
base
=
temp_base
else
:
base
=
""
break
if
base
:
base
+=
"/"
return
base
portal
=
context
.
getPortalObject
()
software_publication
=
context
if
software_publication
.
getSimulationState
()
!=
"draft"
:
...
...
@@ -6,13 +37,17 @@ if software_publication.getSimulationState() != "draft":
software_publication_line
=
software_publication
.
objectValues
(
portal_type
=
"Software Publication Line"
,
)[
0
]
software_product
=
software_publication_line
.
getResourceValue
(
portal_type
=
"Software Product"
)
if
not
software_product
:
rejectSoftwarePublication
(
software_publication
)
return
portal
=
context
.
getPortalObject
()
software_release
=
software_publication_line
.
getAggregateValue
(
portal_type
=
"Software Release"
)
version
=
software_release
.
getReference
()
software_release_url
=
software_release
.
getRelativeUrl
()
user_login
=
software_publication
.
getSourceReference
()
application_publication_section
=
portal
.
portal_categories
.
publication_section
.
application
zip_file
=
portal
.
portal_catalog
.
getResultValue
(
...
...
@@ -22,50 +57,25 @@ zip_file = portal.portal_catalog.getResultValue(
)
if
not
zip_file
:
# XXX Do something?
rejectSoftwarePublication
(
software_publication
)
return
software_release
=
software_publication_line
.
getAggregateValue
(
portal_type
=
"Software Release"
)
from
cStringIO
import
StringIO
import
zipfile
from
zipfile
import
BadZipfile
zipbuffer
=
StringIO
()
zipbuffer
.
write
(
str
(
zip_file
.
getData
()))
zip_reader
=
zipfile
.
ZipFile
(
zipbuffer
)
user_login
=
software_publication
.
getSourceReference
()
version
=
software_release
.
getReference
()
# look for Base Directory
base
=
""
for
name
in
zip_reader
.
namelist
():
if
"/"
in
name
:
temp_base
=
name
.
split
(
"/"
)[
0
]
if
base
and
base
!=
temp_base
:
base
=
""
break
else
:
base
=
temp_base
else
:
base
=
""
break
if
base
:
base
+=
"/"
base_length
=
len
(
base
)
def
extractWebManifest
(
html_file
):
html
=
context
.
Base_parseHtml
(
html_file
)
for
tag
in
html
:
if
tag
[
0
]
==
'starttag'
and
tag
[
1
]
==
'link'
and
(
'rel'
,
'manifest'
)
in
tag
[
2
]:
for
attribute
in
tag
[
2
]:
if
attribute
[
0
]
==
'href'
:
return
attribute
[
1
]
software_release_url
=
software_release
.
getRelativeUrl
()
try
:
zip_reader
=
zipfile
.
ZipFile
(
zipbuffer
)
except
BadZipfile
:
rejectSoftwarePublication
(
software_publication
)
return
base_length
=
len
(
getBaseDirectory
(
zip_reader
.
namelist
()))
tag
=
"preparing_sr_%s"
%
software_release_url
default_page
=
""
web_manifest_url
=
None
for
name
in
zip_reader
.
namelist
():
if
zip_reader
.
getinfo
(
name
).
file_size
==
0
:
continue
...
...
@@ -89,9 +99,14 @@ for name in zip_reader.namelist():
follow_up
=
software_release_url
,
portal_type
=
"File"
,
)
try
:
publication_source_category
=
"contributor/"
+
software_publication
.
getSource
()
except
TypeError
:
rejectSoftwarePublication
(
software_publication
)
return
# XX Hackish
document
.
setCategoryList
(
document
.
getCategoryList
()
+
[
"contributor/"
+
software_publication
.
getSource
()
])
document
.
getCategoryList
()
+
[
publication_source_category
])
if
url
in
(
"index.html"
,
"index.htm"
):
default_page
=
document
.
getRelativeUrl
()
web_manifest_url
=
extractWebManifest
(
document
.
getData
())
...
...
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