Example #1
0
    def process_request(self, req):
        req.perm.assert_permission("BURNDOWN_VIEW")

        db = self.env.get_db_cnx()

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)

        selected_milestone = None
        if len(milestones) > 0:
            selected_milestone = dbhelper.get_current_milestone(db, req.args.get("selected_milestone", ""))

        selected_component = req.args.get("selected_component", "All Components")

        empty_db_for_testing = req.args.get("empty_db_for_testing", "false")
        if empty_db_for_testing == "true":
            req.perm.assert_permission("TRAC_ADMIN")
            dbhelper.empty_db_for_testing(db)

        # expose display data to the templates
        data = {}
        data["milestones"] = req.hdf["milestones"] = milestones
        data["components"] = req.hdf["components"] = components
        data["selected_milestone"] = req.hdf["selected_milestone"] = selected_milestone
        data["selected_component"] = req.hdf["selected_component"] = selected_component
        data["draw_graph"] = req.hdf["draw_graph"] = False
        data["start"] = req.hdf["start"] = False

        if req.perm.has_permission("BURNDOWN_ADMIN"):
            data["start"] = req.hdf["start"] = True  # show the start and complete milestone buttons to admins

        if req.args.has_key("start"):
            self.start_milestone(db, selected_milestone["name"])

        data["draw_graph"] = req.hdf["draw_graph"] = True
        self.update_burndown_data()

        data["burndown_data"] = req.hdf["burndown_data"] = []
        data["burndown_data"] = req.hdf["burndown_data"] = self.get_burndown_data(
            db, selected_milestone, components, selected_component
        )

        add_stylesheet(req, "hw/css/burndown.css")

        self.update_burndown_data()

        if self.tracversion == "0.10":
            add_script(req, "hw/js/line.js")
            add_script(req, "hw/js/wz_jsgraphics.js")
            return "burndown.cs", None
        else:
            data["library"] = ""
            if data["library"] == "flot":
                add_script(req, "hw/js/jquery.flot.js")
            else:
                add_script(req, "hw/js/line.js")
                add_script(req, "hw/js/wz_jsgraphics.js")

            return "burndown.html", data, None
Example #2
0
    def process_request(self, req):
        req.perm.assert_permission('BURNDOWN_VIEW')

        db = self.env.get_db_cnx()

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)
        
        selected_milestone = None
        if (len(milestones)>0):
            selected_milestone = dbhelper.get_current_milestone(db, req.args.get('selected_milestone', ""))
        
        selected_component = req.args.get('selected_component', 'All Components')
        
        empty_db_for_testing = req.args.get('empty_db_for_testing', 'false')
        if empty_db_for_testing == "true":
            req.perm.assert_permission('TRAC_ADMIN')
            dbhelper.empty_db_for_testing(db)
        
        # expose display data to the templates
        data = {}
        data['milestones'] = req.hdf['milestones'] = milestones
        data['components'] = req.hdf['components'] = components
        data['selected_milestone'] = req.hdf['selected_milestone'] = selected_milestone
        data['selected_component'] = req.hdf['selected_component'] = selected_component
        data['draw_graph'] = req.hdf['draw_graph'] = False
        data['start'] = req.hdf['start'] = False
        
        if req.perm.has_permission("BURNDOWN_ADMIN"):
            data['start'] = req.hdf['start'] = True # show the start and complete milestone buttons to admins
        
        if req.args.has_key('start'):
            self.start_milestone(db, selected_milestone['name'])

        data['draw_graph'] = req.hdf['draw_graph'] = True
        self.update_burndown_data()
                
        data['burndown_data'] = req.hdf['burndown_data'] = []
        data['burndown_data'] = req.hdf['burndown_data'] = self.get_burndown_data(db, selected_milestone, components, selected_component)
        
        add_stylesheet(req, 'hw/css/burndown.css')
        
        self.update_burndown_data()
        
        if self.tracversion=="0.10":
            add_script(req, 'hw/js/line.js')
            add_script(req, 'hw/js/wz_jsgraphics.js')
            return 'burndown.cs', None
        else:
            data['library'] = ''
            if data['library'] == 'flot':
                add_script(req, 'hw/js/jquery.flot.js')
            else:
                add_script(req, 'hw/js/line.js')
                add_script(req, 'hw/js/wz_jsgraphics.js')
            
            return 'burndown.html', data, None
Example #3
0
    def update_burndown_data(self):
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        
        # today's date
        today = format_date(int(time.time()))

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)
        
        for mile in milestones:
            if mile['started'] and not mile['completed']: # milestone started, but not completed
                for comp in components:
                    sqlSelect =     "SELECT est.value AS estimate, ts.value AS spent "\
                                        "FROM ticket t "\
                                        "    LEFT OUTER JOIN ticket_custom est ON (t.id = est.ticket AND est.name = 'estimatedhours') "\
                                        "    LEFT OUTER JOIN ticket_custom ts ON (t.id = ts.ticket AND ts.name = 'totalhours') "\
                                        "WHERE t.component = %s AND t.milestone = %s"\
                                        "    AND status IN ('new', 'assigned', 'reopened', 'accepted') "
                    cursor.execute(sqlSelect, [comp['name'], mile['name']])
                
                    rows = cursor.fetchall()
                    hours = 0
                    estimate = 0
                    spent = 0
                    if rows:
                        for estimate, spent in rows:
                            if not estimate:
                                estimate = 0
                            if not spent:
                                spent = 0
                        
                            if (float(estimate) - float(spent)) > 0:
                                hours += float(estimate) - float(spent)

                    cursor.execute("SELECT id FROM burndown WHERE date = %s AND milestone_name = %s"\
                                        "AND component_name = %s", [today, mile['name'], comp['name']])
            
                    row = cursor.fetchone()
                    
                    try:
                        if row:
                            cursor.execute("UPDATE burndown SET hours_remaining = %s WHERE date = %s AND milestone_name = %s"\
                                           "AND component_name = %s", [hours, today, mile['name'], comp['name']])
                        else:
                            cursor.execute("INSERT INTO burndown(component_name, milestone_name, date, hours_remaining) "\
                                           "    VALUES(%s,%s,%s,%s)", [comp['name'], mile['name'], today, hours])
                    except Exception, inst:
                        self.log.debug(type(inst))     # the exception instance
                        self.log.debug(inst.args)      # arguments stored in .args
                        self.log.debug(inst)           # __str__ allows args to printed directly
                        cursor.connection.rollback()
                    else:
                        db.commit()
Example #4
0
    def process_request(self, req):
        req.perm.assert_permission('BURNDOWN_VIEW')

        db = self.env.get_db_cnx()

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)

        selected_milestone = None
        if len(milestones) > 0:
            selected_milestone = dbhelper.get_current_milestone(
                db, req.args.get('selected_milestone', ''))

        selected_component = req.args.get('selected_component',
                                          'All Components')

        empty_db_for_testing = req.args.get('empty_db_for_testing', 'false')
        if empty_db_for_testing == "true":
            req.perm.assert_permission('TRAC_ADMIN')
            dbhelper.empty_db_for_testing(db)

        # expose display data to the templates
        data = {
            'milestones': milestones,
            'components': components,
            'selected_milestone': selected_milestone,
            'selected_component': selected_component,
            'draw_graph': True,
            'start': req.perm.has_permission('BURNDOWN_ADMIN'),
        }

        if 'start' in req.args:
            self.start_milestone(db, selected_milestone['name'])

        self.update_burndown_data()

        data['burndown_data'] = \
            self.get_burndown_data(db, selected_milestone, components,
                                   selected_component)

        add_stylesheet(req, 'hw/css/burndown.css')

        self.update_burndown_data()

        data['library'] = ''
        if data['library'] == 'flot':
            add_script(req, 'hw/js/jquery.flot.js')
        else:
            add_script(req, 'hw/js/line.js')
            add_script(req, 'hw/js/wz_jsgraphics.js')

            return 'burndown.html', data, None
Example #5
0
    def process_request(self, req):
        req.perm.assert_permission('BURNDOWN_VIEW')

        db = self.env.get_db_cnx()

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)

        selected_milestone = None
        if len(milestones) > 0:
            selected_milestone = dbhelper.get_current_milestone(
                db, req.args.get('selected_milestone', ''))

        selected_component = req.args.get('selected_component',
                                          'All Components')

        empty_db_for_testing = req.args.get('empty_db_for_testing', 'false')
        if empty_db_for_testing == "true":
            req.perm.assert_permission('TRAC_ADMIN')
            dbhelper.empty_db_for_testing(db)

        # expose display data to the templates
        data = {
            'milestones': milestones,
            'components': components,
            'selected_milestone': selected_milestone,
            'selected_component': selected_component,
            'draw_graph': True,
            'start': req.perm.has_permission('BURNDOWN_ADMIN'),
        }

        if 'start' in req.args:
            self.start_milestone(db, selected_milestone['name'])

        self.update_burndown_data()

        data['burndown_data'] = \
            self.get_burndown_data(db, selected_milestone, components,
                                   selected_component)

        add_stylesheet(req, 'hw/css/burndown.css')

        self.update_burndown_data()

        data['library'] = ''
        if data['library'] == 'flot':
            add_script(req, 'hw/js/jquery.flot.js')
        else:
            add_script(req, 'hw/js/line.js')
            add_script(req, 'hw/js/wz_jsgraphics.js')

            return 'burndown.html', data, None
    def render_admin_panel(self, req, cat, page, milestone):
        req.perm.assert_permission('BURNDOWN_ADMIN')
        db = self.env.get_db_cnx()

        if milestone:
            mil = dbhelper.get_milestone(db, milestone)
            if req.method == 'POST':
                if req.args.get('save'):
                    mil['started'] = None
                    started = req.args.get('started', '')
                    if started:
                        startdate = parse_date(started, req.tz)
                        # todo: fill empty dates in
                        mil['started'] = startdate
                        dbhelper.set_startdate_for_milestone(
                            db, mil['name'], to_timestamp(mil['started']))

                    req.redirect(req.href.admin(cat, page))
                elif req.args.get('cancel'):
                    req.redirect(req.href.admin(cat, page))

            data = {'view': 'detail', 'milestone': mil}
        else:
            db = self.env.get_db_cnx()
            cursor = db.cursor()
            milestones = []
            for milestone in dbhelper.get_milestones(db):
                milestones.append(milestone)

            data = {
                'view': 'list',
                'milestones': milestones,
                'default': self.config.get('ticket', 'default_milestone')
            }

        data.update({
            'date_hint': get_date_format_hint(),
            'datetime_hint': get_datetime_format_hint()
        })

        return 'config.html', data
    def render_admin_panel(self, req, cat, page, milestone):
        req.perm.assert_permission('BURNDOWN_ADMIN')
        db = self.env.get_db_cnx()            

        if milestone:
            mil = dbhelper.get_milestone(db, milestone)
            if req.method == 'POST':
                if req.args.get('save'):
                    mil['started'] = None
                    started = req.args.get('started', '')
                    if started:
                        startdate = parse_date(started, req.tz)
                        # todo: fill empty dates in
                        mil['started'] = startdate
                        dbhelper.set_startdate_for_milestone(db, mil['name'], to_timestamp(mil['started']))

                    req.redirect(req.href.admin(cat, page))
                elif req.args.get('cancel'):
                    req.redirect(req.href.admin(cat, page))
            
            data = {'view': 'detail', 
                    'milestone': mil
                    }
        else:
            db = self.env.get_db_cnx()
            cursor = db.cursor()
            milestones = []
            for milestone in dbhelper.get_milestones(db):
                milestones.append(milestone)

            data = {'view': 'list',
                    'milestones': milestones,
                    'default': self.config.get('ticket', 'default_milestone')
                    }
            
        data.update({
            'date_hint': get_date_format_hint(),
            'datetime_hint': get_datetime_format_hint()
        })

        return 'config.html', data
Example #8
0
    def update_burndown_data(self):
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        # today's date
        today = format_date(int(time.time()))

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)

        for mile in milestones:
            if mile['started'] and not mile['completed']:
                for comp in components:
                    cursor.execute("""
                        SELECT est.value AS estimate, ts.value AS spent
                        FROM ticket t
                        LEFT OUTER JOIN ticket_custom est
                          ON (t.id = est.ticket AND est.name = 'estimatedhours')
                        LEFT OUTER JOIN ticket_custom ts
                          ON (t.id = ts.ticket AND ts.name = 'totalhours')
                        WHERE t.component = %s AND t.milestone = %s
                          AND status IN ('new', 'assigned', 'reopened',
                            'accepted')""", (comp['name'], mile['name']))

                    rows = cursor.fetchall()
                    hours = 0
                    if rows:
                        for estimate, spent in rows:
                            if not estimate:
                                estimate = 0
                            if not spent:
                                spent = 0

                            if (float(estimate) - float(spent)) > 0:
                                hours += float(estimate) - float(spent)

                    cursor.execute("""
                        SELECT id FROM burndown
                        WHERE date = %s AND milestone_name = %s
                        AND component_name = %s
                        """, (today, mile['name'], comp['name']))

                    row = cursor.fetchone()

                    try:
                        if row:
                            cursor.execute("""
                                UPDATE burndown SET hours_remaining = %s
                                WHERE date = %s AND milestone_name = %s
                                AND component_name = %s
                                """, (hours, today, mile['name'], comp['name']))
                        else:
                            cursor.execute("""
                                INSERT INTO burndown(component_name,
                                  milestone_name, date, hours_remaining)
                                VALUES(%s,%s,%s,%s)
                                """, (comp['name'], mile['name'], today, hours))
                    except Exception, inst:
                        self.log.debug(type(inst))
                        self.log.debug(inst.args)
                        self.log.debug(inst)
                        cursor.connection.rollback()
                    else:
                        db.commit()
Example #9
0
    def update_burndown_data(self):
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        # today's date
        today = format_date(int(time.time()))

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)

        for mile in milestones:
            if mile['started'] and not mile['completed']:
                for comp in components:
                    cursor.execute(
                        """
                        SELECT est.value AS estimate, ts.value AS spent
                        FROM ticket t
                        LEFT OUTER JOIN ticket_custom est
                          ON (t.id = est.ticket AND est.name = 'estimatedhours')
                        LEFT OUTER JOIN ticket_custom ts
                          ON (t.id = ts.ticket AND ts.name = 'totalhours')
                        WHERE t.component = %s AND t.milestone = %s
                          AND status IN ('new', 'assigned', 'reopened',
                            'accepted')""", (comp['name'], mile['name']))

                    rows = cursor.fetchall()
                    hours = 0
                    if rows:
                        for estimate, spent in rows:
                            if not estimate:
                                estimate = 0
                            if not spent:
                                spent = 0

                            if (float(estimate) - float(spent)) > 0:
                                hours += float(estimate) - float(spent)

                    cursor.execute(
                        """
                        SELECT id FROM burndown
                        WHERE date = %s AND milestone_name = %s
                        AND component_name = %s
                        """, (today, mile['name'], comp['name']))

                    row = cursor.fetchone()

                    try:
                        if row:
                            cursor.execute(
                                """
                                UPDATE burndown SET hours_remaining = %s
                                WHERE date = %s AND milestone_name = %s
                                AND component_name = %s
                                """,
                                (hours, today, mile['name'], comp['name']))
                        else:
                            cursor.execute(
                                """
                                INSERT INTO burndown(component_name,
                                  milestone_name, date, hours_remaining)
                                VALUES(%s,%s,%s,%s)
                                """,
                                (comp['name'], mile['name'], today, hours))
                    except Exception, inst:
                        self.log.debug(type(inst))
                        self.log.debug(inst.args)
                        self.log.debug(inst)
                        cursor.connection.rollback()
                    else:
                        db.commit()
Example #10
0
    def update_burndown_data(self):
        db = self.env.get_db_cnx()
        cursor = db.cursor()

        # today's date
        today = format_date(int(time.time()))

        milestones = dbhelper.get_milestones(db)
        components = dbhelper.get_components(db)

        for mile in milestones:
            if mile["started"] and not mile["completed"]:  # milestone started, but not completed
                for comp in components:
                    sqlSelect = (
                        "SELECT est.value AS estimate, ts.value AS spent "
                        "FROM ticket t "
                        "    LEFT OUTER JOIN ticket_custom est ON (t.id = est.ticket AND est.name = 'estimatedhours') "
                        "    LEFT OUTER JOIN ticket_custom ts ON (t.id = ts.ticket AND ts.name = 'totalhours') "
                        "WHERE t.component = %s AND t.milestone = %s"
                        "    AND status IN ('new', 'assigned', 'reopened', 'accepted') "
                    )
                    cursor.execute(sqlSelect, [comp["name"], mile["name"]])

                    rows = cursor.fetchall()
                    hours = 0
                    estimate = 0
                    spent = 0
                    if rows:
                        for estimate, spent in rows:
                            if not estimate:
                                estimate = 0
                            if not spent:
                                spent = 0

                            if (float(estimate) - float(spent)) > 0:
                                hours += float(estimate) - float(spent)

                    cursor.execute(
                        "SELECT id FROM burndown WHERE date = %s AND milestone_name = %s" "AND component_name = %s",
                        [today, mile["name"], comp["name"]],
                    )

                    row = cursor.fetchone()

                    try:
                        if row:
                            cursor.execute(
                                "UPDATE burndown SET hours_remaining = %s WHERE date = %s AND milestone_name = %s"
                                "AND component_name = %s",
                                [hours, today, mile["name"], comp["name"]],
                            )
                        else:
                            cursor.execute(
                                "INSERT INTO burndown(component_name, milestone_name, date, hours_remaining) "
                                "    VALUES(%s,%s,%s,%s)",
                                [comp["name"], mile["name"], today, hours],
                            )
                    except Exception, inst:
                        self.log.debug(type(inst))  # the exception instance
                        self.log.debug(inst.args)  # arguments stored in .args
                        self.log.debug(inst)  # __str__ allows args to printed directly
                        cursor.connection.rollback()
                    else:
                        db.commit()