mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-17 04:32:55 -06:00
[IMP] Change the form view,add two booleans fields to check the write access right and the read access right
This commit is contained in:
parent
48f3cd7a9f
commit
c248a393cc
@ -24,9 +24,9 @@
|
|||||||
'name': 'CMIS',
|
'name': 'CMIS',
|
||||||
'version': '0.1',
|
'version': '0.1',
|
||||||
'category': 'Connector',
|
'category': 'Connector',
|
||||||
'summary': 'CMIS Connector',
|
'summary': 'Cmis Connector',
|
||||||
'description': """
|
'description': """
|
||||||
CMIS Connector
|
Cmis Connector
|
||||||
==============
|
==============
|
||||||
|
|
||||||
This module is the base for OpenERP modules implementing different integration scenario with a CMIS server.
|
This module is the base for OpenERP modules implementing different integration scenario with a CMIS server.
|
||||||
@ -39,8 +39,7 @@ Create a new CMIS backend with the host, login and password.
|
|||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
* El Hadji Dem <elhadji.dem@savoirfairelinux.com>
|
* El Hadji Dem (elhadji.dem@savoirfairelinux.com)
|
||||||
* Maxime Chambreuil <maxime.chambreuil@savoirfairelinux.com>
|
|
||||||
""",
|
""",
|
||||||
'author': 'Savoir-faire Linux',
|
'author': 'Savoir-faire Linux',
|
||||||
'website': 'www.savoirfairelinux.com',
|
'website': 'www.savoirfairelinux.com',
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<menuitem id="menu_cmis_root"
|
<menuitem id="menu_cmis_root"
|
||||||
parent="connector.menu_connector_root"
|
parent="connector.menu_connector_root"
|
||||||
name="CMIS"
|
name="Cmis"
|
||||||
sequence="10"
|
sequence="10"
|
||||||
groups="connector.group_connector_manager"/>
|
groups="connector.group_connector_manager"/>
|
||||||
|
|
||||||
|
@ -53,12 +53,13 @@ class cmis_backend(orm.Model):
|
|||||||
try:
|
try:
|
||||||
return client.defaultRepository
|
return client.defaultRepository
|
||||||
except cmislib.exceptions.ObjectNotFoundException:
|
except cmislib.exceptions.ObjectNotFoundException:
|
||||||
raise orm.except_orm(_('CMIS connection Error!'),
|
raise orm.except_orm(_('Cmis connection Error!'),
|
||||||
_("Check your CMIS account configuration."))
|
_("Check your cmis account configuration."))
|
||||||
except cmislib.exceptions.PermissionDeniedException:
|
except cmislib.exceptions.PermissionDeniedException:
|
||||||
raise orm.except_orm(_('CMIS connection Error!'),
|
raise orm.except_orm(_('Cmis connection Error!'),
|
||||||
_("Check your CMIS account configuration."))
|
_("Check your cmis account configuration."))
|
||||||
|
|
||||||
|
# Function to check if we have access right to write from the path
|
||||||
def check_directory_of_write(self, cr, uid, ids, context=None):
|
def check_directory_of_write(self, cr, uid, ids, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
@ -93,6 +94,7 @@ class cmis_backend(orm.Model):
|
|||||||
("Please check your access right."))
|
("Please check your access right."))
|
||||||
self.get_error_for_path(bool_path_write, folder_path_write)
|
self.get_error_for_path(bool_path_write, folder_path_write)
|
||||||
|
|
||||||
|
# Function to check if we have access right to read from the path
|
||||||
def check_directory_of_read(self, cr, uid, ids, context=None):
|
def check_directory_of_read(self, cr, uid, ids, context=None):
|
||||||
ir_attach_obj = self.pool.get('ir.attachment')
|
ir_attach_obj = self.pool.get('ir.attachment')
|
||||||
if context is None:
|
if context is None:
|
||||||
@ -101,33 +103,15 @@ class cmis_backend(orm.Model):
|
|||||||
cmis_backend_rec = cmis_backend_obj.read(
|
cmis_backend_rec = cmis_backend_obj.read(
|
||||||
cr, uid, ids, ['initial_directory_read'],
|
cr, uid, ids, ['initial_directory_read'],
|
||||||
context=context)[0]
|
context=context)[0]
|
||||||
# login with the cmis account
|
# Login with the cmis account
|
||||||
repo = self._auth(cr, uid, context=context)
|
repo = self._auth(cr, uid, context=context)
|
||||||
folder_path_read = cmis_backend_rec['initial_directory_read']
|
folder_path_read = cmis_backend_rec['initial_directory_read']
|
||||||
# Testing the path
|
# Testing the path
|
||||||
rs = repo.query("SELECT cmis:path FROM cmis:folder ")
|
rs = repo.query("SELECT cmis:path FROM cmis:folder ")
|
||||||
bool_path_read = self.check_existing_path(rs, folder_path_read)
|
bool_path_read = self.check_existing_path(rs, folder_path_read)
|
||||||
file_name = 'testdoc'
|
|
||||||
# Add testdoc in the context just to check if it is as test
|
|
||||||
context['bool_testdoc'] = True
|
|
||||||
if bool_path_read:
|
|
||||||
# Get results from name of document
|
|
||||||
results = repo.query(" SELECT * FROM cmis:document "
|
|
||||||
"WHERE cmis:name LIKE '%" + file_name + "%'")
|
|
||||||
for result in results:
|
|
||||||
info = result.getProperties()
|
|
||||||
data_attach = {
|
|
||||||
'name': info['cmis:name'],
|
|
||||||
'datas_fname': info['cmis:name'],
|
|
||||||
'type': 'binary',
|
|
||||||
'datas': result.getContentStream().read().encode('base64'),
|
|
||||||
}
|
|
||||||
ir_attach_obj.create(cr, uid, data_attach, context=context)
|
|
||||||
# Remove the test doc
|
|
||||||
doc_to_remove = repo.getObjectByPath(folder_path_read
|
|
||||||
+ file_name).delete()
|
|
||||||
self.get_error_for_path(bool_path_read, folder_path_read)
|
self.get_error_for_path(bool_path_read, folder_path_read)
|
||||||
|
|
||||||
|
# Function to check if the path is correct
|
||||||
def check_existing_path(self, rs, folder_path):
|
def check_existing_path(self, rs, folder_path):
|
||||||
for one_rs in rs:
|
for one_rs in rs:
|
||||||
# Print name of files
|
# Print name of files
|
||||||
@ -139,12 +123,13 @@ class cmis_backend(orm.Model):
|
|||||||
break
|
break
|
||||||
return bool
|
return bool
|
||||||
|
|
||||||
|
# Function to return following the boolean the right error message
|
||||||
def get_error_for_path(self, bool, path):
|
def get_error_for_path(self, bool, path):
|
||||||
if bool:
|
if bool:
|
||||||
raise orm.except_orm(_('CMIS Message'),
|
raise orm.except_orm(_('Cmis Message'),
|
||||||
_("Path is correct for : " + path))
|
_("Path is correct for : " + path))
|
||||||
else:
|
else:
|
||||||
raise orm.except_orm(_('CMIS Error!'),
|
raise orm.except_orm(_('Cmis Error!'),
|
||||||
_("Error path for : " + path))
|
_("Error path for : " + path))
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
@ -168,6 +153,10 @@ class cmis_backend(orm.Model):
|
|||||||
size=128,
|
size=128,
|
||||||
required=True,
|
required=True,
|
||||||
help="Initial directory of write."),
|
help="Initial directory of write."),
|
||||||
|
'browsing_ok': fields.boolean('Allow browsing in this backend',
|
||||||
|
help="Allow browsing in this backend."),
|
||||||
|
'storing_ok': fields.boolean('Allow storing in this backend',
|
||||||
|
help="Allow storing in this backend."),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'initial_directory_read': '/',
|
'initial_directory_read': '/',
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<h1>
|
<h1>
|
||||||
<field name="name" class="oe_inline" />
|
<field name="name" class="oe_inline" />
|
||||||
</h1>
|
</h1>
|
||||||
<group name="cmis" string="CMIS Configuration">
|
<group name="cmis" string="Cmis Configuration">
|
||||||
<group colspan="4" col="4">
|
<group colspan="4" col="4">
|
||||||
<field name="version" colspan="4"/>
|
<field name="version" colspan="4"/>
|
||||||
<field name="location" placeholder="e.g. http://localhost:8081/alfresco/s/cmis"
|
<field name="location" placeholder="e.g. http://localhost:8081/alfresco/s/cmis"
|
||||||
@ -22,21 +22,30 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group name="directory_conf" string="Directory Configuration">
|
<group name="directory_conf" string="Directory Configuration">
|
||||||
<group colspan="4" col="4">
|
<group >
|
||||||
<field name="initial_directory_write" colspan="2"/>
|
<field name="browsing_ok"/>
|
||||||
<field name="initial_directory_read" colspan="2"/>
|
<newline/>
|
||||||
</group>
|
<group attrs="{'invisible':[('browsing_ok','=',False)]}"
|
||||||
</group>
|
colspan="4" col="4">
|
||||||
<group colspan="4" col="4">
|
<field name="initial_directory_read"/>
|
||||||
<button name="check_directory_of_write"
|
|
||||||
type="object"
|
|
||||||
class="oe_highlight"
|
|
||||||
string="Test Directory of write"/>
|
|
||||||
<button name="check_directory_of_read"
|
<button name="check_directory_of_read"
|
||||||
type="object"
|
type="object"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
string="Test Directory of read"/>
|
string="Test Directory of read"/>
|
||||||
</group>
|
</group>
|
||||||
|
<newline/>
|
||||||
|
<field name="storing_ok"/>
|
||||||
|
<newline/>
|
||||||
|
<group attrs="{'invisible':[('storing_ok','=',False)]}"
|
||||||
|
colspan="4" col="4">
|
||||||
|
<field name="initial_directory_write"/>
|
||||||
|
<button name="check_directory_of_write"
|
||||||
|
type="object"
|
||||||
|
class="oe_highlight"
|
||||||
|
string="Test Directory of write"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
Loading…
Reference in New Issue
Block a user