Exemplo n.º 1
0
    def _getDateList(self, milestone):
        """ get all dates of a milestone
        """
        # get min milestone date
        startdate = MMV_List.getStartdate(self.env, milestone)
        # get max milestone date
        enddate = MMV_List.getEnddate(self.env, milestone)

        

        dateMin = int(startdate) / SECPERDAY
        dateMax = int(enddate) / SECPERDAY

        dateList = range(dateMax, dateMin - 1, -1)

        return dateList
Exemplo n.º 2
0
    def _getBurndownImgStr(self, milestone, date):
        """ get burndown image string
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        # prepare chart data
        # init chart data
        chartData = {"due":{},
                     "done":{},
                    }

        # get history data from db
        # get min milestone date
        startdate = MMV_List.getStartdate(self.env, milestone)
        # get max milestone date
        enddate = MMV_List.getEnddate(self.env, milestone)
        if not startdate:
            # no ticket in this milestone
            # skip
            return ""

        dateMin = int(startdate) / SECPERDAY + 1
        dateMax = int(enddate) / SECPERDAY + 1
        if dateMax > date:
            dateMax = date


        max_history_date = MMV_List.getMaxHistoryDate(self.env, milestone)
        # add history
        for add_date in range(dateMin, dateMax + 1):
            if add_date < max_history_date - 2:
                # don't update stable history
                continue
            MMV_List(self.env).addHistory(self.env, add_date, milestone)

        # get due
        dueData = MMV_List.getDue(self.env, dateMin, dateMax, milestone)
        for date, dueDays in dueData:
            dateString = formatDateCompact(date * SECPERDAY)
            chartData["due"][dateString] = dueDays

        # get done
        doneData = MMV_List.getDue(self.env, dateMin, dateMax, milestone)
        for date, doneDays in doneData:
            dateString = formatDateCompact(date * SECPERDAY)
            chartData["done"][dateString] = doneDays

        # genearte chart
        subMilestone = stripMilestoneName(milestone)
        returnStr = self._genLineChart(chartData, subMilestone, subMilestone)

        return returnStr
Exemplo n.º 3
0
    def _getMemberImgStr(self, milestone, member):
        """ get one member image string
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        # prepare chart data
        # init chart data
        chartData = {"due":{},
                     "done":{},
                    }


        # get history data from db
        # get min milestone date
        startdate = MMV_List.getStartdate(self.env, milestone)
        # get max milestone date
        enddate = MMV_List.getEnddate(self.env, milestone)

        dateMin = int(startdate) / SECPERDAY
        dateMax = int(enddate) / SECPERDAY

        # due
        for aDay in range(dateMin, dateMax + 1):
            dateString = formatDateCompact(aDay * SECPERDAY)
            dateEndTime = (aDay + 1) * SECPERDAY

            sqlString = """
                SELECT tc.ticket, tc.name, tc.value 
                FROM ticket_custom tc, ticket t 
                WHERE tc.ticket = t.id 
                AND tc.name = '%(duetime)s' 
                AND t.id IN (
                    SELECT ta.id FROM 
                    (SELECT id
                     FROM ticket
                     WHERE time < %(dateEndTime)s  AND owner = '%(member)s' ) AS ta 
                     LEFT JOIN
                    (SELECT DISTINCT B.ticket AS ticket, B.time AS time, A.newvalue AS newvalue
                     FROM ticket_change A,
                     (SELECT  ticket, max(time) AS time
                     FROM ticket_change 
                     WHERE field = 'status' 
                     AND time < %(dateEndTime)s
                     GROUP BY ticket 
                     ORDER BY ticket) AS B
                     WHERE A.ticket = B.ticket 
                     AND A.time = B.time
                     AND A.field = 'status'
                     AND newvalue IN ('closed','reopened') ) AS tb 
                     ON ta.id = tb.ticket
                     WHERE tb.newvalue != 'closed' OR tb.newvalue IS NULL
                     )  
                AND t.milestone = '%(milestone)s';
            """ % {'dateEndTime':dateEndTime, 
                    'milestone':milestone, 
                    'member':member, 
                    'duetime':_getDueField(self.config), }

            cursor.execute(sqlString)
            rows = cursor.fetchall()

            # calculate total due days
            dueDays = 0
            for row in rows:
                duetime = row[2]
                dueDays += dueday(duetime)

            chartData["due"][dateString] = dueDays


        # done
        for aDay in range(dateMin, dateMax + 1):
            dateString = formatDateCompact(aDay * SECPERDAY)
            dateEndTime = (aDay + 1) * SECPERDAY

            sqlString = """
                SELECT tc.ticket, tc.name, tc.value 
                FROM ticket_custom tc, ticket t 
                WHERE tc.ticket = t.id 
                AND tc.name = '%(duetime)s' 
                AND t.id IN (
                    SELECT ta.id FROM 
                    (SELECT id
                     FROM ticket
                     WHERE time < %(dateEndTime)s  AND owner = '%(member)s' ) AS ta 
                     LEFT JOIN
                    (SELECT DISTINCT B.ticket AS ticket, B.time AS time, A.newvalue AS newvalue
                     FROM ticket_change A,
                     (SELECT  ticket, max(time) AS time
                     FROM ticket_change 
                     WHERE field = 'status' 
                     AND time < %(dateEndTime)s
                     GROUP BY ticket 
                     ORDER BY ticket) AS B
                     WHERE A.ticket = B.ticket 
                     AND A.time = B.time
                     AND A.field = 'status'
                     AND newvalue IN ('closed','reopened') ) AS tb 
                     ON ta.id = tb.ticket
                     WHERE tb.newvalue = 'closed'
                     )  
                AND t.milestone = '%(milestone)s';
            """ % {'dateEndTime':dateEndTime, 
                    'milestone':milestone, 
                    'member':member, 
                    'duetime':_getDueField(self.config), }

            cursor.execute(sqlString)
            rows = cursor.fetchall()

            # calculate total due days
            dueDays = 0
            for row in rows:
                duetime = row[2]
                dueDays += dueday(duetime)

            chartData["done"][dateString] = dueDays


        print chartData

        # genearte chart
        subMilestone = stripMilestoneName(milestone)
        returnStr = self._genLineChart(chartData, subMilestone, member)

        return returnStr
Exemplo n.º 4
0
    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
Exemplo n.º 5
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