[ADD,REF]: caldav: Added new module base_calendar for basic calendar functionality and related improvement in caldav module
bzr revid: rpa@openerp.co.in-20100120095724-50ex0yp8q61w77kz
This commit is contained in:
parent
cd05a92fba
commit
913484860e
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 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
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import base_calendar
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 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
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
"name" : "Basic Calendar Functionality",
|
||||
"version" : "1.0",
|
||||
"depends" : [
|
||||
"base",
|
||||
],
|
||||
'description': """
|
||||
Contains basic functionality for caldav system like:
|
||||
- Maintenance of basic objects needed for caldav calendar
|
||||
* Event(Meeting)
|
||||
* Todo(Task)
|
||||
* Reminder
|
||||
* Attendee
|
||||
- Availabilities of synchronisation using WebDAV
|
||||
""",
|
||||
"author" : "Tiny",
|
||||
'category': 'Generic Modules/Others',
|
||||
'website': 'http://www.openerp.com',
|
||||
"init_xml" : [],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
"installable" : True,
|
||||
"active" : False,
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -23,7 +23,7 @@ from datetime import datetime, timedelta
|
|||
from dateutil import parser
|
||||
from dateutil.rrule import *
|
||||
from osv import osv
|
||||
import common
|
||||
import pooler
|
||||
import re
|
||||
import vobject
|
||||
|
||||
|
@ -32,6 +32,33 @@ import vobject
|
|||
# R-1 Required and can come only once
|
||||
# R-n Required and can come more than once
|
||||
|
||||
def uid2openobjectid(cr, uidval, oomodel, rdate):
|
||||
__rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$')
|
||||
wematch = __rege.match(uidval.encode('utf8'))
|
||||
if not wematch:
|
||||
return (False, None)
|
||||
else:
|
||||
model, id, dbname = wematch.groups()
|
||||
model_obj = pooler.get_pool(cr.dbname).get(model)
|
||||
if (not model == oomodel) or (not dbname == cr.dbname):
|
||||
return (False, None)
|
||||
qry = 'select distinct(id) from %s' % model_obj._table
|
||||
if rdate:
|
||||
qry += " where recurrent_id='%s'" % (rdate)
|
||||
cr.execute(qry)
|
||||
r_id = cr.fetchone()
|
||||
if r_id:
|
||||
return (id, r_id[0])
|
||||
cr.execute(qry)
|
||||
ids = map(lambda x: str(x[0]), cr.fetchall())
|
||||
if id in ids:
|
||||
return (id, None)
|
||||
return False
|
||||
|
||||
def openobjectid2uid(cr, uidval, oomodel):
|
||||
value = 'OpenObject-%s_%s@%s' % (oomodel, uidval, cr.dbname)
|
||||
return value
|
||||
|
||||
def map_data(cr, uid, obj):
|
||||
vals = {}
|
||||
for map_dict in obj.__attribute__:
|
||||
|
@ -126,7 +153,7 @@ class CalDAV(object):
|
|||
model = context.get('model', None)
|
||||
if not model:
|
||||
continue
|
||||
uidval = common.openobjectid2uid(cr, data[map_field], model)
|
||||
uidval = openobjectid2uid(cr, data[map_field], model)
|
||||
model_obj = self.pool.get(model)
|
||||
cr.execute('select id from %s where recurrent_uid=%s'
|
||||
% (model_obj._table, data[map_field]))
|
||||
|
@ -137,7 +164,7 @@ class CalDAV(object):
|
|||
for revents in rcal.contents['vevent']:
|
||||
ical.contents['vevent'].append(revents)
|
||||
if data.get('recurrent_uid', None):
|
||||
uidval = common.openobjectid2uid(cr, data['recurrent_uid'], model)
|
||||
uidval = openobjectid2uid(cr, data['recurrent_uid'], model)
|
||||
vevent.add('uid').value = uidval
|
||||
elif field == 'attendee' and data[map_field]:
|
||||
model = self.__attribute__[field].get('object', False)
|
|
@ -0,0 +1,6 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_basic_calendar_all","basic.calendar","model_basic_calendar",,1,1,1,1
|
||||
"access_basic_calendar_event_all","basic.calendar.event","model_basic_calendar_event",,1,1,1,1
|
||||
"access_basic_calendar_attendee_all","basic.calendar.attendee","model_basic_calendar_attendee",,1,1,1,1
|
||||
"access_calendar_todo_all","basic.calendar.todo","model_basic_calendar_todo",,1,1,1,1
|
||||
"access_basic_calendar_alarm_all","basic.calendar.alarm","model_basic_calendar_alarm",,1,1,1,1
|
|
|
@ -19,8 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import calendar
|
||||
import common
|
||||
import caldav
|
||||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -24,16 +24,14 @@
|
|||
"name" : "CalDAV",
|
||||
"version" : "1.0",
|
||||
"depends" : [
|
||||
"base",
|
||||
"base_calendar",
|
||||
],
|
||||
'description': """
|
||||
To develop a full featured caldav system that support:
|
||||
- access through webdav (based on xrg code)
|
||||
Full featured caldav system that support:
|
||||
- alerts (create requests)
|
||||
- recurring events (*)
|
||||
- invitations to others people (exactly like sunbird)
|
||||
- availabilities of users/calendars
|
||||
- full day events""",
|
||||
""",
|
||||
"author" : "Tiny",
|
||||
'category': 'Generic Modules/Others',
|
||||
'website': 'http://www.openerp.com',
|
||||
|
|
|
@ -23,6 +23,7 @@ from datetime import datetime, timedelta
|
|||
from datetime import datetime, timedelta
|
||||
from dateutil import parser
|
||||
from osv import fields, osv
|
||||
from base_calendar import base_calendar
|
||||
from service import web_services
|
||||
from tools.translate import _
|
||||
import base64
|
||||
|
@ -56,32 +57,6 @@ def real_id2caldav_id(real_id, recurrent_date):
|
|||
return '%d-%s' % (real_id, recurrent_date)
|
||||
return real_id
|
||||
|
||||
def uid2openobjectid(cr, uidval, oomodel, rdate):
|
||||
__rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$')
|
||||
wematch = __rege.match(uidval.encode('utf8'))
|
||||
if not wematch:
|
||||
return (False, None)
|
||||
else:
|
||||
model, id, dbname = wematch.groups()
|
||||
model_obj = pooler.get_pool(cr.dbname).get(model)
|
||||
if (not model == oomodel) or (not dbname == cr.dbname):
|
||||
return (False, None)
|
||||
qry = 'select distinct(id) from %s' % model_obj._table
|
||||
if rdate:
|
||||
qry += " where recurrent_id='%s'" % (rdate)
|
||||
cr.execute(qry)
|
||||
r_id = cr.fetchone()
|
||||
if r_id:
|
||||
return (id, r_id[0])
|
||||
cr.execute(qry)
|
||||
ids = map(lambda x: str(x[0]), cr.fetchall())
|
||||
if id in ids:
|
||||
return (id, None)
|
||||
return False
|
||||
|
||||
def openobjectid2uid(cr, uidval, oomodel):
|
||||
value = 'OpenObject-%s_%s@%s' % (oomodel, uidval, cr.dbname)
|
||||
return value
|
||||
|
||||
def _links_get(self, cr, uid, context={}):
|
||||
obj = self.pool.get('res.request.link')
|
||||
|
@ -480,7 +455,7 @@ class calendar_event(osv.osv):
|
|||
'url': {'field': 'caldav_url', 'type': 'text'},
|
||||
'recurrence-id': {'field': 'recurrent_id', 'type': 'datetime'},
|
||||
'attendee': {'field': 'attendee_ids', 'type': 'many2many', 'object': 'calendar.attendee'},
|
||||
'categories': {'field': 'categ_id', 'type': 'many2one', 'object': 'crm.meeting.categ'},
|
||||
# 'categories': {'field': 'categ_id', 'type': 'many2one', 'object': 'crm.meeting.categ'},
|
||||
'comment': None,
|
||||
'contact': None,
|
||||
'exdate': {'field': 'exdate', 'type': 'datetime'},
|
||||
|
@ -586,7 +561,7 @@ rule or repeating pattern for anexception to a recurrence set"),
|
|||
vals = event_obj.import_ical(cr, uid, file_content)
|
||||
ids = []
|
||||
for val in vals:
|
||||
exists, r_id = uid2openobjectid(cr, val['id'], self._name, \
|
||||
exists, r_id = base_calendar.uid2openobjectid(cr, val['id'], self._name, \
|
||||
val.get('recurrent_id'))
|
||||
if val.has_key('create_date'): val.pop('create_date')
|
||||
val['caldav_url'] = context.get('url') or ''
|
||||
|
@ -886,7 +861,7 @@ class calendar_todo(osv.osv):
|
|||
hours = (val['planned_hours'].seconds / float(3600)) + \
|
||||
(val['planned_hours'].days * 24)
|
||||
val['planned_hours'] = hours
|
||||
exists, r_id = uid2openobjectid(cr, val['id'], self._name, val.get('recurrent_id'))
|
||||
exists, r_id = base_calendar.uid2openobjectid(cr, val['id'], self._name, val.get('recurrent_id'))
|
||||
val.pop('id')
|
||||
if exists:
|
||||
self.write(cr, uid, [exists], val)
|
|
@ -1,9 +1,4 @@
|
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
||||
"access_basic_calendar_all","basic.calendar","model_basic_calendar",,1,1,1,1
|
||||
"access_basic_calendar_event_all","basic.calendar.event","model_basic_calendar_event",,1,1,1,1
|
||||
"access_basic_calendar_attendee_all","basic.calendar.attendee","model_basic_calendar_attendee",,1,1,1,1
|
||||
"access_calendar_todo_all","basic.calendar.todo","model_basic_calendar_todo",,1,1,1,1
|
||||
"access_calendar_todo_all","basic.calendar.todo","model_basic_calendar_todo",,1,1,1,1
|
||||
"access_calendar_attendee","calendar.attendee","model_calendar_attendee",,1,1,1,1
|
||||
"access_calendar_alarm","calendar.alarm","model_calendar_alarm",,1,1,1,1
|
||||
"access_res_alarm","res.alarm","model_res_alarm",,1,1,1,1
|
||||
|
|
|
|
@ -19,7 +19,6 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from caldav import common
|
||||
from dateutil.rrule import *
|
||||
from osv import fields, osv
|
||||
import datetime
|
||||
|
|
Loading…
Reference in New Issue