[FIX] caldav: remove calendar problem
bzr revid: hmo@tinyerp.com-20100423120544-axml2owg03rwwvv0
This commit is contained in:
@@ -171,7 +171,7 @@ class node_calendar(nodes.node_class):
|
||||
self.cal_type = calendar.type
|
||||
|
||||
def _get_dav_getctag(self, cr):
|
||||
result = self.get_etag(cr)
|
||||
result = self._get_ttag(cr) + ':' + str(time.time())
|
||||
return str(result)
|
||||
|
||||
def match_dav_eprop(self, cr, match, ns, prop):
|
||||
@@ -329,6 +329,9 @@ class node_calendar(nodes.node_class):
|
||||
else: wtime = time.time()
|
||||
return str(wtime)
|
||||
|
||||
def rmcol(self, cr):
|
||||
return False
|
||||
|
||||
|
||||
class res_node_calendar(nodes.node_class):
|
||||
our_type = 'file'
|
||||
@@ -484,6 +487,20 @@ class res_node_calendar(nodes.node_class):
|
||||
return href
|
||||
|
||||
|
||||
def rm(self, cr):
|
||||
uid = self.context.uid
|
||||
res = False
|
||||
if self.type in ('collection','database'):
|
||||
return False
|
||||
if self.model and self.res_id:
|
||||
document_obj = self.context._dirobj.pool.get(self.model)
|
||||
if document_obj:
|
||||
res = False
|
||||
#res = document_obj.unlink(cr, uid, [self.res_id]) #TOFIX
|
||||
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def _get_caldav_schedule_outbox_URL(self, cr):
|
||||
return self._get_caldav_schedule_inbox_URL(cr)
|
||||
|
||||
@@ -161,6 +161,12 @@ class node_class(object):
|
||||
def get_dav_eprop(self,cr,ns,prop):
|
||||
return None
|
||||
|
||||
def rm(self, cr):
|
||||
raise RuntimeError("Not Implemented")
|
||||
|
||||
def rmcol(self, cr):
|
||||
raise RuntimeError("Not Implemented")
|
||||
|
||||
def get_domain(self, cr, filters):
|
||||
return []
|
||||
|
||||
@@ -279,6 +285,20 @@ class node_dir(node_database):
|
||||
def _child_get(self, cr, name=None, domain=None):
|
||||
return super(node_dir,self)._child_get(cr, name, self.dir_id, domain=domain)
|
||||
|
||||
def rmcol(self, cr):
|
||||
uid = self.context.uid
|
||||
directory = self.context._dirobj.browse(cr, uid, self.dir_id)
|
||||
res = False
|
||||
if not directory:
|
||||
raise OSError(2, 'Not such file or directory.')
|
||||
if directory._table_name=='document.directory':
|
||||
if self.children(cr):
|
||||
raise OSError(39, 'Directory not empty.')
|
||||
res = self.context._dirobj.unlink(cr, uid, [directory.id])
|
||||
else:
|
||||
raise OSError(1, 'Operation not permited.')
|
||||
return res
|
||||
|
||||
def create_child_collection(self, cr, objname):
|
||||
object2 = False
|
||||
dirobj = self.context._dirobj
|
||||
@@ -671,7 +691,18 @@ class node_file(node_class):
|
||||
else:
|
||||
s = StringIO.StringIO(base64.decodestring(fobj.db_datas or ''))
|
||||
s.name = self
|
||||
return s
|
||||
return s
|
||||
|
||||
def rm(self, cr):
|
||||
uid = self.context.uid
|
||||
document_obj = self.context._dirobj.pool.get('ir.attachment')
|
||||
if self.type in ('collection','database'):
|
||||
return False
|
||||
document = document_obj.browse(cr, uid, self.file_id, context=self.context.context)
|
||||
res = False
|
||||
if document and document._table_name == 'ir.attachment':
|
||||
res = document_obj.unlink(cr, uid, [document.id])
|
||||
return res
|
||||
|
||||
def fix_ppath(self, cr, fbro):
|
||||
"""Sometimes we may init this w/o path, parent.
|
||||
|
||||
@@ -433,6 +433,7 @@ class openerp_dav_handler(dav_interface):
|
||||
return 201
|
||||
|
||||
def rmcol(self,uri):
|
||||
print ' REMOVE COLLL :::::', uri
|
||||
""" delete a collection """
|
||||
if uri[-1]=='/':uri=uri[:-1]
|
||||
|
||||
@@ -440,39 +441,23 @@ class openerp_dav_handler(dav_interface):
|
||||
if not dbname: # *-*
|
||||
raise DAV_Error, 409
|
||||
node = self.uri2object(cr, uid, pool, uri2)
|
||||
object = node.context._dirobj.browse(cr, uid, node.dir_id)
|
||||
|
||||
if not object:
|
||||
raise OSError(2, 'Not such file or directory.')
|
||||
if object._table_name=='document.directory':
|
||||
if node.children(cr):
|
||||
raise OSError(39, 'Directory not empty.')
|
||||
res = pool.get('document.directory').unlink(cr, uid, [object.id])
|
||||
else:
|
||||
raise OSError(1, 'Operation not permited.')
|
||||
node.rmcol(cr)
|
||||
|
||||
cr.commit()
|
||||
cr.close()
|
||||
return 204
|
||||
|
||||
def rm(self,uri):
|
||||
if uri[-1]=='/':uri=uri[:-1]
|
||||
|
||||
object=False
|
||||
print ' REMOVE EVENT :::::', uri
|
||||
if uri[-1]=='/':uri=uri[:-1]
|
||||
cr, uid, pool,dbname, uri2 = self.get_cr(uri)
|
||||
if not dbname:
|
||||
cr.close()
|
||||
raise DAV_Error, 409
|
||||
node = self.uri2object(cr,uid,pool, uri2)
|
||||
object = pool.get('ir.attachment').browse(cr, uid, node.file_id)
|
||||
self.parent.log_message(' rm %s "%s"'%(object._table_name,uri))
|
||||
if not object:
|
||||
raise OSError(2, 'Not such file or directory.')
|
||||
if object._table_name == 'ir.attachment':
|
||||
res = pool.get('ir.attachment').unlink(cr, uid, [object.id])
|
||||
else:
|
||||
raise OSError(1, 'Operation not permited.')
|
||||
|
||||
res = node.rm(cr)
|
||||
if not res:
|
||||
raise OSError(1, 'Operation not permited.')
|
||||
cr.commit()
|
||||
cr.close()
|
||||
return 204
|
||||
|
||||
Reference in New Issue
Block a user