def process_admin_request(self, req, cat, page, milestone): req.perm.assert_permission('TICKET_ADMIN') # Detail view? if milestone: mil = ticket.Milestone(self.env, milestone) if req.method == 'POST': if req.args.get('save'): mil.name = req.args.get('name') due = req.args.get('duedate', '') try: mil.due = due and util.parse_date(due) or 0 except ValueError, e: raise TracError(e, 'Invalid Date Format') if 'completed' in req.args: completed = req.args.get('completeddate', '') try: mil.completed = completed and \ util.parse_date(completed) or 0 except ValueError, e: raise TracError(e, 'Invalid Date Format') if mil.completed > time.time(): raise TracError('Completion date may not be in the ' 'future', 'Invalid Completion Date') else: mil.completed = 0 mil.description = req.args.get('description', '') mil.update() req.redirect(self.env.href.admin(cat, page)) elif req.args.get('cancel'): req.redirect(self.env.href.admin(cat, page))
def _stats_delete_range(self, req): if not req.args.has_key("start") or not req.args.has_key("end"): return False start = int(util.parse_date(req.args.get("start"))) end = int(util.parse_date(req.args.get("end"))) if DownloadData.delete_range(self.env, start, end): self.env.log.info("Deleted records from " + req.args.get("start") + " to " + req.args.get("end") + ".")
def process_projmanager_request(self, req, cat, page, version): # Detail view? if version: ver = ticket.Version(self.env, version) if req.method == 'POST': if req.args.get('save'): ver.name = req.args.get('name') if req.args.get('time'): try: ver.time = util.parse_date(req.args.get('time')) except ValueError: ver.time = "" ver.description = req.args.get('description') ver.update() req.redirect(self.env.href.projmanager(cat, page)) elif req.args.get('cancel'): req.redirect(self.env.href.projmanager(cat, page)) req.hdf['projmanager.version'] = { 'name': ver.name, 'time': ver.time and util.format_datetime(ver.time) or '', 'description': ver.description } else: if req.method == 'POST': # Add Version if req.args.get('add') and req.args.get('name'): ver = ticket.Version(self.env) ver.name = req.args.get('name') if req.args.get('time'): ver.time = util.parse_date(req.args.get('time')) if req.args.get('description'): ver.description = req.args.get('description') ver.insert() req.redirect(self.env.href.projmanager(cat, page)) # Remove versions elif req.args.get('remove') and req.args.get('sel'): sel = req.args.get('sel') sel = isinstance(sel, list) and sel or [sel] if not sel: raise TracError, 'No version selected' db = self.env.get_db_cnx() for name in sel: ver = ticket.Version(self.env, name, db=db) ver.delete(db=db) db.commit() req.redirect(self.env.href.projmanager(cat, page)) req.hdf['projmanager.versions'] = \ [{'name': version.name, 'time': version.time and util.format_datetime(version.time) or '', 'href': self.env.href.projmanager(cat, page, version.name) } for version in ticket.Version.select(self.env)] return 'projmanager_version.cs', None
def _stats_delete_range(self, req): if not req.args.has_key('start') or not req.args.has_key('end'): return False start = int(util.parse_date(req.args.get('start'))) end = int(util.parse_date(req.args.get('end'))) if DownloadData.delete_range(self.env, start, end): self.env.log.info("Deleted records from " + \ req.args.get('start') + \ " to " + req.args.get('end') + ".")
def _stats_delete_range(self, req): if not req.args.has_key('start') or not req.args.has_key('end'): return False start = int(util.parse_date(req.args['start'].value)) end = int(util.parse_date(req.args['end'].value)) if DownloadData.delete_range(self.env, start, end): self.env.log.info("Deleted records from " + \ req.args['start'].value + \ " to " + req.args['end'].value + ".")
def _create_milestone(self, name, duedate, description): m = Milestone(self.env) m.name = name m.description = description if duedate: if isinstance(duedate, type("")): m.due = parse_date(duedate) else: m.due = duedate m.insert()
def process_admin_request(self, req, cat, page, version): req.perm.assert_permission('TICKET_ADMIN') # Detail view? if version: ver = ticket.Version(self.env, version) if req.method == 'POST': if req.args.get('save'): ver.name = req.args.get('name') if req.args.get('time'): ver.time = util.parse_date(req.args.get('time')) ver.description = req.args.get('description') ver.update() req.redirect(self.env.href.admin(cat, page)) elif req.args.get('cancel'): req.redirect(self.env.href.admin(cat, page)) req.hdf['admin.version'] = { 'name': ver.name, 'time': ver.time and util.format_datetime(ver.time) or '', 'description': ver.description } else: if req.method == 'POST': # Add Version if req.args.get('add') and req.args.get('name'): ver = ticket.Version(self.env) ver.name = req.args.get('name') if req.args.get('time'): ver.time = util.parse_date(req.args.get('time')) ver.insert() req.redirect(self.env.href.admin(cat, page)) # Remove versions elif req.args.get('remove') and req.args.get('sel'): sel = req.args.get('sel') sel = isinstance(sel, list) and sel or [sel] if not sel: raise TracError, 'No version selected' db = self.env.get_db_cnx() for name in sel: ver = ticket.Version(self.env, name, db=db) ver.delete(db=db) db.commit() req.redirect(self.env.href.admin(cat, page)) # Set default version elif req.args.get('apply'): if req.args.get('default'): name = req.args.get('default') self.log.info('Setting default version to %s', name) self.config.set('ticket', 'default_version', name) self.config.save() req.redirect(self.env.href.admin(cat, page)) default = self.config.get('ticket', 'default_version') req.hdf['admin.versions'] = \ [{'name': v.name, 'time': v.time and util.format_datetime(v.time) or '', 'is_default': v.name == default, 'href': self.env.href.admin(cat, page, v.name) } for v in ticket.Version.select(self.env)] req.hdf['admin.date_hint'] = util.get_date_format_hint() req.hdf['admin.datetime_hint'] = util.get_datetime_format_hint() req.hdf['admin.datetime_now'] = util.format_datetime() return 'admin_version.cs', None
elif req.args.get('cancel'): req.redirect(self.env.href.admin(cat, page)) req.hdf['admin.milestone'] = { 'name': mil.name, 'duedate': mil.due and util.format_datetime(mil.due) or '', 'description': mil.description } else: if req.method == 'POST': # Add Milestone if req.args.get('add') and req.args.get('name'): mil = ticket.Milestone(self.env) mil.name = req.args.get('name') if req.args.get('duedate'): mil.due = util.parse_date(req.args.get('duedate')) mil.insert() req.redirect(self.env.href.admin(cat, page)) # Remove milestone elif req.args.get('remove') and req.args.get('sel'): sel = req.args.get('sel') sel = isinstance(sel, list) and sel or [sel] if not sel: raise TracError, 'No milestone selected' db = self.env.get_db_cnx() for name in sel: mil = ticket.Milestone(self.env, name, db=db) mil.delete(db=db) db.commit() req.redirect(self.env.href.admin(cat, page))