mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-25 01:48:41 -06:00
[IMP] take Comments from LP
This commit is contained in:
parent
05f7d9ebf8
commit
6d98993d4a
@ -20,13 +20,9 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp.osv import orm, fields, osv
|
from openerp.osv import orm, fields
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.addons.connector.queue.job import job
|
|
||||||
from cmislib.model import CmisClient
|
from cmislib.model import CmisClient
|
||||||
import openerp.addons.connector as connector
|
|
||||||
from openerp.addons.connector.session import ConnectorSession
|
|
||||||
import base64
|
|
||||||
import cmislib.exceptions
|
import cmislib.exceptions
|
||||||
|
|
||||||
|
|
||||||
@ -57,10 +53,10 @@ class cmis_backend(orm.Model):
|
|||||||
try:
|
try:
|
||||||
return client.defaultRepository
|
return client.defaultRepository
|
||||||
except cmislib.exceptions.ObjectNotFoundException:
|
except cmislib.exceptions.ObjectNotFoundException:
|
||||||
raise osv.except_osv(_('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 osv.except_osv(_('Cmis connection Error!'),
|
raise orm.except_orm(_('Cmis connection Error!'),
|
||||||
_("Check your cmis account configuration."))
|
_("Check your cmis account configuration."))
|
||||||
|
|
||||||
def check_directory_of_write(self, cr, uid, ids, context=None):
|
def check_directory_of_write(self, cr, uid, ids, context=None):
|
||||||
@ -68,7 +64,7 @@ class cmis_backend(orm.Model):
|
|||||||
context = {}
|
context = {}
|
||||||
cmis_backend_obj = self.pool.get('cmis.backend')
|
cmis_backend_obj = self.pool.get('cmis.backend')
|
||||||
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)
|
||||||
|
|
||||||
folder_path_write = cmis_backend_obj.read(
|
folder_path_write = cmis_backend_obj.read(
|
||||||
@ -81,7 +77,7 @@ 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)
|
||||||
someDoc = sub.createDocumentFromString(
|
sub.createDocumentFromString(
|
||||||
datas_fname,
|
datas_fname,
|
||||||
contentString='hello, world',
|
contentString='hello, world',
|
||||||
contentType='text/plain')
|
contentType='text/plain')
|
||||||
@ -89,12 +85,10 @@ class cmis_backend(orm.Model):
|
|||||||
|
|
||||||
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')
|
||||||
ir_attach_dms_obj = self.pool.get('ir.attachment.dms')
|
|
||||||
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')
|
||||||
#login with the cmis account
|
# 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_obj.read(
|
||||||
cr, uid, ids, ['initial_directory_read'],
|
cr, uid, ids, ['initial_directory_read'],
|
||||||
@ -117,8 +111,7 @@ class cmis_backend(orm.Model):
|
|||||||
'type': 'binary',
|
'type': 'binary',
|
||||||
'datas': result.getContentStream().read().encode('base64'),
|
'datas': result.getContentStream().read().encode('base64'),
|
||||||
}
|
}
|
||||||
res = ir_attach_obj.create(cr, uid, data_attach,
|
ir_attach_obj.create(cr, uid, data_attach, context=context)
|
||||||
context=context)
|
|
||||||
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):
|
||||||
@ -134,10 +127,10 @@ class cmis_backend(orm.Model):
|
|||||||
|
|
||||||
def get_error_for_path(self, bool, path):
|
def get_error_for_path(self, bool, path):
|
||||||
if bool:
|
if bool:
|
||||||
raise osv.except_osv(_('Cmis Message'),
|
raise orm.except_orm(_('Cmis Message'),
|
||||||
_("Path is correct for : " + path))
|
_("Path is correct for : " + path))
|
||||||
else:
|
else:
|
||||||
raise osv.except_osv(_('Cmis Error!'),
|
raise orm.except_orm(_('Cmis Error!'),
|
||||||
_("Error path for : " + path))
|
_("Error path for : " + path))
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
|
2
cmis/security/ir.model.access.csv
Normal file
2
cmis/security/ir.model.access.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||||
|
access_cmis_backend_user,access_cmis_backend_user,model_cmis_backend,base.group_user,1,0,0,0
|
|
29
cmis/tests/__init__.py
Normal file
29
cmis/tests/__init__.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# This module copyright (C) 2013-2014 Savoir-faire Linux
|
||||||
|
# (<http://www.savoirfairelinux.com>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
from . import (
|
||||||
|
test_model,
|
||||||
|
)
|
||||||
|
|
||||||
|
checks = [
|
||||||
|
test_model,
|
||||||
|
]
|
49
cmis/tests/test_model.py
Normal file
49
cmis/tests/test_model.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# This module copyright (C) 2010 - 2014 Savoir-faire Linux
|
||||||
|
# (<http://www.savoirfairelinux.com>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
from openerp.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
|
class test_model(TransactionCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(test_model, self).setUp()
|
||||||
|
# Clean up registries
|
||||||
|
self.registry('ir.model').clear_caches()
|
||||||
|
self.registry('ir.model.data').clear_caches()
|
||||||
|
# Get registries
|
||||||
|
self.model = self.registry("cmis.backend")
|
||||||
|
# Get context
|
||||||
|
self.context = self.model.context_get(self.cr, self.uid)
|
||||||
|
|
||||||
|
self.vals = {
|
||||||
|
'name': "Test cmis",
|
||||||
|
'version': '1.0',
|
||||||
|
'location': "http://localhost:8081/alfresco/s/cmis",
|
||||||
|
'username': 'admin',
|
||||||
|
'password': 'admin',
|
||||||
|
}
|
||||||
|
|
||||||
|
def test_create_model(self):
|
||||||
|
model_id = self.model.create(
|
||||||
|
self.cr, self.uid, self.vals, context=self.context)
|
||||||
|
self.assertTrue(model_id)
|
Loading…
Reference in New Issue
Block a user