def process_request(self, req): req.perm.assert_permission('WIKI_VIEW') # setup permission really_has_perm = req.perm.has_permission('WIKI_VIEW') req.perm.perms['WIKI_VIEW'] = True if not really_has_perm: del req.perm.perms['WIKI_VIEW'] if req.path_info.startswith('/mmv/mmv_view'): # display milestone mmv view today = int(time.time()) / SECPERDAY pathSegments = req.path_info.split('/') milestone = pathSegments[3] if req.method == "POST": go_date = req.args.get("go_date") go_date = getDateFromStr(go_date) if not go_date: cur_date = today else: cur_date = go_date / SECPERDAY + 1 else: cur_date = req.args.get("date") if not cur_date: cur_date = int(time.time()) / SECPERDAY cur_date = int(cur_date) if cur_date > today: cur_date = today prev_date = cur_date - 1 next_date = cur_date + 1 if next_date > today: next_date = today req.hdf['milestone'] = milestone req.hdf['burndown_png'] = req.href.chrome('mmv', 'burndown.png') req.hdf['members_png'] = req.href.chrome('mmv', 'members.png') # puredata, reladata puredata, reladata, unplanneddata = self._relaTicketView(req, milestone, cur_date) req.hdf['puredata'] = puredata req.hdf['reladata'] = reladata req.hdf['unplanneddata'] = unplanneddata # member_list memberList = self._getMemberList(milestone) req.hdf['member_list'] = memberList req.hdf['cur_date'] = cur_date req.hdf['prev_date'] = prev_date req.hdf['next_date'] = next_date req.hdf['cur_date_str'] = formatDateFull(cur_date * SECPERDAY) req.hdf['enable_unplanned'] = self.config.getbool("mmv", "enable_unplanned", True) req.hdf['enable_relaticket'] = self.config.getbool("mmv", "enable_relaticket", True) return 'mmv_view.cs', None elif req.path_info.startswith('/mmv/burndown'): # display mmv burndown image pathSegments = req.path_info.split('/') returnStr = "" if len(pathSegments) == 5: milestone = pathSegments[3] date = int(pathSegments[4][:-4]) # get img string returnStr = self._getBurndownImgStr(milestone, date) _sendResponse(req, returnStr) elif req.path_info.startswith('/mmv/date'): pathSegments = req.path_info.split('/') returnStr = "" if len(pathSegments) == 5: # display worktime image one day milestone = pathSegments[3] date = int(pathSegments[4][:-4]) # get img string returnStr = self._getDateImgStr(milestone, date) _sendResponse(req, returnStr) elif req.path_info.startswith('/mmv/members'): pathSegments = req.path_info.split('/') if len(pathSegments) == 4: # display all members worktime image imgname = pathSegments[3] milestone = imgname[:-4] # get img string returnStr = self._getAllMembersImgStr(milestone) _sendResponse(req, returnStr) elif len(pathSegments) == 5: # display one member worktime image member = pathSegments[3] imgname = pathSegments[4] milestone = imgname[:-4] # get img string returnStr = self._getMemberImgStr(milestone, member) _sendResponse(req, returnStr) elif req.path_info == "/mmv": # display milestone list enabledMilestones = MMV_List.getEnabledMilestones(self.env) # strip milestone name milestone = [] for m in enabledMilestones: milestone.append(m) today = int(time.time()) / SECPERDAY data = [] for m, m_full in zip(milestone, enabledMilestones): filename = "mmv/mmv_view/%s" % (m, ) item = { "filename":filename, "m_full":m_full, } data.append(item) req.hdf["data"] = data # return the cs template return 'mmv_list.cs', 0
def process_admin_request(self, req, cat, page, milestone): req.perm.assert_permission('MMV_ADMIN') if req.args.get('save'): # save # empty table first MMV_List.deleteAll(self.env) # insert selected milestone into table db = self.env.get_db_cnx() selReq = req.args.get('sel') milestoneReq = req.args.get('milestone') startdateReq = req.args.get('startdate') enddateReq = req.args.get('enddate') selList = isinstance(selReq, list) and selReq or [selReq] milestoneList = isinstance(milestoneReq, list) and milestoneReq or [milestoneReq] startdateList = isinstance(startdateReq, list) and startdateReq or [startdateReq] enddateList = isinstance(enddateReq, list) and enddateReq or [enddateReq] for milestone, startdate, enddate in zip(milestoneList, startdateList, enddateList): startdate = getDateFromStr(startdate) enddate = getDateFromStr(enddate) if milestone in selList: enabled = True else: enabled = False MMV_List.insert(self.env, milestone, startdate, enddate, enabled) db.commit() req.redirect(self.env.href.admin(cat, page)) elif req.args.get('repair'): # repair # empty table first MMV_List.deleteAllHistory(self.env) req.redirect(self.env.href.admin(cat, page)) else: # display # get all enabled milestones enabledMilestones = MMV_List.getEnabledMilestones(self.env) ms = Milestone.select(self.env) ms.sort(cmp=lambda x,y: cmp(x.name, y.name)) req.hdf['date_hint'] = "Format: YYYY/MM/DD" req.hdf['milestones'] = [{'name': m.name, 'href': self.env.href.admin(cat, "milestones", m.name), 'enabled': m.name in enabledMilestones, 'startdate': formatDateFull(MMV_List.getStartdateFromDb(self.env, m.name)), 'enddate': formatDateFull(MMV_List.getEnddateFromDb(self.env, m.name)), } for m in ms] return 'mmv_admin.cs', None