diff options
| author | ATP (Open ERP) <> | 2010-03-11 14:08:18 +0530 |
|---|---|---|
| committer | rpa (Open ERP) <rpa@tinyerp.com> | 2010-03-11 14:08:18 +0530 |
| commit | e7fb07589f310a2e1b2d4d8ca8cdea3d7d2a3837 (patch) | |
| tree | 177e865c69b0348d5a58ce6f2cb30604a4a24ff8 /addons | |
| parent | f8fbe2e5dcb796dd3a5790bc1c3242379e02ffd8 (diff) | |
[IMP]: caldav: converted wizards into osv_memory wizards
bzr revid: rpa@tinyerp.com-20100311083818-fp3ve2g95mwa3wxu
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/caldav/__init__.py | 8 | ||||
| -rw-r--r-- | addons/caldav/__terp__.py | 4 | ||||
| -rw-r--r-- | addons/caldav/caldav_wizard.xml | 19 | ||||
| -rwxr-xr-x | addons/caldav/wizard/__init__.py | 7 | ||||
| -rw-r--r-- | addons/caldav/wizard/calendar_event_export.py | 69 | ||||
| -rw-r--r-- | addons/caldav/wizard/calendar_event_export_view.xml | 49 | ||||
| -rw-r--r-- | addons/caldav/wizard/calendar_event_import.py | 78 | ||||
| -rw-r--r-- | addons/caldav/wizard/calendar_event_import_view.xml | 61 | ||||
| -rw-r--r-- | addons/caldav/wizard/calendar_event_subscribe.py | 89 | ||||
| -rw-r--r-- | addons/caldav/wizard/calendar_event_subscribe_view.xml | 61 | ||||
| -rw-r--r-- | addons/caldav/wizard/wizard_cal_export.py | 65 | ||||
| -rw-r--r-- | addons/caldav/wizard/wizard_cal_import.py | 88 | ||||
| -rw-r--r-- | addons/caldav/wizard/wizard_cal_subscribe.py | 97 |
13 files changed, 417 insertions, 278 deletions
diff --git a/addons/caldav/__init__.py b/addons/caldav/__init__.py index 19f11301420..a7731ca526a 100644 --- a/addons/caldav/__init__.py +++ b/addons/caldav/__init__.py @@ -20,10 +20,10 @@ ############################################################################## import caldav -import caldav_cache -import caldav_fs -import caldav_node -import webdav_server +#import caldav_cache +#import caldav_fs +#import caldav_node +#import webdav_server import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/__terp__.py b/addons/caldav/__terp__.py index db6e46b1daa..1d25ad8cb77 100644 --- a/addons/caldav/__terp__.py +++ b/addons/caldav/__terp__.py @@ -49,7 +49,9 @@ "demo_xml" : [], "update_xml" : [ 'security/ir.model.access.csv', - 'caldav_wizard.xml', + 'wizard/calendar_event_export_view.xml', + 'wizard/calendar_event_import_view.xml', + 'wizard/calendar_event_subscribe_view.xml', 'caldav_view.xml' ], "installable" : True, diff --git a/addons/caldav/caldav_wizard.xml b/addons/caldav/caldav_wizard.xml deleted file mode 100644 index eaebba4234a..00000000000 --- a/addons/caldav/caldav_wizard.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - <wizard string="Import .ics File" model="basic.calendar" - name="calendar.event.import" id="wizard_cal_event_import" /> - - <wizard string="Subscribe" - model="basic.calendar" name="calendar.event.subscribe" - id="wizard_cal_event_subscribe" multi="True" /> - - <wizard string="Export .ics File" model="basic.calendar" - name="calendar.event.export" id="wizard_cal_event_export" /> - - <wizard string="Edit this event" model="basic.calendar.event" - name="calendar.event.edit.this" id="wizard_edit_this_event" - menu="False" /> - - </data> -</openerp>
\ No newline at end of file diff --git a/addons/caldav/wizard/__init__.py b/addons/caldav/wizard/__init__.py index 4ab34601a96..1c45cb2a191 100755 --- a/addons/caldav/wizard/__init__.py +++ b/addons/caldav/wizard/__init__.py @@ -19,9 +19,8 @@ # ############################################################################## -import wizard_cal_export -import wizard_cal_import -import wizard_cal_subscribe +import calendar_event_export +import calendar_event_import +import calendar_event_subscribe # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/caldav/wizard/calendar_event_export.py b/addons/caldav/wizard/calendar_event_export.py new file mode 100644 index 00000000000..3bee5a5089f --- /dev/null +++ b/addons/caldav/wizard/calendar_event_export.py @@ -0,0 +1,69 @@ +# -*- 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/>. +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ +import netsvc +import pooler +import time +import tools +import wizard +import base64 + +class calendar_event_export(osv.osv_memory): + """ + Export Calendar Event. + """ + def _process_export_ics(self, cr, uid, context): + """ + Get Default value for file_path field. + """ + model = context.get('model', 'basic.calendar') + model_obj = self.pool.get(model) + calendar = model_obj.export_cal(cr, uid, context['active_ids'], context) + #TODO: check why returns wrong value + return base64.encodestring(calendar) + + def _process_export_ics_name(self, cr, uid, context): + """ + Get Default value for Name field. + """ + model = context.get('model', 'basic.calendar') + model_obj = self.pool.get(model) + calendar = model_obj.export_cal(cr, uid, context['active_ids'], context) + return 'OpenERP %s.ics' % (model_obj._description) + + _name = "calendar.event.export" + _description = "Event Export" + _columns = { + 'file_path':fields.binary('Save ICS file', filters='*.ics', required=True), + 'name':fields.char('File name', size=34, required=True, help='Save in .ics format') + } + + _defaults={ + 'name':_process_export_ics_name, + 'file_path':_process_export_ics + } + +calendar_event_export() + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/wizard/calendar_event_export_view.xml b/addons/caldav/wizard/calendar_event_export_view.xml new file mode 100644 index 00000000000..0a049e15083 --- /dev/null +++ b/addons/caldav/wizard/calendar_event_export_view.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_calendar_event_export" model="ir.ui.view"> + <field name="name">calendar.event.export.form</field> + <field name="model">calendar.event.export</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Export ICS"> + <group colspan="4" > + <field name="name"/> + <field name="file_path" colspan="4" width="300"/> + </group> + <separator string="" colspan="4" /> + <group colspan="4" col="6"> + <button icon="gtk-cancel" special="cancel" string="_Cancel"/> + </group> + </form> + </field> + </record> + + <record id="action_calendar_event_export" model="ir.actions.act_window"> + <field name="name">Export .ics File</field> + <field name="res_model">calendar.event.export</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="view_calendar_event_export"/> + <field name="target">new</field> + <field name="context">{'record_id':active_id}</field> + </record> + +<!-- <record id="action_calendar_event_export_values" model="ir.values">--> +<!-- <field name="model_id" ref="caldav.model_basic_calendar" />--> +<!-- <field name="object" eval="1" />--> +<!-- <field name="name">Export .ics File</field>--> +<!-- <field name="key2">client_action_multi</field>--> +<!-- <field name="value" eval="'ir.actions.act_window,' + str(ref('action_calendar_event_export'))"/>--> +<!-- <field name="key">action</field> --> +<!-- <field name="model">basic.calendar</field>--> +<!-- </record>--> + + + <act_window id="action_calendar_event_export_values" + key2="client_action_multi" name="Export .ics File" + res_model="calendar.event.export" src_model="basic.calendar" + view_mode="form" target="new" view_type="form" /> + + </data> +</openerp> diff --git a/addons/caldav/wizard/calendar_event_import.py b/addons/caldav/wizard/calendar_event_import.py new file mode 100644 index 00000000000..ba72e1c8c6d --- /dev/null +++ b/addons/caldav/wizard/calendar_event_import.py @@ -0,0 +1,78 @@ +# -*- 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/>. +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ +import netsvc +import pooler +import time +import tools +import wizard +import base64 + +class calendar_event_import(osv.osv_memory): + """ + Import Calendar Event. + """ + cnt = 0 + def _process_imp_ics(self, cr, uid, ids, context=None): + """ + Process Import ics File. + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of calendar event import’s IDs + @return: dictionary of calendar evet import window with Import successful msg. + """ + for data in self.read(cr, uid, ids): + model = data.get('model', 'basic.calendar') + model_obj = self.pool.get(model) + context.update({'model': model}) + data_obj = self.pool.get('ir.model.data') + id2 = data_obj._get_id(cr, uid, 'caldav', 'view_calendar_event_import_display') + if id2: + id2 = data_obj.browse(cr, uid, id2, context=context).res_id + vals = model_obj.import_cal(cr, uid, data['file_path'], context['active_id'], context) + global cnt + if vals: + cnt = len(vals) + value = { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'calendar.event.import', + 'views': [(id2,'form'),(False,'tree'),(False,'calendar'),(False,'graph')], + 'type': 'ir.actions.act_window', + 'target': 'new' + } + return value + + _name = "calendar.event.import" + _description = "Event Import" + _columns = { + 'file_path': fields.binary('Select ICS file', filters='*.ics', required=True), + 'msg': fields.text('', readonly=True), + } + _defaults={ + 'msg':lambda *a:'Import Sucessful' + } + +calendar_event_import() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/wizard/calendar_event_import_view.xml b/addons/caldav/wizard/calendar_event_import_view.xml new file mode 100644 index 00000000000..1fbd89b2499 --- /dev/null +++ b/addons/caldav/wizard/calendar_event_import_view.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_calendar_event_import" model="ir.ui.view"> + <field name="name">calendar.event.import.form</field> + <field name="model">calendar.event.import</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Import ICS"> + <group colspan="4" > + <separator string="Select ICS file"/> + <field name="file_path" colspan="4" width="300" nolabel="1"/> + </group> + <separator string="" colspan="4" /> + <group colspan="4" col="6"> + <button icon="gtk-cancel" special="cancel" string="_Cancel"/> + <button icon="gtk-ok" name="_process_imp_ics" string="_Import" type="object"/> + </group> + </form> + </field> + </record> + + <record id="view_calendar_event_import_display" model="ir.ui.view"> + <field name="name">calendar.event.import.form.display</field> + <field name="model">calendar.event.import</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Import Message"> + <group colspan="4" > + <field name="msg" colspan="4" width="300" nolabel="1"/> + </group> + <separator string="" colspan="4" /> + <group colspan="4"> + <button icon="gtk-ok" special="cancel" string="Ok"/> + </group> + </form> + </field> + </record> + + <record id="action_calendar_event_import" model="ir.actions.act_window"> + <field name="name">Import .ics File</field> + <field name="res_model">calendar.event.import</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="view_calendar_event_import"/> + <field name="target">new</field> + <field name="context">{'record_id':active_id}</field> + </record> + + <record id="action_calendar_event_import_values" model="ir.values"> + <field name="model_id" ref="caldav.model_basic_calendar" /> + <field name="object" eval="1" /> + <field name="name">Import .ics File</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_calendar_event_import'))"/> + <field name="key">action</field> + <field name="model">basic.calendar</field> + </record> + + </data> +</openerp> diff --git a/addons/caldav/wizard/calendar_event_subscribe.py b/addons/caldav/wizard/calendar_event_subscribe.py new file mode 100644 index 00000000000..aa539938877 --- /dev/null +++ b/addons/caldav/wizard/calendar_event_subscribe.py @@ -0,0 +1,89 @@ +# -*- 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/>. +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ +import netsvc +import pooler +import time +import tools +import wizard +import base64 +import urllib + +class calendar_event_subscribe(osv.osv_memory): + """ + Subscribe Calendar Event. + """ + cnt = 0 + def _process_imp_ics(self, cr, uid, ids, context=None): + """ + process ics file. + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of calendar event subscribe’s IDs + @return: dictionary of calendar evet subscribe window with Import successful msg. + """ + global cnt + for data in self.read(cr, uid, ids): + try: + f = urllib.urlopen(data['url_path']) + caldata = f.fp.read() + f.close() + except Exception,e: + raise osv.except_osv(_('Error!'), _('Please provide Proper URL !')) + model = data.get('model', 'basic.calendar') + model_obj = self.pool.get(model) + context.update({'url': data['url_path'], + 'model': data.get('model', 'basic.calendar')}) + vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), \ + context['active_id'], context) + if vals: + cnt = vals['count'] + data_obj = self.pool.get('ir.model.data') + id2 = data_obj._get_id(cr, uid, 'caldav', 'view_calendar_event_subscribe_display') + if id2: + id2 = data_obj.browse(cr, uid, id2, context=context).res_id + + value = { + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': 'calendar.event.subscribe', + 'views': [(id2,'form'),(False,'tree'),(False,'calendar'),(False,'graph')], + 'type': 'ir.actions.act_window', + 'target': 'new' + } + return value + + _name = "calendar.event.subscribe" + _description = "Event subscribe" + _columns = { + 'url_path': fields.char('Provide path for remote calendar', size=124, required=True), + 'msg': fields.text('', readonly=True), + } + _defaults={ + 'msg':lambda *a:'Import Sucessful.' + } + +calendar_event_subscribe() + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/wizard/calendar_event_subscribe_view.xml b/addons/caldav/wizard/calendar_event_subscribe_view.xml new file mode 100644 index 00000000000..95c06c20f6e --- /dev/null +++ b/addons/caldav/wizard/calendar_event_subscribe_view.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_calendar_event_subscribe" model="ir.ui.view"> + <field name="name">calendar.event.subscribe.form</field> + <field name="model">calendar.event.subscribe</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Subscribe to Remote Calendar"> + <group colspan="4" > + <separator string="Provide path for Remote Calendar"/> + <field name="url_path" colspan="4" width="300" nolabel="1" widget="url"/> + </group> + <separator string="" colspan="4" /> + <group colspan="4" col="6"> + <button icon="gtk-cancel" special="cancel" string="_Cancel"/> + <button icon="gtk-ok" name="_process_imp_ics" string="_Subscribe" type="object"/> + </group> + </form> + </field> + </record> + + <record id="view_calendar_event_subscribe_display" model="ir.ui.view"> + <field name="name">calendar.event.subscribe.form.display</field> + <field name="model">calendar.event.subscribe</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Message..."> + <group colspan="4" > + <field name="msg" colspan="4" width="300" nolabel="1"/> + </group> + <separator string="" colspan="4" /> + <group colspan="4"> + <button icon="gtk-ok" special="cancel" string="Ok"/> + </group> + </form> + </field> + </record> + + <record id="action_calendar_event_subscribe" model="ir.actions.act_window"> + <field name="name">Subscribe</field> + <field name="res_model">calendar.event.subscribe</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="view_calendar_event_subscribe"/> + <field name="target">new</field> + <field name="context">{'record_id':active_id}</field> + </record> + + <record id="action_calendar_event_subscribe_values" model="ir.values"> + <field name="model_id" ref="caldav.model_basic_calendar" /> + <field name="object" eval="1" /> + <field name="name">Subscribe</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_calendar_event_subscribe'))"/> + <field name="key">action</field> + <field name="model">basic.calendar</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/caldav/wizard/wizard_cal_export.py b/addons/caldav/wizard/wizard_cal_export.py deleted file mode 100644 index f7896c738d7..00000000000 --- a/addons/caldav/wizard/wizard_cal_export.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- 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 wizard -import base64 -import pooler - - -class cal_event_export_wizard(wizard.interface): - form1 = '''<?xml version="1.0"?> - <form string="Export ICS"> - <field name="name"/> - <field name="file_path" colspan="4" width="300"/> - </form>''' - - form1_fields = { - 'file_path': { - 'string': 'Save ICS file', - 'type': 'binary', - 'required': True, - 'filters': '*.ics' - }, - 'name': { - 'string': 'File name', - 'type': 'char', - 'size': 34, - 'required': True, - 'help': 'Save in .ics format'}, - } - - def _process_export_ics(self, cr, uid, data, context): - model = data.get('model') - model_obj = pooler.get_pool(cr.dbname).get(model) - calendar = model_obj.export_cal(cr, uid, data['ids'], context) - return {'file_path': base64.encodestring(calendar), \ - 'name': 'OpenERP %s.ics' % (model_obj._description)} - - states = { - 'init': { - 'actions': [_process_export_ics], - 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, \ - 'state': [('end', '_Cancel', 'gtk-cancel')]}}, - } - -cal_event_export_wizard('calendar.event.export') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/wizard/wizard_cal_import.py b/addons/caldav/wizard/wizard_cal_import.py deleted file mode 100644 index a5670f545fa..00000000000 --- a/addons/caldav/wizard/wizard_cal_import.py +++ /dev/null @@ -1,88 +0,0 @@ -# -*- 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 wizard -import pooler - - -class cal_event_import_wizard(wizard.interface): - form1 = '''<?xml version="1.0"?> - <form string="Import ICS"> - <separator string="Select ICS file"/> - <field name="file_path" colspan="4" width="300" nolabel="1"/> - </form>''' - - form1_fields = { - 'file_path': { - 'string': 'Select ICS file', - 'type': 'binary', - 'required': True, - 'filters': '*.ics' - } - } - display = '''<?xml version="1.0"?> - <form string="Import Message"> - <field name="msg" colspan="4" width="300" nolabel="1"/> - </form>''' - - display_fields = { - 'msg': { - 'string': '', - 'type': 'text', - 'readonly': True, - } - } - - def _process_imp_ics(self, cr, uid, data, context=None): - model = data.get('model') - model_obj = pooler.get_pool(cr.dbname).get(model) - context.update({'model': model}) - vals = model_obj.import_cal(cr, uid, data['form']['file_path'], data['id'], context) - global cnt - cnt = 0 - if vals: - cnt = len(vals) - return {} - - def _result_set(self, cr, uid, data, context=None): - msg = (cnt and "Imported %s components" % cnt) or 'Import Sucessful' - return {'msg': msg} - - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \ - 'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Import', 'gtk-ok')]} - }, - 'open': { - 'actions': [], - 'result': {'type': 'action', 'action': _process_imp_ics, 'state': 'display'} - }, - 'display': { - 'actions': [_result_set], - 'result': {'type': 'form', 'arch': display, 'fields': display_fields, \ - 'state': [('end', 'Ok', 'gtk-ok')]} - }, - } - -cal_event_import_wizard('calendar.event.import') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/caldav/wizard/wizard_cal_subscribe.py b/addons/caldav/wizard/wizard_cal_subscribe.py deleted file mode 100644 index 709c61d0b25..00000000000 --- a/addons/caldav/wizard/wizard_cal_subscribe.py +++ /dev/null @@ -1,97 +0,0 @@ -# -*- 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/>. -# -############################################################################## - -from tools.translate import _ -import base64 -import pooler -import urllib -import wizard - -class cal_event_subscribe_wizard(wizard.interface): - form1 = '''<?xml version="1.0"?> - <form string="Subscribe to Remote Calendar"> - <separator string="Provide path for Remote Calendar"/> - <field name="url_path" colspan="4" width="300" nolabel="1" widget="url"/> - </form>''' - - form1_fields = { - 'url_path': { - 'string': 'Provide path for remote calendar', - 'type': 'char', - 'required': True, - 'size': 124 - } - } - display = '''<?xml version="1.0"?> - <form string="Message..."> - <field name="msg" colspan="4" width="300" nolabel="1"/> - </form>''' - - display_fields = { - 'msg': { - 'string': '', - 'type': 'text', - 'readonly': True, - } - } - - def _process_imp_ics(self, cr, uid, data, context=None): - global cnt - cnt = 0 - try: - f = urllib.urlopen(data['form']['url_path']) - caldata = f.fp.read() - f.close() - except Exception,e: - raise wizard.except_wizard(_('Error!'), _('Please provide Proper URL !')) - model = data.get('model') - model_obj = pooler.get_pool(cr.dbname).get(model) - context.update({'url': data['form']['url_path'], - 'model': data.get('model')}) - vals = model_obj.import_cal(cr, uid, base64.encodestring(caldata), \ - data['id'], context) - if vals: - cnt = vals['count'] - return {} - - def _result_set(self, cr, uid, data, context=None): - return {'msg': 'Import Sucessful.'} - - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \ - 'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Subscribe', 'gtk-ok')]} - }, - 'open': { - 'actions': [], - 'result': {'type': 'action', 'action': _process_imp_ics, 'state': 'display'} - }, - 'display': { - 'actions': [_result_set], - 'result': {'type': 'form', 'arch': display, 'fields': display_fields, \ - 'state': [('end', 'Ok', 'gtk-ok')]} - }, - } - -cal_event_subscribe_wizard('calendar.event.subscribe') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
