Exemplo n.º 1
0
    def process_event(self, req):
        req.perm.assert_permission('CAL_VIEW')

        add_stylesheet (req, 'hw/css/azcalendar.css')
        if req.method == 'GET' and req.args.has_key('id'):
            evt = Event.get_event(self.env,req.args['id'])
            req.hdf['azcalendar.evid'] = req.args['id']
            req.hdf['azcalendar.title'] = evt.get_title()
            req.hdf['azcalendar.author'] = evt.get_author()
            req.hdf['azcalendar.time_begin'] = time.strftime("%Y/%m/%d %H:%M",time.localtime(evt.get_time_begin()))
            req.hdf['azcalendar.time_end'] = time.strftime("%Y/%m/%d %H:%M",time.localtime(evt.get_time_end()))
            req.hdf['azcalendar.event.'+str(EventType[evt.get_type()])] = 1
            req.hdf['azcalendar.priority.'+str(EventPriority[evt.get_priority()])] = 1
            req.hdf['azcalendar.last_update'] = time.strftime("%Y/%m/%d %H:%M:%S",time.localtime(evt.get_time_update()))
            return 'azevent.cs', None

        elif req.method == 'GET' and req.args.has_key('update_event'):
	    req.perm.assert_permission('CAL_EDIT')

            begin_time, end_time, begin_stamp, end_stamp \
              = caltools.parse_time_begin_end(req.args['time_begin'], req.args['time_end'])

            evt = Event.get_event(self.env,req.args['evid'])
            #evt.set_author(req.authname)
            evt.set_type(req.args['type'])
            evt.set_priority(req.args['priority'])
            evt.set_time_update(int(time.time()))
            evt.set_time_begin(begin_stamp)
            evt.set_time_end(end_stamp)
            evt.set_title(req.args['title'])
            date = time.strftime("%Y%m%d", begin_time)
            req.hdf['redir_url'] = str(self.env.href.azcalendar()) + "?date=%s" % date
            return evt.update(self.env, req)

        elif req.method == 'GET' and req.args.has_key('delete_event'):
	    req.perm.assert_permission('CAL_ADMIN')
            begin_time, end_time, begin_stamp, end_stamp \
              = caltools.parse_time_begin_end(req.args['time_begin'], req.args['time_end'])

            evt = Event.get_event(self.env,req.args['evid'])
            date = time.strftime("%Y%m%d", begin_time)
            req.hdf['redir_url'] = str(self.env.href.azcalendar()) + "?date=%s" % date
            return evt.delete(self.env)
Exemplo n.º 2
0
    def process_add(self, req):
        req.perm.assert_permission('CAL_EDIT')
        add_stylesheet (req, 'hw/css/azcalendar.css')

        if req.method == 'GET' and req.args.has_key('date'):
            req.hdf['azcalendar.time_begin'] = time.strftime("%Y/%m/%d",(time.strptime(req.args['date'],"%Y%m%d")))
            req.hdf['azcalendar.time_end'] = time.strftime("%Y/%m/%d",(time.strptime(req.args['date'],"%Y%m%d")))
            return 'add_event.cs', None

        elif req.method == 'GET' and req.args.has_key('new_event'):
            begin_time, end_time, begin_stamp, end_stamp \
              = caltools.parse_time_begin_end(req.args['time_begin'], req.args['time_end'])

            date = time.strftime("%Y%m%d", begin_time)
            req.hdf['redir_url'] = str(self.env.href.azcalendar()) + "?date=%s" % date

            current_stamp = int(time.time())

            # Events with id 0 are created automatically by a DB layer.
            author = req.authname
            evt = Event(0, author, current_stamp, current_stamp, begin_stamp, end_stamp,
                        req.args['type'], req.args['priority'], req.args['title'])

            return evt.save(self.env, req)