Skip to content
Snippets Groups Projects
Commit b5755527 authored by Ujjvala Collins's avatar Ujjvala Collins
Browse files

[MERGE]: Merged with parent branch

bzr revid: uco@tinyerp.co.in-20091222133221-iysoizq0knzk22ko
parents c3aaa3a6 312ce4d6
No related branches found
No related tags found
No related merge requests found
......@@ -69,14 +69,17 @@ class CalDAV(object):
__attribute__ = {
}
def get_recurrent_dates(self, rrulestring, exdate, startdate=None):
todate = parser.parse
def todate(date):
val = parser.parse(''.join((re.compile('\d')).findall(date)) + 'Z')
return val
if not startdate:
startdate = datetime.now()
else:
startdate = todate(''.join((re.compile('\d')).findall(startdate)) + 'Z')
startdate = todate(startdate)
rset1 = rrulestr(rrulestring, dtstart=startdate, forceset=True)
for date in exdate:
datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
datetime_obj = todate(date)
rset1._exdate.append(datetime_obj)
re_dates = rset1._iter()
recurrent_dates = map(lambda x:x.strftime('%Y-%m-%d %H:%M:%S'), re_dates)
......@@ -93,9 +96,12 @@ class CalDAV(object):
valtype = self.__attribute__.get(name).get('type', None)
if type == 'value':
if valtype and valtype=='datetime' and val:
val = val.strftime('%Y-%m-%d %H:%M:%S')
if isinstance(val, list):
val = ','.join(map(lambda x: x.strftime('%Y-%m-%d %H:%M:%S'), val))
else:
val = val.strftime('%Y-%m-%d %H:%M:%S')
if valtype and valtype=='integer' and val:
val = int(val)
val = int(val)
return val
else:
return self.__attribute__.get(name, None)
......@@ -124,8 +130,10 @@ class CalDAV(object):
if map_type == "text":
vevent.add(field).value = str(data[map_field])
elif map_type == 'datetime' and data[map_field]:
vevent.add(field).value = datetime.strptime(data[map_field], \
"%Y-%m-%d %H:%M:%S")
if field in ('exdate'):
vevent.add(field).value = [parser.parse(data[map_field])]
else:
vevent.add(field).value = parser.parse(data[map_field])
elif map_type == "timedelta":
vevent.add(field).value = timedelta(hours=data[map_field])
if self.__attribute__.get(field).has_key('mapping'):
......
......@@ -98,12 +98,23 @@
<newline/>
<separator string="Event Location" colspan="4"/>
<field name="location" colspan="4" nolabel="1"/>
<separator string="Freebusy Value" colspan="4"/>
<field name="freebusy" colspan="4" nolabel="1"/>
<separator string="RRule Details" colspan="4"/>
<field name="rrule" colspan="4" nolabel="1"/>
<separator string="Recurrenet Dates" colspan="4"/>
<field name="rdates" colspan="4" nolabel="1"/>
<!-- <separator string="Freebusy Value" colspan="4"/>-->
<!-- <field name="freebusy" colspan="4" nolabel="1"/>-->
<!-- <separator string="Recurrency Details" colspan="4"/>-->
<group string="Recurrency Details" col="4" colspan="4">
<group col="1" colspan="2">
<separator string="Recurrenet Rule" />
<field name="rrule" nolabel="1" />
<separator string="Exception Rule" />
<field name="exrule" nolabel="1" />
</group>
<group col="1" colspan="2">
<separator string="Recurrenet Dates" />
<field name="rdates" nolabel="1" />
<separator string="Exception Dates" />
<field name="exdate" nolabel="1" />
</group>
</group>
</page>
<page string="Attendee">
<separator string="Attendee" colspan="4"/>
......
......@@ -19,18 +19,13 @@
#
##############################################################################
from osv import fields, osv
from time import strftime
import time
import base64
import vobject
from dateutil.rrule import *
from dateutil import parser
from osv import fields, osv
import datetime
from time import strftime
from pytz import timezone
import base64
import re
import time
import tools
from service import web_services
def caldevIDs2readIDs(caldev_ID = None):
if caldev_ID:
......@@ -68,8 +63,8 @@ class crm_case(osv.osv):
# 'categories' : {'field':None , 'sub-field':'name', 'type':'text'}, # keep none for now
'comment' : None,
'contact' : None,
'exdate' : None,
'exrule' : None,
'exdate' : {'field':'exdate', 'type':'datetime'},
'exrule' : {'field':'exrule', 'type':'text'},
'rstatus' : None,
'related' : None,
'resources' : None,
......@@ -100,10 +95,10 @@ class crm_case(osv.osv):
def _get_rdates(self, cr, uid, ids, name, arg, context=None):
res = {}
context.update({'read':True})
for case in self.read(cr, uid, ids, ['date', 'rrule'], context=context):
for case in self.read(cr, uid, ids, ['date', 'rrule', 'exdate', 'exrule'], context=context):
if case['rrule']:
rule = case['rrule'].split('\n')[0]
exdate = case['rrule'].split('\n')[1:]
rule = case['rrule']
exdate = case['exdate'] and case['exdate'].split(',') or []
event_obj = self.pool.get('caldav.event')
res[case['id']] = str(event_obj.get_recurrent_dates(str(rule), exdate, case['date']))
return res
......@@ -116,6 +111,10 @@ class crm_case(osv.osv):
'freebusy' : fields.text('FreeBusy'),
'transparent' : fields.selection([('OPAQUE', 'OPAQUE'), ('TRANSPARENT', 'TRANSPARENT')], 'Trensparent'),
'caldav_url' : fields.char('Caldav URL', size=34),
'exdate' : fields.text('Exception Date/Times', help="This property defines the list\
of date/time exceptions for arecurring calendar component."),
'exrule' : fields.text('Exception Rule', help="defines a rule or repeating pattern\
for anexception to a recurrence set"),
'rrule' : fields.text('Recurrent Rule'),
'rdates' : fields.function(_get_rdates, method=True, string='Recurrent Dates', \
store=True, type='text'),
......@@ -134,7 +133,7 @@ class crm_case(osv.osv):
def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \
context=None):
if not context:
context={}
context = {}
cr.execute('select c.id as id, c.date as date, alarm.id as alarm_id, alarm.name as name,\
alarm.trigger_interval, alarm.trigger_duration, alarm.trigger_related, \
alarm.trigger_occurs from crm_case c \
......@@ -196,7 +195,7 @@ class crm_case(osv.osv):
file_content = base64.decodestring(data['form']['file_path'])
event_obj = self.pool.get('caldav.event')
event_obj.__attribute__.update(self.__attribute__)
attendee_obj = self.pool.get('caldav.attendee')
crm_attendee = self.pool.get('crm.caldav.attendee')
attendee_obj.__attribute__.update(crm_attendee.__attribute__)
......@@ -236,8 +235,7 @@ class crm_case(osv.osv):
select = map(lambda x:caldevIDs2readIDs(x), select)
return super(crm_case, self).browse(cr, uid, select, context, list_class, fields_process)
def read(self, cr, uid, ids, fields=None, context={},
load='_classic_read'):
def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'):
""" logic for recurrent event
example : 123-20091111170822"""
if context and context.has_key('read'):
......@@ -269,7 +267,6 @@ class crm_case(osv.osv):
result.remove(val)
for rdate in rdates:
import re
idval = (re.compile('\d')).findall(rdate)
val['date'] = rdate
id = str(val['id']).split('-')[0]
......@@ -287,10 +284,12 @@ class crm_case(osv.osv):
if len(str(id).split('-')) > 1:
date_new = time.strftime("%Y-%m-%d %H:%M:%S", \
time.strptime(str(str(id).split('-')[1]), "%Y%m%d%H%M%S"))
for record in self.read(cr, uid, [caldevIDs2readIDs(id)], ['date', 'rdates', 'rrule']):
for record in self.read(cr, uid, [caldevIDs2readIDs(id)], \
['date', 'rdates', 'rrule', 'exdate']):
exdate = (record['exdate'] and (record['exdate'] + ',' ) or '') + \
''.join((re.compile('\d')).findall(date_new)) + 'Z'
if record['date'] == date_new:
self.write(cr, uid, [caldevIDs2readIDs(id)], \
{'rrule' : record['rrule'] +"\n" + str(date_new)})
self.write(cr, uid, [caldevIDs2readIDs(id)], {'exdate' : exdate})
else:
return super(crm_case, self).unlink(cr, uid, ids)
......
......@@ -23,6 +23,8 @@ from datetime import datetime
from osv import fields, osv
from service import web_services
import base64
import time
import re
def caldevIDs2readIDs(caldev_ID = None):
if caldev_ID:
......@@ -36,12 +38,12 @@ class project_task(osv.osv):
def _get_rdates(self, cr, uid, ids, name, arg, context=None):
res = {}
context.update({'read':True})
for task in self.read(cr, uid, ids, ['date_start', 'rrule'], context=context):
for task in self.read(cr, uid, ids, ['date_start', 'rrule', 'exdate', 'exrule'], context=context):
if task['rrule']:
rule = task['rrule'].split('\n')[0]
rule = task['rrule']
if rule.upper().find('COUNT') < 0: # Temp fix, needs review
rule += ';COUNT=5'
exdate = task['rrule'].split('\n')[1:]
exdate = task['exdate'] and task['exdate'].split(',') or []
todo_obj = self.pool.get('caldav.todo')
res[task['id']] = str(todo_obj.get_recurrent_dates(str(rule), exdate, task['date_start']))
return res
......@@ -51,9 +53,13 @@ class project_task(osv.osv):
('CONFIDENTIAL', 'CONFIDENTIAL')], 'Class'),
'location': fields.text('Location'),
'rrule': fields.text('Recurrent Rule'),
'exdate' : fields.text('Exception Date/Times', help="This property defines the list\
of date/time exceptions for arecurring calendar component."),
'exrule' : fields.text('Exception Rule', help="defines a rule or repeating pattern\
for anexception to a recurrence set"),
'rdates': fields.function(_get_rdates, method=True, string='Recurrent Dates', \
store=True, type='text'),
'attendee_ids': fields.many2many('crm.caldav.attendee', 'crm_attendee_rel', 'case_id', \
'attendee_ids': fields.many2many('crm.caldav.attendee', 'task_attendee_rel', 'case_id', \
'attendee_id', 'Attendees'),
'alarm_id': fields.many2one('crm.caldav.alarm', 'Alarm'),
'caldav_url': fields.char('Caldav URL', size=34),
......@@ -87,8 +93,8 @@ class project_task(osv.osv):
# 'categories': {'field': 'type', 'type': 'text'}, # Needs review
'comment': {'field': 'notes', 'type': 'text'},
# 'contact': {'field': 'field', 'type': 'text'},
# 'exdate': {'field': 'field', 'type': 'text'},
# 'exrule': {'field': 'field', 'type': 'text'},
'exdate' : {'field':'exdate', 'type':'datetime'},
'exrule' : {'field':'exrule', 'type':'text'},
# 'rstatus': {'field': 'field', 'type': 'text'},
# 'related': {'field': 'field', 'type': 'text'},
# 'resources': {'field': 'field', 'type': 'text'},
......@@ -143,8 +149,8 @@ class project_task(osv.osv):
return caendar_val
def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'):
""" logic for recurrent task
example : 123-20091111170822""", ids, fields, context
""" Logic for recurrent task
example : 123-20091111170822"""
if context and context.has_key('read'):
return super(project_task, self).read(cr, uid, ids, fields, context, load)
if not type(ids) == list :
......@@ -173,7 +179,6 @@ class project_task(osv.osv):
result.remove(val)
for rdate in rdates:
import re
idval = (re.compile('\d')).findall(rdate)
val['date_start'] = rdate
id = str(val['id']).split('-')[0]
......@@ -210,10 +215,12 @@ class project_task(osv.osv):
if len(str(id).split('-')) > 1:
date_new = time.strftime("%Y-%m-%d %H:%M:%S", \
time.strptime(str(str(id).split('-')[1]), "%Y%m%d%H%M%S"))
for record in self.read(cr, uid, [caldevIDs2readIDs(id)], ['date_start', 'rdates', 'rrule']):
for record in self.read(cr, uid, [caldevIDs2readIDs(id)], \
['date', 'rdates', 'rrule', 'exdate']):
exdate = (record['exdate'] and (record['exdate'] + ',' ) or '') + \
''.join((re.compile('\d')).findall(date_new)) + 'Z'
if record['date_start'] == date_new:
self.write(cr, uid, [caldevIDs2readIDs(id)], \
{'rrule' : record['rrule'] +"\n" + str(date_new)})
self.write(cr, uid, [caldevIDs2readIDs(id)], {'exdate' : exdate})
else:
return super(project_task, self).unlink(cr, uid, ids)
......
......@@ -109,10 +109,20 @@
<newline/>
<separator string="Location" colspan="4"/>
<field name="location" colspan="4" nolabel="1"/>
<separator string="RRule Details" colspan="4"/>
<field name="rrule" colspan="4" nolabel="1"/>
<separator string="Recurrenet Dates" colspan="4"/>
<field name="rdates" colspan="4" nolabel="1"/>
<group string="Recurrency Details" col="4" colspan="4">
<group col="1" colspan="2">
<separator string="Recurrenet Rule" />
<field name="rrule" nolabel="1" />
<separator string="Exception Rule" />
<field name="exrule" nolabel="1" />
</group>
<group col="1" colspan="2">
<separator string="Recurrenet Dates" />
<field name="rdates" nolabel="1" />
<separator string="Exception Dates" />
<field name="exdate" nolabel="1" />
</group>
</group>
</page>
<page string="Attendee">
<separator string="Attendee" colspan="4"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment