[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:
EL HADJI DEM 2014-05-27 15:23:53 -04:00 committed by Sandy Carter
parent 48f3cd7a9f
commit c248a393cc
4 changed files with 44 additions and 47 deletions

View File

@ -24,9 +24,9 @@
'name': 'CMIS',
'version': '0.1',
'category': 'Connector',
'summary': 'CMIS Connector',
'summary': 'Cmis Connector',
'description': """
CMIS Connector
Cmis Connector
==============
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
------------
* El Hadji Dem <elhadji.dem@savoirfairelinux.com>
* Maxime Chambreuil <maxime.chambreuil@savoirfairelinux.com>
* El Hadji Dem (elhadji.dem@savoirfairelinux.com)
""",
'author': 'Savoir-faire Linux',
'website': 'www.savoirfairelinux.com',

View File

@ -4,7 +4,7 @@
<menuitem id="menu_cmis_root"
parent="connector.menu_connector_root"
name="CMIS"
name="Cmis"
sequence="10"
groups="connector.group_connector_manager"/>

View File

@ -53,12 +53,13 @@ class cmis_backend(orm.Model):
try:
return client.defaultRepository
except cmislib.exceptions.ObjectNotFoundException:
raise orm.except_orm(_('CMIS connection Error!'),
_("Check your CMIS account configuration."))
raise orm.except_orm(_('Cmis connection Error!'),
_("Check your cmis account configuration."))
except cmislib.exceptions.PermissionDeniedException:
raise orm.except_orm(_('CMIS connection Error!'),
_("Check your CMIS account configuration."))
raise orm.except_orm(_('Cmis connection Error!'),
_("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):
if context is None:
context = {}
@ -71,7 +72,7 @@ class cmis_backend(orm.Model):
context=context)[0]
folder_path_write = cmis_backend_rec['initial_directory_write']
# Testing the path
rs = repo.query("SELECT cmis:path FROM cmis:folder")
rs = repo.query("SELECT cmis:path FROM cmis:folder")
bool_path_write = self.check_existing_path(rs, folder_path_write)
# Check if we can create a doc from OE to EDM
# Document properties
@ -93,6 +94,7 @@ class cmis_backend(orm.Model):
("Please check your access right."))
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):
ir_attach_obj = self.pool.get('ir.attachment')
if context is None:
@ -101,33 +103,15 @@ class cmis_backend(orm.Model):
cmis_backend_rec = cmis_backend_obj.read(
cr, uid, ids, ['initial_directory_read'],
context=context)[0]
# login with the cmis account
# Login with the cmis account
repo = self._auth(cr, uid, context=context)
folder_path_read = cmis_backend_rec['initial_directory_read']
# 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)
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)
# Function to check if the path is correct
def check_existing_path(self, rs, folder_path):
for one_rs in rs:
# Print name of files
@ -139,12 +123,13 @@ class cmis_backend(orm.Model):
break
return bool
# Function to return following the boolean the right error message
def get_error_for_path(self, bool, path):
if bool:
raise orm.except_orm(_('CMIS Message'),
raise orm.except_orm(_('Cmis Message'),
_("Path is correct for : " + path))
else:
raise orm.except_orm(_('CMIS Error!'),
raise orm.except_orm(_('Cmis Error!'),
_("Error path for : " + path))
_columns = {
@ -168,6 +153,10 @@ class cmis_backend(orm.Model):
size=128,
required=True,
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 = {
'initial_directory_read': '/',

View File

@ -12,7 +12,7 @@
<h1>
<field name="name" class="oe_inline" />
</h1>
<group name="cmis" string="CMIS Configuration">
<group name="cmis" string="Cmis Configuration">
<group colspan="4" col="4">
<field name="version" colspan="4"/>
<field name="location" placeholder="e.g. http://localhost:8081/alfresco/s/cmis"
@ -22,21 +22,30 @@
</group>
</group>
<group name="directory_conf" string="Directory Configuration">
<group colspan="4" col="4">
<field name="initial_directory_write" colspan="2"/>
<field name="initial_directory_read" colspan="2"/>
<group >
<field name="browsing_ok"/>
<newline/>
<group attrs="{'invisible':[('browsing_ok','=',False)]}"
colspan="4" col="4">
<field name="initial_directory_read"/>
<button name="check_directory_of_read"
type="object"
class="oe_highlight"
string="Test Directory of read"/>
</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>
<group colspan="4" col="4">
<button name="check_directory_of_write"
type="object"
class="oe_highlight"
string="Test Directory of write"/>
<button name="check_directory_of_read"
type="object"
class="oe_highlight"
string="Test Directory of read"/>
</group>
</sheet>
</form>
</field>