[FIX, IMP] Interface to see the documentation for caldav sync
authorThibault Francois <tfr@openerp.com>
Thu, 6 Jan 2011 12:17:06 +0000 (13:17 +0100)
committerThibault Francois <tfr@openerp.com>
Thu, 6 Jan 2011 12:17:06 +0000 (13:17 +0100)
bzr revid: tfr@openerp.com-20110106121706-jfggd7o5uy9xzbzk

addons/caldav/wizard/caldav_browse.py
addons/caldav/wizard/caldav_browse_view.xml
addons/crm_caldav/crm_caldav_view.xml

index 551f492..390641e 100644 (file)
@@ -23,14 +23,37 @@ from osv import osv, fields
 from tools import config
 import base64
 import addons
+from tools.translate import _
 
 class caldav_browse(osv.osv_memory):
+    
+    __doc = {'other' : _("""
+  * Webdav server that provides remote access to calendar
+  * Synchronisation of calendar using WebDAV
+  * Customize calendar event and todo attribute with any of OpenERP model
+  * Provides iCal Import/Export functionality
+
+    To access Calendars using CalDAV clients, point them to:
+        http://HOSTNAME:PORT/webdav/DATABASE_NAME/calendars/users/USERNAME/c
+
+    To access OpenERP Calendar using WebCal to remote site use the URL like:
+        http://HOSTNAME:PORT/webdav/DATABASE_NAME/Calendars/CALENDAR_NAME.ics
+
+      Where,
+        HOSTNAME: Host on which OpenERP server(With webdav) is running
+        PORT : Port on which OpenERP server is running (By Default : 8069)
+        DATABASE_NAME: Name of database on which OpenERP Calendar is created
+        CALENDAR_NAME: Name of calendar to access
+     """),
+     'iphone' : _("""It's complicated""")}
+    
+    
     _name = 'caldav.browse'
     _description = 'Caldav Browse'
 
     _columns = {
-        'url' : fields.char('Caldav Server', size=264, required=True),
-        'caldav_doc_file':fields.binary('Caldav Document', readonly=True, help="Caldav Document ile."),
+        'url' : fields.char('Caldav Server', size=264, required=True, help="Url of the caldav server, use for synchronization"),
+        'caldav_doc_file':fields.binary('Caldav Document', readonly=True, help="download full caldav Documentation."),
         'description':fields.text('Description', readonly=True)
     }
 
@@ -59,29 +82,16 @@ class caldav_browse(osv.osv_memory):
         current_user = user_pool.browse(cr, uid, uid, context=context)
         pref_obj = self.pool.get('user.preference')
         pref_ids = pref_obj.browse(cr, uid ,context.get('rec_id',False), context=context)
+        #TODO write documentation
+        res['description'] = self.__doc['other']
         if pref_ids:
            pref_ids = pref_ids[0] 
-           url = host + ':' + str(port) + '/'+ pref_ids.service + '/' + cr.dbname + '/'+'calendar/'+ 'users/'+ current_user.login + '/'+ pref_ids.collection.name+ '/'+ pref_ids.calendar.name
+           url = host + ':' + str(port) + '/'+ pref_ids.service + '/' + cr.dbname + '/'+'calendars/'+ 'users/'+ current_user.login + '/'+ pref_ids.collection.name+ '/'+ pref_ids.calendar.name
+           res['description'] = self.__doc.get(pref_ids.device , self.__doc['other'])
         file = open(addons.get_module_resource('caldav','doc', 'Caldav_doc.pdf'),'rb')
         res['caldav_doc_file'] = base64.encodestring(file.read())
-        res['description'] = """
-  * Webdav server that provides remote access to calendar
-  * Synchronisation of calendar using WebDAV
-  * Customize calendar event and todo attribute with any of OpenERP model
-  * Provides iCal Import/Export functionality
-
-    To access Calendars using CalDAV clients, point them to:
-        http://HOSTNAME:PORT/webdav/DATABASE_NAME/calendars/users/USERNAME/c
-
-    To access OpenERP Calendar using WebCal to remote site use the URL like:
-        http://HOSTNAME:PORT/webdav/DATABASE_NAME/Calendars/CALENDAR_NAME.ics
-
-      Where,
-        HOSTNAME: Host on which OpenERP server(With webdav) is running
-        PORT : Port on which OpenERP server is running (By Default : 8069)
-        DATABASE_NAME: Name of database on which OpenERP Calendar is created
-        CALENDAR_NAME: Name of calendar to access
-     """
+        
+        
         res['url'] = prefix+url
         return res
 
@@ -94,16 +104,38 @@ caldav_browse()
 class user_preference(osv.osv_memory):
     
     _name = 'user.preference'
-    _description = 'User preference FOrm'
+    _description = 'User preference Form'
 
     _columns = {
                'collection' :fields.many2one('document.directory', "Calendar Collection", required=True, domain = [('calendar_collection', '=', True)]),
                'calendar' :fields.many2one('basic.calendar', 'Calendar', required=True),
-               'service': fields.selection([('webdav','WEBDAV'),('vdir','VDIR')], "Services")
-    }    
+               'service': fields.selection([('webdav','CalDAV')], "Services"),
+               'device' : fields.selection([('other', 'Other'), ('iphone', 'iPhone'), ('android', 'Android based device'),('thunderbird', 'Sunbird/Thunderbird'), ('evolution','Evolution')], "Software/Devices")
+    }
+    
+    def _get_default_calendar(self, cr, uid, context):
+        if context == None:
+            context = {}
+        name = context.get('cal_name')
+        
+        collection_obj = self.pool.get('basic.calendar')
+        ids = collection_obj.search(cr, uid, [('name', '=', name)])
+        return ids[0]
+       
+        
+    def _get_default_collection(self, cr, uid, context):
+        collection_obj = self.pool.get('document.directory')
+        ids = collection_obj.search(cr, uid, [('name', '=', 'c')])
+        return ids[0]
+    
+        
     _defaults={
-              'service': lambda *a: 'webdav' 
-   }    
+              'service': 'webdav',
+              'collection' : _get_default_collection,
+              'calendar' : _get_default_calendar,
+              'device' : 'other'
+    }    
+   
     def open_window(self, cr, uid, ids, context=None):
         obj_model = self.pool.get('ir.model.data')
         model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','caldav_Browse')])
index 38e8f55..dc3e53b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <openerp>
-       <data>
+    <data>
 
     <record id="caldav_browse_form" model="ir.ui.view">
             <field name="name">caldav_Browse</field>
@@ -8,18 +8,19 @@
             <field name="type">form</field>
             <field name="arch" type="xml">
                 <form string="Browse caldav" >
-                                       <group colspan="4" width="700" height="500">
-                                               <separator string="Browse caldav" colspan="4"/>
-                                               <field name="url" colspan="4" />
-                                               <field name="caldav_doc_file"  colspan="4" />
-                                               <separator string="Description" colspan="4"/>
-                                               <field name="description"  colspan="4"  nolabel="1"/>
-                                               <separator colspan="4"/>
-                                               <group col="4" colspan="4">
-                                                       <label string="" colspan="2"/>
-                                                       <button name="browse_caldav" string="_Ok" type="object" icon="gtk-ok"/>
-                                               </group>
-                                       </group>
+                    <group colspan="4" width="700" height="500">
+                        <separator string="Browse caldav" colspan="4"/>
+                        <field name="url" colspan="4" />
+                        
+                        <separator string="Description" colspan="4"/>
+                        <field name="description"  colspan="4"  nolabel="1"/>
+                        <separator colspan="4"/>
+                        <field name="caldav_doc_file"  colspan="4" />
+                        <group col="4" colspan="4">
+                            <label string="" colspan="2"/>
+                            <button name="browse_caldav" string="_Ok" type="object" icon="gtk-ok"/>
+                        </group>
+                    </group>
                 </form>
             </field>
         </record>
             <field name="arch" type="xml">
                 <form string="User Preference">
                     <separator string="" colspan="4"/>
-                    <field name="service"  colspan="4" width="250"/>
-                    <field name="collection"  colspan="4" width="250"/>
-                    <field name="calendar"  colspan="4" width="250" domain="[('collection_id','=', collection)]"/>
+                    <field name="service"  colspan="4" width="250" readonly="1"/>
+                    <field name="collection"  colspan="4" width="250" invisible="1" />
+                    <field name="calendar"  colspan="4" width="250" domain="[('collection_id','=', collection)]" readonly="1"/>
+                    <field name="device"  colspan="4" width="250" />
                     <separator colspan="4"/>
                     <group col="4" colspan="4">
                         <label string="" colspan="2"/>
             </field>
         </record>
 
-        <record id="action_caldav_browse" model="ir.actions.act_window">
-            <field name="name">Caldav Browse</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">user.preference</field>
-            <field name="view_id" ref="user_prefernce_form"/>
-            <field name="view_type">form</field>
-            <field name="view_mode">form</field>
-            <field name="target">new</field>
-        </record>
-       </data>
+        
+    </data>
 </openerp>
index c5d557e..cc1b6d0 100644 (file)
@@ -1,11 +1,24 @@
 <?xml version="1.0"?>
 <openerp>
     <data>
+        <record id="action_caldav_browse" model="ir.actions.act_window">
+            <field name="name">Caldav Browse</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">user.preference</field>
+            <field name="view_id" ref="caldav.user_prefernce_form"/>
+            <field name="context">{'cal_name' : 'Meetings'}</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">form</field>
+            <field name="target">new</field>
+        </record>
+    
         <menuitem
             name="Synchronyze this calendar"
-            action="caldav.action_caldav_browse"
+            action="action_caldav_browse"
             id="menu_caldav_browse"
             icon="STOCK_EXECUTE"
             parent="crm.menu_meeting_sale" sequence="1"/>
+            
+        
     </data>
 </openerp>