Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
0cfbc8ca
Commit
0cfbc8ca
authored
Oct 23, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ingestion: only consider group from user login and only consider the higher group levels
parent
e94ce2d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
6 deletions
+50
-6
bt5/erp5_ingestion/SkinTemplateItem/portal_skins/erp5_ingestion/Document_getPropertyDictFromUserLogin.xml
.../erp5_ingestion/Document_getPropertyDictFromUserLogin.xml
+15
-4
product/ERP5OOo/tests/testIngestion.py
product/ERP5OOo/tests/testIngestion.py
+35
-2
No files found.
bt5/erp5_ingestion/SkinTemplateItem/portal_skins/erp5_ingestion/Document_getPropertyDictFromUserLogin.xml
View file @
0cfbc8ca
...
...
@@ -56,11 +56,22 @@ User would be usually the current user, but sometimes the name has to be given e
if e.g. the doc is contributed by email, and the script is run by zope user.\n
"""\n
assignment_dict = context.ERP5Site_getPersonAssignmentDict(user_name=user_name)\n
group_list = assignment_dict[\'group_list\']\n
\n
# XXX: make list of properties configurable through preferences\n
return {\'group_list\': assignment_dict[\'group_list\'],\n
\'site_list\': assignment_dict[\'site_list\'],\n
\'function_list\': assignment_dict[\'function_list\']}\n
if group_list:\n
group_level_dict = {}\n
for group in group_list:\n
group_level = len(group.split("/"))\n
group_level_dict[group] = group_level\n
\n
#Get the highest levels groups of the assignments\n
##if group_list = [\'g1\', \'g1/g1.1\', \'g1/g1.2\'] returns [\'g1\']\n
##if group_list = [\'g1/g1.1\', \'g1/g1.2\'] returns [\'g1/g1.1\', \'g1/g1.2\']\n
highest_level_group_value = min(group_level_dict.itervalues())\n
highest_level_group_list = [k for k in group_level_dict if group_level_dict[k] == highest_level_group_value]\n
return {\'group_list\': highest_level_group_list}\n
\n
return {}\n
</string>
</value>
</item>
<item>
...
...
product/ERP5OOo/tests/testIngestion.py
View file @
0cfbc8ca
...
...
@@ -187,6 +187,12 @@ class TestIngestion(ERP5TypeTestCase):
,{
'path'
:
'group/anybody'
,
'title'
:
'Anybody'
}
,{
'path'
:
'group/anybody/a1'
,
'title'
:
'Anybody 1'
}
,{
'path'
:
'group/anybody/a2'
,
'title'
:
'Anybody 2'
}
,{
'path'
:
'publication_section/cop'
,
'title'
:
'COPs'
}
...
...
@@ -1464,9 +1470,36 @@ class TestIngestion(ERP5TypeTestCase):
document
.
discoverMetadata
(
document
.
getFilename
(),
'contributor1'
)
self
.
tic
()
self
.
assertEqual
(
document
.
getFilename
(),
'TEST-en-002.doc'
)
self
.
assertEqual
(
'musician/wind/saxophone'
,
document
.
getFunction
())
self
.
assertEqual
(
'anybody'
,
document
.
getGroup
())
self
.
assertEqual
(
'arctic/spitsbergen'
,
document
.
getSite
())
self
.
assertEqual
(
None
,
document
.
getFunction
())
self
.
assertEqual
(
None
,
document
.
getSite
())
def
test_TestMetadataDiscoveryFromUserLoginHigherGroup
(
self
):
portal
=
self
.
portal
contribution_tool
=
getToolByName
(
portal
,
'portal_contributions'
)
user
=
self
.
createUser
(
reference
=
'contributor3'
)
self
.
createUserAssignment
(
user
,
dict
(
group
=
'anybody/a1'
,))
self
.
createUserAssignment
(
user
,
dict
(
group
=
'anybody/a2'
,))
self
.
createUserAssignment
(
user
,
dict
(
group
=
'anybody'
,))
other_user
=
self
.
createUser
(
reference
=
'contributor2'
)
self
.
createUserAssignment
(
other_user
,
dict
(
group
=
'anybody/a1'
,))
self
.
createUserAssignment
(
other_user
,
dict
(
group
=
'anybody/a2'
,))
portal
.
document_module
.
manage_setLocalRoles
(
'contributor2'
,
[
'Assignor'
,])
self
.
tic
()
file_object
=
makeFileUpload
(
'TEST-en-002.doc'
)
document
=
contribution_tool
.
newContent
(
file
=
file_object
)
# We only consider the higher group of assignments
document
.
discoverMetadata
(
document
.
getFilename
(),
user
.
getReference
())
self
.
tic
()
self
.
assertEqual
(
document
.
getFilename
(),
'TEST-en-002.doc'
)
self
.
assertEqual
([
'anybody'
],
document
.
getGroupList
())
document
.
discoverMetadata
(
document
.
getFilename
(),
other_user
.
getReference
())
self
.
assertEqual
([
'anybody/a1'
,
'anybody/a2'
],
document
.
getGroupList
())
def
test_IngestionConfigurationByTypeBasedMethod_usecase1
(
self
):
"""How to configure meta data discovery so that each time a file
...
...
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