From f012f8aa756ae70513fc845a4783025b4bf9e8ee Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Wed, 30 Dec 2009 13:47:59 +0530 Subject: [PATCH] [ADD]: project_calendar: Added wizard to subscribe to remote calendar bzr revid: rpa@tinyerp.com-20091230081759-dbvvosaj8vlx7hw4 --- .../project_calendar_wizard.xml | 4 + addons/project_calendar/wizard/__init__.py | 1 + .../wizard/wizard_cal_subscribe.py | 95 +++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 addons/project_calendar/wizard/wizard_cal_subscribe.py diff --git a/addons/project_calendar/project_calendar_wizard.xml b/addons/project_calendar/project_calendar_wizard.xml index 97410cade5c..b30abb809e0 100644 --- a/addons/project_calendar/project_calendar_wizard.xml +++ b/addons/project_calendar/project_calendar_wizard.xml @@ -9,6 +9,10 @@ multi="True" /> + + diff --git a/addons/project_calendar/wizard/__init__.py b/addons/project_calendar/wizard/__init__.py index 009d377ad04..6bb857e3a21 100644 --- a/addons/project_calendar/wizard/__init__.py +++ b/addons/project_calendar/wizard/__init__.py @@ -21,5 +21,6 @@ import wizard_cal_export import wizard_cal_import +import wizard_cal_subscribe # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/project_calendar/wizard/wizard_cal_subscribe.py b/addons/project_calendar/wizard/wizard_cal_subscribe.py new file mode 100644 index 00000000000..a67ff03879c --- /dev/null +++ b/addons/project_calendar/wizard/wizard_cal_subscribe.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +from tools.translate import _ +import base64 +import pooler +import urllib +import wizard + +class project_cal_subscribe_wizard(wizard.interface): + form1 = ''' +
+ + + ''' + + form1_fields = { + 'url_path': { + 'string': 'Provide path for remote calendar', + 'type': 'char', + 'required': True, + 'size': 124 + } + } + display = ''' +
+ + ''' + + 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 !')) + + task_obj = pooler.get_pool(cr.dbname).get('project.task') + context.update({'url': data['form']['url_path']}) + vals = task_obj.import_cal(cr, uid, base64.encodestring(caldata), context) + if vals: + cnt = vals['count'] + return {} + + def _result_set(self, cr, uid, data, context=None): + return {'msg': 'Subscribed %s Task(s)' % cnt} + + 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')]} + }, + } + +project_cal_subscribe_wizard('caldav.project.subscribe') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file