[ADD]: project_calendar: Added wizard to subscribe to remote calendar
bzr revid: rpa@tinyerp.com-20091230081759-dbvvosaj8vlx7hw4
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
multi="True"
|
||||
/>
|
||||
|
||||
<wizard string="Subscribe to a Remote calendar" model="project.task"
|
||||
name="caldav.project.subscribe" id="wizard_project_cal_subscribe" multi="True"
|
||||
/>
|
||||
|
||||
<wizard string="Set RRULE" model="crm.case"
|
||||
name="caldav.set.rrule" id="wizard_crm_set_rrule" menu="False"
|
||||
/>
|
||||
|
||||
@@ -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:
|
||||
@@ -0,0 +1,95 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 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 project_cal_subscribe_wizard(wizard.interface):
|
||||
form1 = '''<?xml version="1.0"?>
|
||||
<form string="Subscribe to Remote ICS">
|
||||
<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 !'))
|
||||
|
||||
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:
|
||||
Reference in New Issue
Block a user