summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry (Open ERP) <hmo@tinyerp.com>2010-04-23 17:35:44 +0530
committerHarry (Open ERP) <hmo@tinyerp.com>2010-04-23 17:35:44 +0530
commit199ac22a962e89eee314254846cfbb95aaa6d99d (patch)
tree3315d35692fa3f4e8d4f3ff03096c7b62848aa14
parent65ed78ef9172300bdd03c02c27d8aed1c75fcebc (diff)
[FIX] caldav: remove calendar problem
bzr revid: hmo@tinyerp.com-20100423120544-axml2owg03rwwvv0
-rw-r--r--addons/caldav/caldav_node.py19
-rw-r--r--addons/document/nodes.py33
-rw-r--r--addons/document_webdav/dav_fs.py29
3 files changed, 57 insertions, 24 deletions
diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py
index fb6f3393bf3..8ec7422a045 100644
--- a/addons/caldav/caldav_node.py
+++ b/addons/caldav/caldav_node.py
@@ -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)
diff --git a/addons/document/nodes.py b/addons/document/nodes.py
index e74389dd0d4..d0815ef9c74 100644
--- a/addons/document/nodes.py
+++ b/addons/document/nodes.py
@@ -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.
diff --git a/addons/document_webdav/dav_fs.py b/addons/document_webdav/dav_fs.py
index bfe9729a194..0c2e52c8df7 100644
--- a/addons/document_webdav/dav_fs.py
+++ b/addons/document_webdav/dav_fs.py
@@ -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