2010-02-01 13:54:53 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
2010-03-25 12:07:00 +00:00
|
|
|
#
|
2010-02-01 13:54:53 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
|
|
|
#
|
|
|
|
# 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
|
2010-03-25 12:07:00 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-02-01 13:54:53 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
from osv import osv, fields
|
|
|
|
from tools.translate import _
|
|
|
|
import pooler
|
|
|
|
import tools
|
|
|
|
import time
|
2010-04-13 11:03:20 +00:00
|
|
|
from document import nodes
|
|
|
|
import StringIO
|
2010-02-01 13:54:53 +00:00
|
|
|
|
2010-04-13 11:03:20 +00:00
|
|
|
class node_database(nodes.node_database):
|
|
|
|
def _child_get(self, cr, name=False, parent_id=False, domain=None):
|
|
|
|
dirobj = self.context._dirobj
|
|
|
|
uid = self.context.uid
|
|
|
|
ctx = self.context.context.copy()
|
|
|
|
ctx.update(self.dctx)
|
|
|
|
if not domain:
|
|
|
|
domain = []
|
|
|
|
domain2 = domain + [('calendar_collection','=', False)]
|
|
|
|
res = super(node_database, self)._child_get(cr, name=name, parent_id=parent_id, domain=domain2)
|
2010-07-29 13:39:36 +00:00
|
|
|
where = [('parent_id','=',parent_id)]
|
|
|
|
domain2 = domain + [('calendar_collection','=', True)]
|
2010-04-13 11:03:20 +00:00
|
|
|
if name:
|
|
|
|
where.append(('name','=',name))
|
|
|
|
if domain2:
|
|
|
|
where += domain2
|
2010-03-25 12:07:00 +00:00
|
|
|
|
2010-04-13 11:03:20 +00:00
|
|
|
where2 = where + [('type', '=', 'directory')]
|
2010-07-29 13:39:36 +00:00
|
|
|
ids = dirobj.search(cr, uid, where2, context=ctx)
|
|
|
|
for dirr in dirobj.browse(cr,uid,ids,context=ctx):
|
2010-04-13 11:03:20 +00:00
|
|
|
res.append(node_calendar_collection(dirr.name,self,self.context,dirr))
|
|
|
|
return res
|
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
class node_calendar_collection(nodes.node_dir):
|
2010-07-29 13:39:36 +00:00
|
|
|
DAV_PROPS = {
|
2010-07-29 13:39:37 +00:00
|
|
|
"http://calendarserver.org/ns/" : ('getctag',),
|
2010-07-29 13:39:36 +00:00
|
|
|
}
|
2010-07-29 13:39:36 +00:00
|
|
|
DAV_M_NS = {
|
2010-04-14 07:36:16 +00:00
|
|
|
"http://calendarserver.org/ns/" : '_get_dav',
|
2010-07-29 13:39:36 +00:00
|
|
|
}
|
2010-04-22 12:50:41 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
http_options = { 'DAV': ['calendar-access'] }
|
2010-04-22 12:50:41 +00:00
|
|
|
|
2010-04-15 07:58:09 +00:00
|
|
|
def _file_get(self,cr, nodename=False):
|
2010-04-22 12:50:41 +00:00
|
|
|
return []
|
2010-04-15 07:58:09 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def _child_get(self, cr, name=False, parent_id=False, domain=None):
|
2010-04-22 12:50:41 +00:00
|
|
|
dirobj = self.context._dirobj
|
2010-04-21 13:34:02 +00:00
|
|
|
uid = self.context.uid
|
2010-04-22 12:50:41 +00:00
|
|
|
ctx = self.context.context.copy()
|
|
|
|
ctx.update(self.dctx)
|
2010-07-29 13:39:36 +00:00
|
|
|
where = [('collection_id','=',self.dir_id)]
|
|
|
|
ext = False
|
2010-07-29 13:39:38 +00:00
|
|
|
if name and name.endswith('.ics'):
|
2010-08-10 12:29:57 +00:00
|
|
|
name = name[:-4]
|
|
|
|
ext = True
|
2010-07-29 13:39:36 +00:00
|
|
|
if name:
|
2010-04-22 12:50:41 +00:00
|
|
|
where.append(('name','=',name))
|
|
|
|
if not domain:
|
2010-07-29 13:39:36 +00:00
|
|
|
domain = []
|
2010-04-22 12:50:41 +00:00
|
|
|
where = where + domain
|
2010-07-29 13:39:36 +00:00
|
|
|
fil_obj = dirobj.pool.get('basic.calendar')
|
2010-04-22 12:50:41 +00:00
|
|
|
ids = fil_obj.search(cr,uid,where,context=ctx)
|
|
|
|
res = []
|
2010-08-10 12:29:57 +00:00
|
|
|
for cal in fil_obj.browse(cr, uid, ids, context=ctx):
|
|
|
|
if (not name) or not ext:
|
|
|
|
res.append(node_calendar(cal.name, self, self.context, cal))
|
|
|
|
if (not name) or ext:
|
|
|
|
res.append(res_node_calendar(cal.name+'.ics', self, self.context, cal))
|
2010-08-12 11:10:18 +00:00
|
|
|
# May be both of them!
|
2010-04-21 13:34:02 +00:00
|
|
|
return res
|
|
|
|
|
2010-04-22 12:50:41 +00:00
|
|
|
def _get_dav_owner(self, cr):
|
2010-08-12 11:10:18 +00:00
|
|
|
# Todo?
|
2010-04-22 12:50:41 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
def _get_ttag(self, cr):
|
2010-07-29 13:39:37 +00:00
|
|
|
return 'calen-dir-%d' % self.dir_id
|
2010-04-22 12:50:41 +00:00
|
|
|
|
|
|
|
def _get_dav_getctag(self, cr):
|
2010-07-29 13:39:36 +00:00
|
|
|
result = self.get_etag(cr)
|
|
|
|
return str(result)
|
2010-04-22 12:50:41 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
class node_calendar(nodes.node_class):
|
|
|
|
our_type = 'collection'
|
2010-07-29 13:39:36 +00:00
|
|
|
DAV_PROPS = {
|
2010-07-29 13:39:37 +00:00
|
|
|
"http://calendarserver.org/ns/" : ('getctag',),
|
2010-07-29 13:39:37 +00:00
|
|
|
'http://groupdav.org/': ('resourcetype',),
|
2010-04-22 12:50:41 +00:00
|
|
|
"urn:ietf:params:xml:ns:caldav" : (
|
|
|
|
'calendar-description',
|
|
|
|
'calendar-data',
|
|
|
|
'calendar-home-set',
|
|
|
|
'calendar-user-address-set',
|
|
|
|
'schedule-inbox-URL',
|
|
|
|
'schedule-outbox-URL',)}
|
2010-07-29 13:39:36 +00:00
|
|
|
DAV_M_NS = {
|
2010-07-29 13:39:36 +00:00
|
|
|
"DAV:" : '_get_dav',
|
2010-07-29 13:39:37 +00:00
|
|
|
'http://groupdav.org/': '_get_gdav',
|
2010-04-22 12:50:41 +00:00
|
|
|
"http://calendarserver.org/ns/" : '_get_dav',
|
2010-07-29 13:39:36 +00:00
|
|
|
"urn:ietf:params:xml:ns:caldav" : '_get_caldav'}
|
2010-04-22 12:50:41 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
http_options = { 'DAV': ['calendar-access'] }
|
|
|
|
|
2010-04-22 12:50:41 +00:00
|
|
|
def __init__(self,path, parent, context, calendar):
|
|
|
|
super(node_calendar,self).__init__(path, parent,context)
|
|
|
|
self.calendar_id = calendar.id
|
|
|
|
self.mimetype = 'application/x-directory'
|
|
|
|
self.create_date = calendar.create_date
|
|
|
|
self.write_date = calendar.write_date or calendar.create_date
|
|
|
|
self.content_length = 0
|
|
|
|
self.displayname = calendar.name
|
|
|
|
self.cal_type = calendar.type
|
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def _get_dav_getctag(self, cr):
|
2010-04-23 12:05:44 +00:00
|
|
|
result = self._get_ttag(cr) + ':' + str(time.time())
|
2010-07-29 13:39:36 +00:00
|
|
|
return str(result)
|
2010-04-15 07:58:09 +00:00
|
|
|
|
2010-08-01 08:37:26 +00:00
|
|
|
def get_dav_resourcetype(self, cr):
|
|
|
|
res = [ ('collection', 'DAV:'),
|
|
|
|
(str(self.cal_type + '-collection'), 'http://groupdav.org/'),
|
|
|
|
('calendar', 'urn:ietf:params:xml:ns:caldav') ]
|
2010-07-29 13:39:36 +00:00
|
|
|
return res
|
|
|
|
|
|
|
|
def get_domain(self, cr, filters):
|
2010-07-29 13:39:37 +00:00
|
|
|
# TODO: doc.
|
2010-04-15 07:58:09 +00:00
|
|
|
res = []
|
2010-07-29 13:39:37 +00:00
|
|
|
# dirobj = self.context._dirobj
|
|
|
|
#uid = self.context.uid
|
|
|
|
#ctx = self.context.context.copy()
|
|
|
|
#ctx.update(self.dctx)
|
|
|
|
# calendar_obj = dirobj.pool.get('basic.calendar')
|
2010-04-15 07:58:09 +00:00
|
|
|
if not filters:
|
|
|
|
return res
|
2010-07-29 13:39:36 +00:00
|
|
|
if filters.localName == 'calendar-query':
|
2010-04-15 07:58:09 +00:00
|
|
|
res = []
|
|
|
|
for filter_child in filters.childNodes:
|
|
|
|
if filter_child.nodeType == filter_child.TEXT_NODE:
|
2010-07-29 13:39:36 +00:00
|
|
|
continue
|
|
|
|
if filter_child.localName == 'filter':
|
2010-04-15 07:58:09 +00:00
|
|
|
for vcalendar_filter in filter_child.childNodes:
|
2010-07-29 13:39:36 +00:00
|
|
|
if vcalendar_filter.nodeType == vcalendar_filter.TEXT_NODE:
|
2010-04-15 07:58:09 +00:00
|
|
|
continue
|
|
|
|
if vcalendar_filter.localName == 'comp-filter':
|
|
|
|
if vcalendar_filter.getAttribute('name') == 'VCALENDAR':
|
|
|
|
for vevent_filter in vcalendar_filter.childNodes:
|
|
|
|
if vevent_filter.nodeType == vevent_filter.TEXT_NODE:
|
|
|
|
continue
|
|
|
|
if vevent_filter.localName == 'comp-filter':
|
2010-07-29 13:39:36 +00:00
|
|
|
if vevent_filter.getAttribute('name') == 'VEVENT':
|
2010-04-15 07:58:09 +00:00
|
|
|
res = [('type','=','vevent')]
|
|
|
|
if vevent_filter.getAttribute('name') == 'VTODO':
|
2010-07-29 13:39:36 +00:00
|
|
|
res = [('type','=','vtodo')]
|
2010-04-15 07:58:09 +00:00
|
|
|
return res
|
|
|
|
elif filters.localName == 'calendar-multiget':
|
2010-04-22 12:50:41 +00:00
|
|
|
names = []
|
2010-04-15 07:58:09 +00:00
|
|
|
for filter_child in filters.childNodes:
|
|
|
|
if filter_child.nodeType == filter_child.TEXT_NODE:
|
|
|
|
continue
|
|
|
|
if filter_child.localName == 'href':
|
|
|
|
if not filter_child.firstChild:
|
|
|
|
continue
|
2010-07-29 13:39:36 +00:00
|
|
|
uri = filter_child.firstChild.data
|
2010-04-15 07:58:09 +00:00
|
|
|
caluri = uri.split('/')
|
|
|
|
if len(caluri):
|
2010-04-22 12:50:41 +00:00
|
|
|
caluri = caluri[-2]
|
|
|
|
if caluri not in names : names.append(caluri)
|
|
|
|
res = [('name','in',names)]
|
|
|
|
return res
|
2010-07-29 13:39:36 +00:00
|
|
|
return res
|
2010-04-22 12:50:41 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def children(self, cr, domain=None):
|
2010-04-22 12:50:41 +00:00
|
|
|
return self._child_get(cr, domain=domain)
|
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def child(self,cr, name, domain=None):
|
|
|
|
res = self._child_get(cr, name, domain=domain)
|
2010-04-22 12:50:41 +00:00
|
|
|
if res:
|
|
|
|
return res[0]
|
2010-07-29 13:39:36 +00:00
|
|
|
return None
|
2010-04-22 12:50:41 +00:00
|
|
|
|
2010-04-15 07:58:09 +00:00
|
|
|
|
2010-04-13 11:03:20 +00:00
|
|
|
def _child_get(self, cr, name=False, parent_id=False, domain=None):
|
|
|
|
dirobj = self.context._dirobj
|
|
|
|
uid = self.context.uid
|
|
|
|
ctx = self.context.context.copy()
|
2010-07-29 13:39:36 +00:00
|
|
|
ctx.update(self.dctx)
|
|
|
|
where = []
|
|
|
|
if name:
|
2010-07-29 13:39:38 +00:00
|
|
|
if name.endswith('.ics'):
|
|
|
|
name = name[:-4]
|
2010-08-12 11:10:18 +00:00
|
|
|
try:
|
|
|
|
where.append(('id','=',int(name)))
|
|
|
|
except ValueError:
|
|
|
|
# if somebody requests any other name than the ones we
|
|
|
|
# generate (non-numeric), it just won't exist
|
|
|
|
# FIXME: however, this confuses Evolution (at least), which
|
|
|
|
# thinks the .ics node hadn't been saved.
|
|
|
|
return []
|
|
|
|
|
2010-04-13 11:03:20 +00:00
|
|
|
if not domain:
|
2010-04-22 12:50:41 +00:00
|
|
|
domain = []
|
|
|
|
#for opr1, opt, opr2 in domain:
|
|
|
|
# if opr1 == 'type' and opr2 != self.cal_type:
|
|
|
|
# return []
|
2010-04-13 11:03:20 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
fil_obj = dirobj.pool.get('basic.calendar')
|
2010-04-22 12:50:41 +00:00
|
|
|
ids = fil_obj.search(cr, uid, domain)
|
|
|
|
res = []
|
|
|
|
if self.calendar_id in ids:
|
2010-07-29 13:39:36 +00:00
|
|
|
res = fil_obj.get_calendar_objects(cr, uid, [self.calendar_id], self, domain=where, context=ctx)
|
|
|
|
return res
|
|
|
|
|
2010-07-29 13:39:38 +00:00
|
|
|
def create_child(self, cr, path, data):
|
2010-04-22 12:50:41 +00:00
|
|
|
""" API function to create a child file object and node
|
|
|
|
Return the node_* created
|
|
|
|
"""
|
2010-07-29 13:39:38 +00:00
|
|
|
# we ignore the path, it will be re-generated automatically
|
|
|
|
res = self.set_data(cr, data)
|
|
|
|
|
|
|
|
# TODO: use the res to create at least one node
|
|
|
|
return None
|
2010-04-22 12:50:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
def set_data(self, cr, data, fil_obj = None):
|
|
|
|
uid = self.context.uid
|
|
|
|
calendar_obj = self.context._dirobj.pool.get('basic.calendar')
|
2010-07-29 13:39:38 +00:00
|
|
|
res = calendar_obj.import_cal(cr, uid, data, self.calendar_id)
|
|
|
|
return res
|
2010-04-22 12:50:41 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def get_data_len(self, cr, fil_obj = None):
|
2010-04-22 12:50:41 +00:00
|
|
|
return self.content_length
|
2010-04-13 14:04:04 +00:00
|
|
|
|
2010-04-22 12:50:41 +00:00
|
|
|
def _get_ttag(self,cr):
|
2010-07-29 13:39:36 +00:00
|
|
|
return 'calendar-%d' % (self.calendar_id,)
|
|
|
|
|
2010-04-23 12:05:44 +00:00
|
|
|
def rmcol(self, cr):
|
|
|
|
return False
|
|
|
|
|
2010-04-14 07:36:16 +00:00
|
|
|
|
2010-04-22 12:50:41 +00:00
|
|
|
class res_node_calendar(nodes.node_class):
|
2010-04-15 07:58:09 +00:00
|
|
|
our_type = 'file'
|
2010-07-29 13:39:36 +00:00
|
|
|
DAV_PROPS = {
|
2010-04-15 07:58:09 +00:00
|
|
|
"http://calendarserver.org/ns/" : ('getctag'),
|
|
|
|
"urn:ietf:params:xml:ns:caldav" : (
|
|
|
|
'calendar-description',
|
|
|
|
'calendar-data',
|
|
|
|
'calendar-home-set',
|
|
|
|
'calendar-user-address-set',
|
|
|
|
'schedule-inbox-URL',
|
|
|
|
'schedule-outbox-URL',)}
|
2010-07-29 13:39:36 +00:00
|
|
|
DAV_M_NS = {
|
2010-04-15 07:58:09 +00:00
|
|
|
"http://calendarserver.org/ns/" : '_get_dav',
|
2010-07-29 13:39:36 +00:00
|
|
|
"urn:ietf:params:xml:ns:caldav" : '_get_caldav'}
|
2010-04-14 07:36:16 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
http_options = { 'DAV': ['calendar-access'] }
|
|
|
|
|
2010-04-23 11:14:22 +00:00
|
|
|
def __init__(self,path, parent, context, res_obj, res_model=None, res_id=None):
|
2010-07-29 13:39:36 +00:00
|
|
|
super(res_node_calendar,self).__init__(path, parent, context)
|
2010-04-21 13:34:02 +00:00
|
|
|
self.mimetype = 'text/calendar'
|
2010-04-22 12:50:41 +00:00
|
|
|
self.create_date = parent.create_date
|
|
|
|
self.write_date = parent.write_date or parent.create_date
|
2010-04-23 11:14:22 +00:00
|
|
|
self.calendar_id = hasattr(parent, 'calendar_id') and parent.calendar_id or False
|
2010-04-22 12:50:41 +00:00
|
|
|
if res_obj:
|
2010-04-23 11:14:22 +00:00
|
|
|
if not self.calendar_id: self.calendar_id = res_obj.id
|
2010-07-29 13:39:37 +00:00
|
|
|
pr = res_obj.perm_read()[0]
|
|
|
|
self.create_date = pr.get('create_date')
|
|
|
|
self.write_date = pr.get('write_date') or pr.get('create_date')
|
2010-04-22 12:50:41 +00:00
|
|
|
self.displayname = res_obj.name
|
|
|
|
|
2010-04-15 07:58:09 +00:00
|
|
|
self.content_length = 0
|
2010-07-29 13:39:36 +00:00
|
|
|
|
2010-04-22 12:50:41 +00:00
|
|
|
self.model = res_model
|
|
|
|
self.res_id = res_id
|
2010-07-29 13:39:36 +00:00
|
|
|
|
2010-04-15 07:58:09 +00:00
|
|
|
def open(self, cr, mode=False):
|
2010-07-29 13:39:36 +00:00
|
|
|
uid = self.context.uid
|
2010-04-15 07:58:09 +00:00
|
|
|
if self.type in ('collection','database'):
|
2010-07-29 13:39:36 +00:00
|
|
|
return False
|
|
|
|
s = StringIO.StringIO(self.get_data(cr))
|
2010-04-15 07:58:09 +00:00
|
|
|
s.name = self
|
2010-07-29 13:39:36 +00:00
|
|
|
return s
|
2010-04-15 07:58:09 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def get_data(self, cr, fil_obj = None):
|
2010-04-14 07:36:16 +00:00
|
|
|
uid = self.context.uid
|
2010-04-15 07:58:09 +00:00
|
|
|
calendar_obj = self.context._dirobj.pool.get('basic.calendar')
|
2010-07-29 13:39:36 +00:00
|
|
|
context = self.context.context.copy()
|
|
|
|
context.update({'model': self.model, 'res_id':self.res_id})
|
|
|
|
res = calendar_obj.export_cal(cr, uid, [self.calendar_id], context=context)
|
2010-04-15 10:56:05 +00:00
|
|
|
return res
|
2010-04-14 07:36:16 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def get_data_len(self, cr, fil_obj = None):
|
2010-04-15 07:58:09 +00:00
|
|
|
return self.content_length
|
|
|
|
|
|
|
|
def set_data(self, cr, data, fil_obj = None):
|
|
|
|
uid = self.context.uid
|
|
|
|
calendar_obj = self.context._dirobj.pool.get('basic.calendar')
|
2010-07-29 13:39:38 +00:00
|
|
|
res = calendar_obj.import_cal(cr, uid, data, self.calendar_id)
|
|
|
|
return res
|
2010-04-15 07:58:09 +00:00
|
|
|
|
|
|
|
def _get_ttag(self,cr):
|
2010-04-23 11:14:22 +00:00
|
|
|
res = False
|
|
|
|
if self.model and self.res_id:
|
|
|
|
res = '%s_%d' % (self.model, self.res_id)
|
|
|
|
elif self.calendar_id:
|
|
|
|
res = '%d' % (self.calendar_id)
|
|
|
|
return res
|
2010-04-15 07:58:09 +00:00
|
|
|
|
2010-07-29 13:39:36 +00:00
|
|
|
def _get_caldav_calendar_data(self, cr):
|
2010-04-15 10:56:05 +00:00
|
|
|
return self.get_data(cr)
|
2010-07-29 13:39:36 +00:00
|
|
|
|
2010-04-15 07:58:09 +00:00
|
|
|
|
|
|
|
def _get_caldav_calendar_description(self, cr):
|
|
|
|
uid = self.context.uid
|
|
|
|
calendar_obj = self.context._dirobj.pool.get('basic.calendar')
|
|
|
|
ctx = self.context.context.copy()
|
2010-07-29 13:39:36 +00:00
|
|
|
ctx.update(self.dctx)
|
2010-04-15 07:58:09 +00:00
|
|
|
calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx)
|
|
|
|
return calendar.description
|
2010-07-29 13:39:36 +00:00
|
|
|
|
2010-04-14 07:36:16 +00:00
|
|
|
|
|
|
|
def _get_caldav_calendar_home_set(self, cr):
|
|
|
|
import xml.dom.minidom
|
2010-07-29 13:39:36 +00:00
|
|
|
import urllib
|
2010-04-14 07:36:16 +00:00
|
|
|
uid = self.context.uid
|
|
|
|
ctx = self.context.context.copy()
|
|
|
|
ctx.update(self.dctx)
|
2010-07-29 13:39:36 +00:00
|
|
|
doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None)
|
|
|
|
|
|
|
|
calendar_obj = self.context._dirobj.pool.get('basic.calendar')
|
2010-04-15 07:58:09 +00:00
|
|
|
calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx)
|
|
|
|
huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, calendar.collection_id.name)))
|
2010-04-14 07:36:16 +00:00
|
|
|
href = doc.documentElement
|
|
|
|
href.tagName = 'D:href'
|
|
|
|
href.appendChild(huri)
|
|
|
|
return href
|
|
|
|
|
|
|
|
def _get_caldav_calendar_user_address_set(self, cr):
|
|
|
|
import xml.dom.minidom
|
|
|
|
dirobj = self.context._dirobj
|
|
|
|
uid = self.context.uid
|
|
|
|
ctx = self.context.context.copy()
|
|
|
|
ctx.update(self.dctx)
|
|
|
|
user_obj = self.context._dirobj.pool.get('res.users')
|
2010-07-29 13:39:36 +00:00
|
|
|
user = user_obj.browse(cr, uid, uid, context=ctx)
|
2010-04-14 07:36:16 +00:00
|
|
|
doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None)
|
|
|
|
href = doc.documentElement
|
|
|
|
href.tagName = 'D:href'
|
|
|
|
huri = doc.createTextNode('MAILTO:' + user.email)
|
|
|
|
href.appendChild(huri)
|
|
|
|
return href
|
|
|
|
|
|
|
|
|
|
|
|
def _get_caldav_schedule_inbox_URL(self, cr):
|
|
|
|
import xml.dom.minidom
|
2010-07-29 13:39:36 +00:00
|
|
|
import urllib
|
2010-04-14 07:36:16 +00:00
|
|
|
uid = self.context.uid
|
|
|
|
ctx = self.context.context.copy()
|
|
|
|
ctx.update(self.dctx)
|
2010-07-29 13:39:36 +00:00
|
|
|
calendar_obj = self.context._dirobj.pool.get('basic.calendar')
|
2010-04-15 07:58:09 +00:00
|
|
|
calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx)
|
|
|
|
res = '%s/%s' %(calendar.name, calendar.collection_id.name)
|
2010-04-14 07:36:16 +00:00
|
|
|
doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None)
|
|
|
|
href = doc.documentElement
|
|
|
|
href.tagName = 'D:href'
|
|
|
|
huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, res)))
|
|
|
|
href.appendChild(huri)
|
|
|
|
return href
|
|
|
|
|
|
|
|
|
2010-04-23 12:05:44 +00:00
|
|
|
def rm(self, cr):
|
|
|
|
uid = self.context.uid
|
|
|
|
res = False
|
|
|
|
if self.type in ('collection','database'):
|
2010-07-29 13:39:36 +00:00
|
|
|
return False
|
|
|
|
if self.model and self.res_id:
|
2010-04-23 12:05:44 +00:00
|
|
|
document_obj = self.context._dirobj.pool.get(self.model)
|
|
|
|
if document_obj:
|
2010-07-29 13:39:38 +00:00
|
|
|
res = document_obj.unlink(cr, uid, [self.res_id])
|
2010-07-29 13:39:36 +00:00
|
|
|
|
|
|
|
return res
|
2010-04-23 12:05:44 +00:00
|
|
|
|
2010-04-14 07:36:16 +00:00
|
|
|
def _get_caldav_schedule_outbox_URL(self, cr):
|
2010-04-21 13:34:02 +00:00
|
|
|
return self._get_caldav_schedule_inbox_URL(cr)
|
2010-07-29 13:39:36 +00:00
|
|
|
|
2010-04-13 11:03:20 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4
|