mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-21 19:47:24 -06:00
[IMP] Fixed comments from LP, modify check_directory_of_write,check_directory_of_write, username and password fields to be required
This commit is contained in:
parent
6d98993d4a
commit
2497bfcc41
@ -47,9 +47,6 @@ Contributors
|
|||||||
'depends': [
|
'depends': [
|
||||||
'connector',
|
'connector',
|
||||||
],
|
],
|
||||||
'external_dependencies': {
|
|
||||||
'python': ['cmislib'],
|
|
||||||
},
|
|
||||||
'data': [
|
'data': [
|
||||||
'cmis_model_view.xml',
|
'cmis_model_view.xml',
|
||||||
'cmis_menu.xml',
|
'cmis_menu.xml',
|
||||||
|
@ -66,10 +66,10 @@ class cmis_backend(orm.Model):
|
|||||||
datas_fname = 'testdoc'
|
datas_fname = 'testdoc'
|
||||||
# login with the cmis account
|
# login with the cmis account
|
||||||
repo = self._auth(cr, uid, context=context)
|
repo = self._auth(cr, uid, context=context)
|
||||||
|
cmis_backend_rec = cmis_backend_obj.read(
|
||||||
folder_path_write = cmis_backend_obj.read(
|
|
||||||
cr, uid, ids, ['initial_directory_write'],
|
cr, uid, ids, ['initial_directory_write'],
|
||||||
context=context)[0]['initial_directory_write']
|
context=context)[0]
|
||||||
|
folder_path_write = cmis_backend_rec['initial_directory_write']
|
||||||
# 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_write = self.check_existing_path(rs, folder_path_write)
|
bool_path_write = self.check_existing_path(rs, folder_path_write)
|
||||||
@ -77,10 +77,20 @@ class cmis_backend(orm.Model):
|
|||||||
# Document properties
|
# Document properties
|
||||||
if bool_path_write:
|
if bool_path_write:
|
||||||
sub = repo.getObjectByPath(folder_path_write)
|
sub = repo.getObjectByPath(folder_path_write)
|
||||||
sub.createDocumentFromString(
|
try:
|
||||||
datas_fname,
|
sub.createDocumentFromString(
|
||||||
contentString='hello, world',
|
datas_fname,
|
||||||
contentType='text/plain')
|
contentString='hello, world',
|
||||||
|
contentType='text/plain')
|
||||||
|
except cmislib.exceptions.UpdateConflictException:
|
||||||
|
raise orm.except_orm(
|
||||||
|
_('Cmis Error!'),
|
||||||
|
_("The test file is already existed in DMS. "
|
||||||
|
"Please remove it and try again."))
|
||||||
|
except cmislib.exceptions.RuntimeException:
|
||||||
|
raise orm.except_orm(
|
||||||
|
_('Cmis access right Error!'),
|
||||||
|
("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)
|
||||||
|
|
||||||
def check_directory_of_read(self, cr, uid, ids, context=None):
|
def check_directory_of_read(self, cr, uid, ids, context=None):
|
||||||
@ -88,11 +98,12 @@ class cmis_backend(orm.Model):
|
|||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
cmis_backend_obj = self.pool.get('cmis.backend')
|
cmis_backend_obj = self.pool.get('cmis.backend')
|
||||||
|
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)
|
repo = self._auth(cr, uid, context=context)
|
||||||
folder_path_read = cmis_backend_obj.read(
|
folder_path_read = cmis_backend_rec['initial_directory_read']
|
||||||
cr, uid, ids, ['initial_directory_read'],
|
|
||||||
context=context)[0]['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)
|
||||||
@ -101,8 +112,8 @@ class cmis_backend(orm.Model):
|
|||||||
context['bool_testdoc'] = True
|
context['bool_testdoc'] = True
|
||||||
if bool_path_read:
|
if bool_path_read:
|
||||||
# Get results from name of document
|
# Get results from name of document
|
||||||
results = repo.query(" SELECT * FROM cmis:document \
|
results = repo.query(" SELECT * FROM cmis:document "
|
||||||
WHERE cmis:name LIKE '%" + file_name + "%'")
|
"WHERE cmis:name LIKE '%" + file_name + "%'")
|
||||||
for result in results:
|
for result in results:
|
||||||
info = result.getProperties()
|
info = result.getProperties()
|
||||||
data_attach = {
|
data_attach = {
|
||||||
@ -112,6 +123,9 @@ class cmis_backend(orm.Model):
|
|||||||
'datas': result.getContentStream().read().encode('base64'),
|
'datas': result.getContentStream().read().encode('base64'),
|
||||||
}
|
}
|
||||||
ir_attach_obj.create(cr, uid, data_attach, context=context)
|
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)
|
||||||
|
|
||||||
def check_existing_path(self, rs, folder_path):
|
def check_existing_path(self, rs, folder_path):
|
||||||
@ -138,19 +152,24 @@ class cmis_backend(orm.Model):
|
|||||||
_select_versions,
|
_select_versions,
|
||||||
string='Version',
|
string='Version',
|
||||||
required=True),
|
required=True),
|
||||||
'location': fields.char('Location', size=128, help="Location."),
|
'location': fields.char('Location', size=128, required=True,
|
||||||
'username': fields.char('Username', size=64, help="Username."),
|
help="Location."),
|
||||||
'password': fields.char('Password', size=64, help="Password."),
|
'username': fields.char('Username', size=64, required=True,
|
||||||
|
help="Username."),
|
||||||
|
'password': fields.char('Password', size=64, required=True,
|
||||||
|
help="Password."),
|
||||||
'initial_directory_read': fields.char(
|
'initial_directory_read': fields.char(
|
||||||
'Initial directory of read',
|
'Initial directory of read',
|
||||||
size=128,
|
size=128,
|
||||||
|
required=True,
|
||||||
help="Initial directory of read."),
|
help="Initial directory of read."),
|
||||||
'initial_directory_write': fields.char(
|
'initial_directory_write': fields.char(
|
||||||
'Initial directory of write',
|
'Initial directory of write',
|
||||||
size=128,
|
size=128,
|
||||||
|
required=True,
|
||||||
help="Initial directory of write."),
|
help="Initial directory of write."),
|
||||||
}
|
}
|
||||||
_default = {
|
_defaults = {
|
||||||
'initial_directory_read': '/',
|
'initial_directory_read': '/',
|
||||||
'initial_directory_write': '/',
|
'initial_directory_write': '/',
|
||||||
}
|
}
|
||||||
|
@ -23,21 +23,19 @@
|
|||||||
</group>
|
</group>
|
||||||
<group name="directory_conf" string="Directory Configuration">
|
<group name="directory_conf" string="Directory Configuration">
|
||||||
<group colspan="4" col="4">
|
<group colspan="4" col="4">
|
||||||
<field name="initial_directory_read" colspan="2"/>
|
|
||||||
<field name="initial_directory_write" colspan="2"/>
|
<field name="initial_directory_write" colspan="2"/>
|
||||||
|
<field name="initial_directory_read" colspan="2"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group colspan="4" col="4">
|
<group colspan="4" col="4">
|
||||||
<div>
|
|
||||||
<button name="check_directory_of_read"
|
|
||||||
type="object"
|
|
||||||
class="oe_highlight"
|
|
||||||
string="Test Directory of read"/>
|
|
||||||
<button name="check_directory_of_write"
|
<button name="check_directory_of_write"
|
||||||
type="object"
|
type="object"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
string="Test Directory of write"/>
|
string="Test Directory of write"/>
|
||||||
</div>
|
<button name="check_directory_of_read"
|
||||||
|
type="object"
|
||||||
|
class="oe_highlight"
|
||||||
|
string="Test Directory of read"/>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp.osv import orm, fields
|
|
||||||
from openerp.addons.connector.connector import (Environment,
|
from openerp.addons.connector.connector import (Environment,
|
||||||
install_in_connector)
|
install_in_connector)
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ class test_model(TransactionCase):
|
|||||||
'location': "http://localhost:8081/alfresco/s/cmis",
|
'location': "http://localhost:8081/alfresco/s/cmis",
|
||||||
'username': 'admin',
|
'username': 'admin',
|
||||||
'password': 'admin',
|
'password': 'admin',
|
||||||
|
'initial_directory_read': '/',
|
||||||
|
'initial_directory_write': '/',
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_create_model(self):
|
def test_create_model(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user