From fe0ee384c7b5a64c12f8725027352df173701456 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Thu, 29 Jul 2010 16:39:36 +0300 Subject: [PATCH 01/23] Caldav: whitespace fixes Expand tabs and remove trailing whitespace. Only. bzr revid: p_christ@hol.gr-20100729133936-d0o3u34qqmqk7qba --- addons/caldav/caldav_data.xml | 746 +++++++++--------- addons/caldav/caldav_node.py | 221 +++--- addons/caldav/caldav_view.xml | 70 +- .../wizard/calendar_event_export_view.xml | 26 +- .../wizard/calendar_event_import_view.xml | 40 +- .../wizard/calendar_event_subscribe_view.xml | 38 +- 6 files changed, 571 insertions(+), 570 deletions(-) diff --git a/addons/caldav/caldav_data.xml b/addons/caldav/caldav_data.xml index e2ae6624979..337901603c9 100644 --- a/addons/caldav/caldav_data.xml +++ b/addons/caldav/caldav_data.xml @@ -1,385 +1,385 @@ - + Calendars True - + - - comment - vevent - + + comment + vevent + - organizer - vevent - - - - uid - vevent - - - - seq - vevent - - - - recurrence-id - vevent - - - - transp - vevent - - - - attendee - vevent - - - - related - vevent - - - - rrule - vevent - - - - dtend - vevent - - - - valarm - vevent - - - - vtimezone - vevent - - - - priority - vevent - - - - location - vevent - - - - exrule - vevent - - - - resources - vevent - - - - rstatus - vevent - - - - status - vevent - - - - exdate - vevent - - - - dtstamp - vevent - - - - description - vevent - - - - rdate - vevent - - - - dtstart - vevent - - - - class - vevent - - - - x-openobject-model - vevent - - - - created - vevent - - - - url - vevent - - - - summary - vevent - - - - contact - vevent - - - - - - - status - vtodo - - - - comment - vtodo - - - - attendee - vtodo - - - - valarm - vtodo - - - - description - vtodo - - - - seq - vtodo - - - - vtimezone - vtodo - - - - url - vtodo - - - - completed - vtodo - - - - percent - vtodo - - - - due - vtodo - - - - summary - vtodo - - - - priority - vtodo - - - - exdate - vtodo - - - - location - vtodo - - - - exrule - vtodo - - - - duration - vtodo - - - - organizer - vtodo - - - - dtstart - vtodo - - - - rrule - vtodo - - - - class - vtodo - - - - uid - vtodo - - - - - - cn - attendee - - - - sent-by - attendee - - - - language - attendee - - - - delegated-from - attendee - - - - member - attendee - - - - cutype - attendee - - - - role - attendee - - - - partstat - attendee - - - - delegated-to - attendee - - - - dir - attendee - - - - rsvp - attendee - - - - - - attendee - alarm - - - - trigger_duration - alarm - - - - description - alarm - - - - attach - alarm - - - - trigger_occurs - alarm - - - - trigger_interval - alarm - - - - summary - alarm - - - - duration - alarm - - - - repeat - alarm - - - - action - alarm - - - - trigger_related - alarm - - - + organizer + vevent + + + + uid + vevent + + + + seq + vevent + + + + recurrence-id + vevent + + + + transp + vevent + + + + attendee + vevent + + + + related + vevent + + + + rrule + vevent + + + + dtend + vevent + + + + valarm + vevent + + + + vtimezone + vevent + + + + priority + vevent + + + + location + vevent + + + + exrule + vevent + + + + resources + vevent + + + + rstatus + vevent + + + + status + vevent + + + + exdate + vevent + + + + dtstamp + vevent + + + + description + vevent + + + + rdate + vevent + + + + dtstart + vevent + + + + class + vevent + + + + x-openobject-model + vevent + + + + created + vevent + + + + url + vevent + + + + summary + vevent + + + + contact + vevent + + + + + + + status + vtodo + + + + comment + vtodo + + + + attendee + vtodo + + + + valarm + vtodo + + + + description + vtodo + + + + seq + vtodo + + + + vtimezone + vtodo + + + + url + vtodo + + + + completed + vtodo + + + + percent + vtodo + + + + due + vtodo + + + + summary + vtodo + + + + priority + vtodo + + + + exdate + vtodo + + + + location + vtodo + + + + exrule + vtodo + + + + duration + vtodo + + + + organizer + vtodo + + + + dtstart + vtodo + + + + rrule + vtodo + + + + class + vtodo + + + + uid + vtodo + + + + + + cn + attendee + + + + sent-by + attendee + + + + language + attendee + + + + delegated-from + attendee + + + + member + attendee + + + + cutype + attendee + + + + role + attendee + + + + partstat + attendee + + + + delegated-to + attendee + + + + dir + attendee + + + + rsvp + attendee + + + + + + attendee + alarm + + + + trigger_duration + alarm + + + + description + alarm + + + + attach + alarm + + + + trigger_occurs + alarm + + + + trigger_interval + alarm + + + + summary + alarm + + + + duration + alarm + + + + repeat + alarm + + + + action + alarm + + + + trigger_related + alarm + + + diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py index 8ec7422a045..66cca2eb1f3 100644 --- a/addons/caldav/caldav_node.py +++ b/addons/caldav/caldav_node.py @@ -38,34 +38,34 @@ class node_database(nodes.node_database): domain = [] domain2 = domain + [('calendar_collection','=', False)] res = super(node_database, self)._child_get(cr, name=name, parent_id=parent_id, domain=domain2) - where = [('parent_id','=',parent_id)] - domain2 = domain + [('calendar_collection','=', True)] + where = [('parent_id','=',parent_id)] + domain2 = domain + [('calendar_collection','=', True)] if name: where.append(('name','=',name)) if domain2: where += domain2 where2 = where + [('type', '=', 'directory')] - ids = dirobj.search(cr, uid, where2, context=ctx) - for dirr in dirobj.browse(cr,uid,ids,context=ctx): + ids = dirobj.search(cr, uid, where2, context=ctx) + for dirr in dirobj.browse(cr,uid,ids,context=ctx): res.append(node_calendar_collection(dirr.name,self,self.context,dirr)) return res -class node_calendar_collection(nodes.node_dir): +class node_calendar_collection(nodes.node_dir): PROPS = { "http://calendarserver.org/ns/" : ('getctag'), - } - M_NS = { + } + M_NS = { "http://calendarserver.org/ns/" : '_get_dav', - } + } - def get_dav_props(self, cr): + def get_dav_props(self, cr): return self.PROPS - - def get_dav_eprop(self,cr, ns, propname): + + def get_dav_eprop(self,cr, ns, propname): if self.M_NS.has_key(ns): prefix = self.M_NS[ns] else: @@ -83,33 +83,33 @@ class node_calendar_collection(nodes.node_dir): return r except AttributeError, e: print 'Property %s not supported' % propname - print "Exception:", e + print "Exception:", e return None def _file_get(self,cr, nodename=False): return [] - - - def _child_get(self, cr, name=False, parent_id=False, domain=None): + + + 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) - where = [('collection_id','=',self.dir_id)] - ext = False - if name: - res = name.split('.ics') + where = [('collection_id','=',self.dir_id)] + ext = False + if name: + res = name.split('.ics') if len(res) > 1: name = res[0] ext = '.ics' - if name: + if name: where.append(('name','=',name)) if not domain: - domain = [] + domain = [] where = where + domain - fil_obj = dirobj.pool.get('basic.calendar') + fil_obj = dirobj.pool.get('basic.calendar') ids = fil_obj.search(cr,uid,where,context=ctx) res = [] for calender in fil_obj.browse(cr, uid, ids, context=ctx): @@ -122,7 +122,7 @@ class node_calendar_collection(nodes.node_dir): def _get_dav_owner(self, cr): return False - + def get_etag(self, cr): """ Get a tag, unique per object + modification. @@ -140,12 +140,12 @@ class node_calendar_collection(nodes.node_dir): return 'calendar collection-%d' % self.dir_id def _get_dav_getctag(self, cr): - result = self.get_etag(cr) - return str(result) - + result = self.get_etag(cr) + return str(result) -class node_calendar(nodes.node_class): - our_type = 'collection' + +class node_calendar(nodes.node_class): + our_type = 'collection' PROPS = { "http://calendarserver.org/ns/" : ('getctag'), "urn:ietf:params:xml:ns:caldav" : ( @@ -156,9 +156,9 @@ class node_calendar(nodes.node_class): 'schedule-inbox-URL', 'schedule-outbox-URL',)} M_NS = { - "DAV:" : '_get_dav', + "DAV:" : '_get_dav', "http://calendarserver.org/ns/" : '_get_dav', - "urn:ietf:params:xml:ns:caldav" : '_get_caldav'} + "urn:ietf:params:xml:ns:caldav" : '_get_caldav'} def __init__(self,path, parent, context, calendar): super(node_calendar,self).__init__(path, parent,context) @@ -170,29 +170,29 @@ class node_calendar(nodes.node_class): self.displayname = calendar.name self.cal_type = calendar.type - def _get_dav_getctag(self, cr): + def _get_dav_getctag(self, cr): result = self._get_ttag(cr) + ':' + str(time.time()) - return str(result) + return str(result) def match_dav_eprop(self, cr, match, ns, prop): if ns == "DAV:" and prop == "getetag": dirobj = self.context._dirobj uid = self.context.uid - ctx = self.context.context.copy() + ctx = self.context.context.copy() tem, dav_time = tuple(match.split(':')) model, res_id = tuple(tem.split('_')) model_obj = dirobj.pool.get(model) model = model_obj.browse(cr, uid, res_id, context=ctx) write_time = model.write_date or model.create_date - wtime = time.mktime(time.strptime(write_time,'%Y-%m-%d %H:%M:%S')) + wtime = time.mktime(time.strptime(write_time,'%Y-%m-%d %H:%M:%S')) if float(dav_time) == float(wtime): return True return False res = super(node_calendar, self).match_dav_eprop(cr, match, ns, prop) - return res - - - def get_domain(self, cr, filters): + return res + + + def get_domain(self, cr, filters): res = [] dirobj = self.context._dirobj uid = self.context.uid @@ -201,14 +201,14 @@ class node_calendar(nodes.node_class): calendar_obj = dirobj.pool.get('basic.calendar') if not filters: return res - if filters.localName == 'calendar-query': + if filters.localName == 'calendar-query': res = [] for filter_child in filters.childNodes: if filter_child.nodeType == filter_child.TEXT_NODE: - continue - if filter_child.localName == 'filter': + continue + if filter_child.localName == 'filter': for vcalendar_filter in filter_child.childNodes: - if vcalendar_filter.nodeType == vcalendar_filter.TEXT_NODE: + if vcalendar_filter.nodeType == vcalendar_filter.TEXT_NODE: continue if vcalendar_filter.localName == 'comp-filter': if vcalendar_filter.getAttribute('name') == 'VCALENDAR': @@ -216,10 +216,10 @@ class node_calendar(nodes.node_class): if vevent_filter.nodeType == vevent_filter.TEXT_NODE: continue if vevent_filter.localName == 'comp-filter': - if vevent_filter.getAttribute('name') == 'VEVENT': + if vevent_filter.getAttribute('name') == 'VEVENT': res = [('type','=','vevent')] if vevent_filter.getAttribute('name') == 'VTODO': - res = [('type','=','vtodo')] + res = [('type','=','vtodo')] return res elif filters.localName == 'calendar-multiget': names = [] @@ -229,49 +229,49 @@ class node_calendar(nodes.node_class): if filter_child.localName == 'href': if not filter_child.firstChild: continue - uri = filter_child.firstChild.data + uri = filter_child.firstChild.data caluri = uri.split('/') if len(caluri): caluri = caluri[-2] if caluri not in names : names.append(caluri) res = [('name','in',names)] return res - return res + return res - def children(self, cr, domain=None): + def children(self, cr, domain=None): return self._child_get(cr, domain=domain) - def child(self,cr, name, domain=None): - res = self._child_get(cr, name, domain=domain) + def child(self,cr, name, domain=None): + res = self._child_get(cr, name, domain=domain) if res: return res[0] - return None + return None 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) - where = [] - if name: - where.append(('id','=',int(name))) + ctx.update(self.dctx) + where = [] + if name: + where.append(('id','=',int(name))) if not domain: domain = [] #for opr1, opt, opr2 in domain: # if opr1 == 'type' and opr2 != self.cal_type: # return [] - fil_obj = dirobj.pool.get('basic.calendar') + fil_obj = dirobj.pool.get('basic.calendar') ids = fil_obj.search(cr, uid, domain) res = [] if self.calendar_id in ids: - res = fil_obj.get_calendar_objects(cr, uid, [self.calendar_id], self, domain=where, context=ctx) - return res + res = fil_obj.get_calendar_objects(cr, uid, [self.calendar_id], self, domain=where, context=ctx) + return res - - - def get_dav_props(self, cr): + + + def get_dav_props(self, cr): return self.PROPS def get_dav_eprop(self,cr, ns, propname): @@ -287,11 +287,11 @@ class node_calendar(nodes.node_class): try: m = getattr(self, mname) - r = m(cr) + r = m(cr) return r except AttributeError, e: print 'Property %s not supported' % propname - print "Exception:", e + print "Exception:", e return None @@ -299,7 +299,7 @@ class node_calendar(nodes.node_class): """ API function to create a child file object and node Return the node_* created """ - return self.set_data(cr, data) + return self.set_data(cr, data) def set_data(self, cr, data, fil_obj = None): @@ -307,14 +307,14 @@ class node_calendar(nodes.node_class): calendar_obj = self.context._dirobj.pool.get('basic.calendar') return calendar_obj.import_cal(cr, uid, base64.encodestring(data), self.calendar_id) - def get_data_len(self, cr, fil_obj = None): + def get_data_len(self, cr, fil_obj = None): return self.content_length - + def _get_ttag(self,cr): - return 'calendar-%d' % (self.calendar_id,) - - + return 'calendar-%d' % (self.calendar_id,) + + def get_etag(self, cr): """ Get a tag, unique per object + modification. @@ -327,7 +327,7 @@ class node_calendar(nodes.node_class): if self.write_date: wtime = time.mktime(time.strptime(self.write_date, '%Y-%m-%d %H:%M:%S')) else: wtime = time.time() - return str(wtime) + return str(wtime) def rmcol(self, cr): return False @@ -344,12 +344,12 @@ class res_node_calendar(nodes.node_class): 'calendar-user-address-set', 'schedule-inbox-URL', 'schedule-outbox-URL',)} - M_NS = { + M_NS = { "http://calendarserver.org/ns/" : '_get_dav', - "urn:ietf:params:xml:ns:caldav" : '_get_caldav'} + "urn:ietf:params:xml:ns:caldav" : '_get_caldav'} def __init__(self,path, parent, context, res_obj, res_model=None, res_id=None): - super(res_node_calendar,self).__init__(path, parent, context) + super(res_node_calendar,self).__init__(path, parent, context) self.mimetype = 'text/calendar' self.create_date = parent.create_date self.write_date = parent.write_date or parent.create_date @@ -361,24 +361,24 @@ class res_node_calendar(nodes.node_class): self.displayname = res_obj.name self.content_length = 0 - + self.model = res_model self.res_id = res_id - - def open(self, cr, mode=False): - uid = self.context.uid - if self.type in ('collection','database'): - return False - s = StringIO.StringIO(self.get_data(cr)) - s.name = self - return s - - - def get_dav_props(self, cr): + def open(self, cr, mode=False): + uid = self.context.uid + if self.type in ('collection','database'): + return False + s = StringIO.StringIO(self.get_data(cr)) + s.name = self + return s + + + + def get_dav_props(self, cr): return self.PROPS - def get_dav_eprop(self,cr, ns, propname): + def get_dav_eprop(self,cr, ns, propname): if self.M_NS.has_key(ns): prefix = self.M_NS[ns] else: @@ -391,23 +391,23 @@ class res_node_calendar(nodes.node_class): try: m = getattr(self, mname) - r = m(cr) + r = m(cr) return r except AttributeError, e: print 'Property %s not supported' % propname - print "Exception:", e + print "Exception:", e return None - def get_data(self, cr, fil_obj = None): + def get_data(self, cr, fil_obj = None): uid = self.context.uid calendar_obj = self.context._dirobj.pool.get('basic.calendar') - 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) + 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) return res - def get_data_len(self, cr, fil_obj = None): + def get_data_len(self, cr, fil_obj = None): return self.content_length def set_data(self, cr, data, fil_obj = None): @@ -424,29 +424,29 @@ class res_node_calendar(nodes.node_class): return res - - def _get_caldav_calendar_data(self, cr): + + def _get_caldav_calendar_data(self, cr): return self.get_data(cr) - + 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() - ctx.update(self.dctx) + ctx.update(self.dctx) calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) return calendar.description - + def _get_caldav_calendar_home_set(self, cr): import xml.dom.minidom - import urllib + import urllib uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) - doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) - - calendar_obj = self.context._dirobj.pool.get('basic.calendar') + doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) + + calendar_obj = self.context._dirobj.pool.get('basic.calendar') calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, calendar.collection_id.name))) href = doc.documentElement @@ -461,7 +461,7 @@ class res_node_calendar(nodes.node_class): ctx = self.context.context.copy() ctx.update(self.dctx) user_obj = self.context._dirobj.pool.get('res.users') - user = user_obj.browse(cr, uid, uid, context=ctx) + user = user_obj.browse(cr, uid, uid, context=ctx) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) href = doc.documentElement href.tagName = 'D:href' @@ -472,11 +472,11 @@ class res_node_calendar(nodes.node_class): def _get_caldav_schedule_inbox_URL(self, cr): import xml.dom.minidom - import urllib + import urllib uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) - calendar_obj = self.context._dirobj.pool.get('basic.calendar') + calendar_obj = self.context._dirobj.pool.get('basic.calendar') calendar = calendar_obj.browse(cr, uid, self.calendar_id, context=ctx) res = '%s/%s' %(calendar.name, calendar.collection_id.name) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) @@ -491,20 +491,20 @@ class res_node_calendar(nodes.node_class): uid = self.context.uid res = False if self.type in ('collection','database'): - return False - if self.model and self.res_id: + 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 + + return res def _get_caldav_schedule_outbox_URL(self, cr): return self._get_caldav_schedule_inbox_URL(cr) - + def get_etag(self, cr): """ Get a tag, unique per object + modification. @@ -517,5 +517,6 @@ class res_node_calendar(nodes.node_class): if self.write_date: wtime = time.mktime(time.strptime(self.write_date, '%Y-%m-%d %H:%M:%S')) else: wtime = time.time() - return str(wtime) + return str(wtime) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4 diff --git a/addons/caldav/caldav_view.xml b/addons/caldav/caldav_view.xml index d1cb79a0e4a..9184a0aadd2 100644 --- a/addons/caldav/caldav_view.xml +++ b/addons/caldav/caldav_view.xml @@ -1,6 +1,6 @@ - + Calendar Collections : Form document.directory @@ -17,10 +17,10 @@ Calendar Collections : Tree document.directory - tree + tree - + @@ -73,34 +73,34 @@ - + -
- - - - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + + + - - - + + +
@@ -110,11 +110,11 @@ Calendar : Tree basic.calendar - tree + tree - - + + @@ -127,8 +127,8 @@ ir.actions.act_window basic.calendar form - tree,form - + tree,form +
@@ -147,5 +147,5 @@ action="action_caldav_form" id="menu_caldav_directories" parent="menu_calendar"/> -
+
diff --git a/addons/caldav/wizard/calendar_event_export_view.xml b/addons/caldav/wizard/calendar_event_export_view.xml index cfadf945bf4..3161bb7d45e 100644 --- a/addons/caldav/wizard/calendar_event_export_view.xml +++ b/addons/caldav/wizard/calendar_event_export_view.xml @@ -1,25 +1,25 @@ - + calendar.event.export.form calendar.event.export form
- - - + + + - + -