Exemplo n.º 1
0
    def analyse(self):
        from zeta.config.environment import revcomp

        reviews = revcomp.get_review()

        self.rdets = self.do_rdets(reviews)
        self.chart27_data, self.chart27_usrs = self.do_chart27(reviews)
Exemplo n.º 2
0
    def timeline(self, environ, projectname, revwid=''):
        """Aggregate activities under project review or individual review
        URLS :
            /p/{projectname}/r/timeline/{revwid}
        """
        from zeta.config.environment import projcomp, revcomp

        c.rclose = h.ZResp()

        logid = request.params.get('logid', None)
        dir = request.params.get('dir', None)
        fromoff = request.params.get('fromoff', 1)
        logid = logid and int(logid)
        fromoff = int(fromoff)

        # Setup context for page generation
        c.projsummary = c.project.summary
        c.review = revwid and revcomp.get_review(int(revwid)) or None
        c.revweditable = h.authorized(h.HasPermname('REVIEW_CREATE'))
        routeargs = {'projectname': projectname, 'revwid': revwid}
        self.tline_controller(h.r_projrevwtline, routeargs, 'review', fromoff,
                              logid, dir, c.review)
        c.title = 'Review:%s:timeline' % c.review.id
        c.datatline, c.startdt = h.tlineplot(c.logs[:])
        c.rclose.append(render('/derived/projects/reviewtline.html'))
        return c.rclose
Exemplo n.º 3
0
    def do_chart14(self, projects):
        """Compute project activity based on functions,
        chart14_data,
        { projectname : { review:count, wiki:count, ticket:count,
                          vcs:count, admin:count },
          ...
        }"""
        from zeta.config.environment    import  \
                projcomp, tckcomp, vcscomp, revcomp, wikicomp

        chart14_data = dict([(p.projectname, {
            'ticket': 0,
            'vcs': 0,
            'review': 0,
            'wiki': 0,
            'admin': 0
        }) for p in projcomp.get_project()])

        for t in tckcomp.get_ticket(attrload=['project']):
            d = chart14_data[t.project.projectname]
            d['ticket'] += len(t.logs)
        for v in vcscomp.get_vcs(attrload=['project']):
            d = chart14_data[v.project.projectname]
            d['vcs'] += len(v.logs)
        for r in revcomp.get_review(attrload=['project']):
            d = chart14_data[r.project.projectname]
            d['review'] += len(r.logs)
        for w in wikicomp.get_wiki(attrload=['project']):
            d = chart14_data[w.project.projectname]
            d['wiki'] += len(w.logs)
        for p in projcomp.get_project():
            d = chart14_data[p.projectname]
            d['admin'] += len(p.logs)
        return chart14_data
Exemplo n.º 4
0
    def commit(self, config, byuser, tz='UTC', attachments=[]):
        """If the identified structure is Review, commit the data to DB"""
        from zeta.config.environment import attcomp, projcomp, revcomp

        data = self.dataset
        attrs = [
            'reviewid', 'rcmtid', 'projectname', 'projectid', 'position',
            'nature', 'action', 'approved', 'tags', 'favorite', 'comment'
        ]

        kwargs = dict([(k, data.get(k, None)) for k in attrs])

        p = kwargs.pop('projectname', None)
        p = p or kwargs.pop('projectid', None)
        p = p and projcomp.get_project(p)

        r = kwargs.pop('reviewid', None)
        rcmt = kwargs.pop('rcmtid', None)
        r = revcomp.get_review(r)

        nature = kwargs.pop('nature', None)
        action = kwargs.pop('action', None)
        approved = kwargs.pop('approved', None)
        position = kwargs.pop('position', None)
        comment = kwargs.pop('comment', None)

        if r and comment and position:
            revcomp.create_reviewcomment(
                r, (None, position, comment, byuser, nature, None),
                byuser=byuser)
        elif rcmt:
            revcomp.process_reviewcomment(rcmt,
                                          reviewnature=nature,
                                          reviewaction=action,
                                          approve=approved,
                                          byuser=byuser)
        if r:
            # Favorite
            fav = kwargs.pop('favorite', None)
            fav == True and revcomp.addfavorites(r, [byuser], byuser=byuser)
            fav == False and revcomp.delfavorites(r, [byuser], byuser=byuser)

            # Tags
            tags = kwargs.pop('tags', [])
            tags and revcomp.add_tags(r, tags=tags, byuser=byuser)

        # Attachments
        if r:
            for fname, fcont in attachments:
                att = attcomp.create_attach(fname,
                                            FileC(fcont),
                                            uploader=byuser)
                revcomp.add_attach(r, att, byuser=byuser)
Exemplo n.º 5
0
    def indexreview( self, reviews=[], clear=False, replace=False, flush=True ) :
        """Index all the reviews passed as argument, or index all the reviews in
        the database if 'reviews' is empty.
        If clear == True,
            then do the reverse, (i.e) clear the list of reviews from index
        If replace == True,
            then replace the list of reviews with new data"""
        from zeta.config.environment import revcomp

        config = self.compmgr.config
        if config['zeta.xapiansearch'] :
            do_onetime( config )
            reviews = reviews or revcomp.get_review()
            if clear :
                [ self.clear( 'id:review_%s' % r.id, flush=flush ) for r in reviews ]
            else :
                [ self.index( revcomp.documentof( r ), replace, flush=flush )
                  for r in reviews ]
        return
Exemplo n.º 6
0
    def feed(self, environ, projectname, revwid=''):
        """Aggregate activities under project review or individual review
        URLS :
            /p/{projectname}/r/feed/{revwid}
        """
        from zeta.config.environment import revcomp

        title = '%s-revw:%s' % (projectname, revwid)
        link = h.urlroot(environ)
        descr = 'Timeline for review, %s in project %s' % (
            c.review.resource_url, projectname)
        c.projsummary = c.project.summary
        c.review = revcomp.get_review(int(revwid)) if revwid else None
        feed = h.FeedGen(title, link, descr)
        routeargs = {'projectname': projectname, 'revwid': revwid}
        self.tline_controller(h.r_projrevwtline, routeargs, 'review', 1, None,
                              None, c.review)
        feedhtml = self.feeds(environ, link, feed, c.logs)
        response.content_type = 'application/atom+xml'
        return feedhtml
Exemplo n.º 7
0
 def sr_reviewurl(self, projectname, id):
     from zeta.config.environment import revcomp
     review = revcomp.get_review(id)
     return self.url_revwid(projectname, review.id)
Exemplo n.º 8
0
    def urlfor_match( self, m, urlconstructor ) :
        """Construct url for the matching document"""
        from zeta.config.environment import \
                    userscomp, attcomp, liccomp, syscomp, projcomp, tckcomp, \
                    revcomp, wikicomp

        do_onetime( self.compmgr.config )
        doc     = m.document
        doctype = doc.get_value( DOCTYPE )
        id      = doc.get_value( ID )
        if doctype == 'user' :
            user    = userscomp.get_user( int(id ))
            text    = 'User : %s' % user.username
            url     = urlconstructor['user']( int(id)  )
        elif doctype == 'attach' :
            attach  = attcomp.get_attach( int(id ))
            # Attachments can be deleted
            if attach :
                text = 'Attachment : %s' % attach.filename
                url  = urlconstructor['attach']( int(id) )
            else :
                text = '-- Missing attachment. May be deleted'
                url  = ''
        elif doctype == 'license' :
            license = liccomp.get_license( int(id ))
            # License can be deleted
            if license :
                text = 'License : %s' % license.licensename
                url  = urlconstructor['license']( int(id) )
            else :
                text = '-- Missing License. May be deleted'
                url  = ''
        elif doctype == 'staticwiki' :  # id is 'path'
            swiki = syscomp.get_staticwiki( unicode(id) )
            text = 'Guest Wiki : %s' % swiki.path
            url = urlconstructor['staticwiki']( id )
        elif doctype == 'project' :
            project = projcomp.get_project( int(id) )
            text = 'Project : %s' % project.projectname
            url = urlconstructor['project']( int(id) )
        elif doctype == 'ticket' :
            projectname = doc.get_value( PROJECTNAME )
            ticket = tckcomp.get_ticket( int(id) )
            text = '(%s) Ticket : %s' % (projectname, ticket.summary)
            url = urlconstructor['ticket']( projectname, int(id) )
        elif doctype == 'review' :
            projectname = doc.get_value( PROJECTNAME )
            review  = revcomp.get_review( int(id) )
            text    = '(%s) Review : %s' % (projectname, review.id)
            url = urlconstructor['review']( projectname, int(id) )
        elif doctype == 'wiki' :
            projectname = doc.get_value( PROJECTNAME )
            wiki    = wikicomp.get_wiki( int(id) )
            text    = '(%s) Wiki : %s' % \
                            (projectname, os.path.basename(wiki.wikiurl))
            url = urlconstructor['wiki']( projectname, int(id) )
        else :
            text = ''
            url  = ''

        return text, url