Back to index

plone3  3.1.7
event_edit_form.py
Go to the documentation of this file.
00001 ##parameters=change='', change_and_view=''
00002 ##
00003 from Products.CMFCalendar.utils import Message as _
00004 from Products.CMFDefault.utils import decode
00005 
00006 form = context.REQUEST.form
00007 if change and \
00008         context.event_edit_control(**form) and \
00009         context.setRedirect(context, 'object/edit'):
00010     return
00011 elif change_and_view and \
00012         context.event_edit_control(**form) and \
00013         context.setRedirect(context, 'object/view'):
00014     return
00015 
00016 
00017 options = {}
00018 
00019 options['title'] = form.get('title', context.Title())
00020 options['description'] = form.get('description', context.Description())
00021 options['contact_name'] = form.get('contact_name', context.contact_name)
00022 options['location'] = form.get('location', context.location)
00023 options['contact_email'] = form.get('contact_email', context.contact_email)
00024 options['event_type'] = form.get('event_type', context.Subject())
00025 options['contact_phone'] = form.get('contact_phone', context.contact_phone)
00026 options['event_url'] = form.get('event_url', context.event_url)
00027 
00028 date_strings = context.getStartStrings()
00029 options['effectiveYear'] = form.get('effectiveYear', date_strings['year'])
00030 options['effectiveMo'] = form.get('effectiveMo', date_strings['month'])
00031 options['effectiveDay'] = form.get('effectiveDay', date_strings['day'])
00032 
00033 time_strings = context.getStartTimeString().split()
00034 options['start_time'] = form.get('start_time', time_strings[0])
00035 AMPM = (len(time_strings) == 2 and time_strings[1] or 'pm')
00036 options['startAMPM'] = form.get('startAMPM', AMPM)
00037 
00038 date_strings = context.getEndStrings()
00039 options['expirationYear'] = form.get('expirationYear', date_strings['year'])
00040 options['expirationMo'] = form.get('expirationMo', date_strings['month'])
00041 options['expirationDay'] = form.get('expirationDay', date_strings['day'])
00042 
00043 time_strings = context.getStopTimeString().split()
00044 options['stop_time'] = form.get('stop_time', time_strings[0])
00045 AMPM = (len(time_strings) == 2 and time_strings[1] or 'pm')
00046 options['stopAMPM'] = form.get('stopAMPM', AMPM)
00047 
00048 buttons = []
00049 target = context.getActionInfo('object/edit')['url']
00050 buttons.append( {'name': 'change', 'value': _(u'Change')} )
00051 buttons.append( {'name': 'change_and_view', 'value': _(u'Change and View')} )
00052 options['form'] = { 'action': target,
00053                     'listButtonInfos': tuple(buttons) }
00054 
00055 return context.event_edit_template(**decode(options, script))