Example #1
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)