def vcs_revlist(self, environ, projectname, vcsid): """Browse repository URLS : /p/{projectname}/s/{vcsid}/revlist?revno=<num> """ from zeta.config.environment import projcomp c.rclose = h.ZResp() # Setup context for page rendering c.projsummary = c.project.summary c.replogs = c.vrep.logs(c.vcs.rooturl, revstart=c.vrep.finfo['l_revision'], revend=c.vrep.linfo['l_revision']) # Create revision url for each log. c.revpages = [[ c.replogs[i][1], self.url_vcsrevlist(projectname, vcsid, revno=c.replogs[i][1]) ] for i in range(0, len(c.replogs), 100)] c.revpages.reverse() adj = c.vrep.client.start_revno c.revlist = [ log + [ self.url_vcsrev(projectname, vcsid, revno=log[1]), ] for log in c.replogs[(c.revno - adj):c.revno + 100 - adj] ] c.revlist.reverse() c.vcseditable = h.authorized(h.HasPermname('VCS_CREATE')) c.title = '%s:revlist' % c.vcs.name # Html page generation c.rclose.append(render('/derived/projects/vcsrevlist.html')) return c.rclose
def forgotpass( self, environ ) : """Prompt user for his/her email-id to construct a reset-link URLS : /accounts/forgotpass?form=request&formname=forgotpass /accounts/forgotpass?form=submit&formname=forgotpass """ from zeta.config.environment import userscomp c.rclose = h.ZResp() c.errormsg = '' if c.form == 'submit' and c.formname == 'forgotpass' : # Send email to user with resetpassword link. emailid = request.POST.get( 'emailid', None ) user = userscomp.userbyemailid( unicode(emailid) ) if user : digest = sha1( user.username + user.emailid + user.password ).hexdigest() fullurl = "%s/%s" % ( h.urlroot(environ), self.url_forresetp(digest, emailid) ) resetpasswd( config, emailid, fullurl, c.sysentries['sitename'] ) else : c.errormsg = 'Invalid emailid' # Generate page c.rclose.append( render( '/derived/accounts/forgotpass.html' )) return c.rclose
def timeline( self, environ, username ) : """User timeline URLS : /u/timeline/{username} """ from zeta.config.environment import userscomp c.rclose = h.ZResp() # Action specific query parameters 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) c.user = userscomp.get_user( username ) self.tline_controller( h.r_usertline, { 'username' : username }, [ 'user' ], fromoff, logid, dir, c.user ) c.title = '%s:timeline' % username c.datatline, c.startdt = h.tlineplot( c.logs[:] ) c.timeline = True # Html page generation c.rclose.append(render( '/derived/userpage/usertline.html' )) return c.rclose
def charts( self, environ ) : """Charts for combined users URLS : /u/charts /u/charts?chartname=<name> """ from zeta.config.environment import userscomp c.rclose = h.ZResp() # Setup context for page rendering c.chartname = c.chartname or 'chart8' c.selectedchart = (c.chartname, self._userscharts[c.chartname]) c.chartoptions = [ (self.url_userschart(name), text) for name, text in self._userscharts.iteritems() ] c.ua = ca.get_analyticobj( 'users' ) if c.chartname == 'chart8' : # User activity c.chart8_data = getattr( c.ua, 'chart8_data', [] ) elif c.chartname == 'chart9' : # User site-permission c.chart9_data = getattr( c.ua, 'chart9_data', [] ) elif c.chartname == 'chart10' : # project administrators c.chart10_data = getattr( c.ua, 'chart10_data', [] ) elif c.chartname == 'chart11' : # Component owners c.chart11_data = getattr( c.ua, 'chart11_data', [] ) c.chart11_ccnt = getattr( c.ua, 'chart11_ccnt', [] ) c.title = 'Users:Charts' # Html page generation c.rclose.append(render( '/derived/userpage/userscharts.html' )) return c.rclose
def usercharts( self, environ, username='' ) : """User charts URLS : /u/{username}/charts /u/{username}/charts?chartname=<name> """ from zeta.config.environment import userscomp c.rclose = h.ZResp() # Setup context for page rendering c.chartname = c.chartname or 'chart12' c.selectedchart = (c.chartname, self._usercharts[c.chartname]) c.chartoptions = [ (self.url_userschart(name), text) for name, text in self._usercharts.iteritems() ] c.user = userscomp.get_user( unicode(username) ) c.ua = ca.get_analyticobj( 'users' ) data = getattr( c.ua, 'chart12_data', {} ).get( c.user.id, [ c.user.id, c.user.username, [] ] ) c.chart12_data = data c.title = '%s:Charts' % username # Html page generation c.rclose.append(render( '/derived/userpage/usercharts.html' )) return c.rclose
def liccreate(self, environ): """Create a new license to be hosted on this site. URLS : /license/create /license/create?form=submit&formname=createlic """ from zeta.config.environment import vfcomp c.rclose = h.ZResp() # Form handling def errhandler(errmsg): c.errmsg = errmsg vfcomp.process(request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['createlic'], user=c.authuser) # Setup context for page generation c.licensenames, c.licenselist, licfields = self._selectoptions() c.title = (c.form == 'request' and '-Skip-') or 'CreateLicense' # Html page generation if c.errmsg: html = self.returnerrmsg(environ) else: html = render('/derived/license/liccreate.html') c.rclose.append(html) return c.rclose
def index( self, environ ) : """Index of all registered users URLS : /u /u?alphaindex=<a> """ from zeta.config.environment import userscomp c.rclose = h.ZResp() # Setup context for page rendering c.users = userscomp.get_user( attrload=[ 'userinfo', 'photofile' ] ) byindex = {} [ byindex.setdefault( u.username[0], [] ).append(u) for u in c.users ] c.indexlist = sorted( byindex.keys() ) if (c.alphaindex == None) and (len(c.users) > h.MAX2SWITCH_ALPHAINDEX) : c.alphaindex = c.indexlist[0] if c.alphaindex : c.users = byindex[c.alphaindex] c.urlusersphoto = dict([ ( u.id, h.url_attach( u.photofile.id ) ) for u in c.users if u.photofile ]) c.title = 'Users' # Html page generation if c.jsonobj and c.view == 'js' : html = self.handlejson(environ) else : html = render( '/derived/userpage/usersindex.html' ) c.rclose.append(html) return c.rclose
def timeline(self, environ, licid): """Action for all license pages. URLS : /license/timeline/<licid> """ from zeta.config.environment import liccomp c.rclose = h.ZResp() # Action specific query parameters 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) c.licensenames, c.licenselist, licfields = self._selectoptions() c.links = ['', '', ''] c.license = None c.timeline = True licid = [_i for _i, _, p in licfields if _i == c.licid_i][0] c.license = liccomp.get_license(licid) self.tline_controller(h.r_lictimeline, {'id': licid_i}, ['license'], fromoff, logid, dir, c.license) c.title = '%s:timeline' % c.license.licensename c.datatline, c.startdt = h.tlineplot(c.logs[:]) # Html page generation c.rclose.append(render('/derived/license/lictline.html')) return c.rclose
def timelines(self, environ): """Timeline log of activities on all license pages URLS : /license/timeline """ from zeta.config.environment import liccomp c.rclose = h.ZResp() # Action specific query parameters 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) c.licensenames, c.licenselist, licfields = self._selectoptions() c.links = ['', '', ''] c.license = None c.timeline = True self.tline_controller(h.r_lictimelines, {}, 'license', fromoff, logid, dir, c.license) c.title = 'LicenseTimeline' c.datatline, c.startdt = h.tlineplot(c.logs[:]) # Html page generation c.rclose.append(render('/derived/license/lictline.html')) return c.rclose
def charts(self, environ): """License analytics chart URLS : /license/charts /license/charts?chartname=<name> """ from zeta.config.environment import liccomp c.rclose = h.ZResp() c.chartname = c.chartname or 'chart6' c.selectedchart = (c.chartname, self._charts[c.chartname]) c.chartoptions = [(self.url_licchart(name), text) for name, text in self._charts.iteritems()] c.la = ca.get_analyticobj('license') c.ta = ca.get_analyticobj('tags') if c.chartname == 'chart6': # Projects Vs license c.chart6_data = getattr(c.la, 'chart6_data', []) elif c.chartname == 'chart7': # Tagged license c.chart7_data = getattr(c.ta, 'chart7_data', []) c.chart7_tags = getattr(c.ta, 'chart7_tags', []) c.title = 'License:Charts' # Html page generation c.rclose.append(render('/derived/license/charts.html')) return c.rclose
def timeline(self, environ, projectname, wurl): """Aggregate activities under project wiki or individual wiki URLS : /p/{projectname}/wiki/timeline/*(wurl) """ from zeta.config.environment import projcomp, wikicomp 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 wikiurl = self.url_wikiurl(projectname, wurl) c.wiki = wikicomp.get_wiki(unicode(wikiurl)) c.wikipagenames = self.wikipagename(wikicomp.wikiurls(c.project)) c.wikipagename = wurl routeargs = {'projectname': projectname, 'wurl': wurl} self.tline_controller(h.r_projwikitline, routeargs, 'wiki', fromoff, logid, dir, c.wiki) c.title = '%s:timeline' % wurl c.datatline, c.startdt = h.tlineplot(c.logs[:]) c.rclose.append(render('/derived/projects/wikitline.html')) return c.rclose
def create( self, environ ) : """Create and host a new project URLS : /p/newproject?form=request&formname=createprj /p/newproject?form=submit&formname=createprj """ from zeta.config.environment import liccomp, projcomp, vfcomp c.rclose = h.ZResp() # Form handling def errhandler(errmsg) : c.errmsg = errmsg vfcomp.process( request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['createprj'], user=c.authuser ) # Setup context for page generation c.licensenames = sorted([ l[1] for l in liccomp.licensefields() ]) c.projectnames = projcomp.projectnames c.liceditable = h.authorized( h.HasPermname(['LICENSE_CREATE']) ) c.title = 'CreateProject' # Html page generation if c.errmsg : html = self.returnerrmsg(environ) elif c.form == 'submit' : h.redirect_url( h.url_createprj ) else : html = render( '/derived/projects/create.html' ) c.rclose.append(html) return c.rclose
def add( self, environ ) : """Add a new attachment URLS : /attachment/add?form=request&formname=addattachs /attachment/add?form=submit&formname=addattachs """ from zeta.config.environment import vfcomp c.rclose = h.ZResp() # Form handling def errhandler( errmsg ) : c.errmsg = errmsg vfcomp.process( request, c, defer=True, errhandler=errhandler, user=c.authuser, formnames=['addattachs'] ) # Setup context for page generation c.title = 'AddAttachs' # Html page generation if c.errmsg : html = self.returnerrmsg(environ) else : html = render( '/derived/attachs/add.html' ) c.rclose.append(html) return c.rclose
def charts(self, environ, projectname): """Charts and analytics for project tickets URLS : /p/{projectname}/r/charts """ c.rclose = h.ZResp() # Setup context for html page c.projsummary = c.project.summary c.chartname = c.chartname or 'chart27' c.selectedchart = (c.chartname, self._charts[c.chartname]) fn = lambda n, t: (self.url_revwchart(projectname, n), t) c.chartoptions = map(fn, self._charts.iteritems()) c.ra = ca.get_analyticobj('reviews') if c.chartname == 'chart27': # Pie chart of reviewers c.chart27_data = getattr(c.ra, 'chart27_data', {}).get(c.project.id, []) c.chart27_usrs = getattr(c.ra, 'chart27_usrs', {}).get(c.project.id, []) c.title = 'ReviewCharts' c.rclose.append(render('/derived/projects/reviewcharts.html')) return c.rclose
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
def timelineadmin( self, environ, projectname ) : """Aggregate all the activities under the project URLS : /p/<projectname>/timeline/admin""" from zeta.config.environment import projcomp 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 routeargs = { 'projectname' : projectname } self.tline_controller( h.r_projadmtline, routeargs, 'project', fromoff, logid, dir, c.project ) c.title = projectname + ':admintimeline' h.url_rssfeed = h.url_for( h.r_projadmfeed, projectname=projectname ) c.datatline, c.startdt = h.tlineplot( c.logs[:] ) c.rclose.append(render( '/derived/projects/admintline.html' )) return c.rclose
def reviewset(self, environ, projectname, rsetid=''): """Review set URLS : /p/{projectname}/rset/{rsetid} """ from zeta.config.environment import userscomp, revcomp, vfcomp c.rclose = h.ZResp() c.projsummary = c.project.summary c.reviewset = revcomp.get_reviewset(int(rsetid), attrload=['reviews'], attrload_all=[ 'reviews.author', 'reviews.moderator', 'reviews.participants', 'reviews.comments', ]) c.reviews = revcomp.addabletorset(c.project, c.reviewset) c.revwloner = [[r[0], resurlname(r[1].split('/'))] for r in c.reviews] c.revwinrset = [[r.id, resurlname(r.resource_url.split('/'))] for r in c.reviewset.reviews] c.title = 'reviewset:%s' % c.reviewset.name c.rclose.append(render('/derived/projects/reviewset.html')) return c.rclose
def uploadlogo( self, environ ) : """Action to upload site logo file""" from zeta.config.environment import vfcomp, userscomp c.rclose = h.ZResp() # Form handling def errhandler(errmsg) : c.errmsg = errmsg vfcomp.process( request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=[ 'sitelogo'] ) c.title = 'SiteLogo' # Html page generation if c.errmsg : html = self.returnerrmsg(environ) elif c.form == 'submit' : h.redirect_url( h.url_siteadmin ) else : html = render( '/derived/siteadmin/sitelogo.html' ) c.rclose.append(html) return html
def vcs_browse(self, environ, projectname, vcsid): """Browse repository URLS : /p/{projectname}/s/{vcsid}/browse /p/{projectname}/s/{vcsid}/browse?revno=<num> /p/{projectname}/s/{vcsid}/browse?repospath=<rooturl>&revno=<num> &jsonobj=dirlist&view=js /p/{projectname}/s/{vcsid}/browse?filepath=<path>&revno=<num> """ from zeta.config.environment import projcomp, vcscomp c.rclose = h.ZResp() # Setup context for page generation c.projsummary = c.project.summary c.rootdir = basename(c.vcs.rooturl.rstrip('/')) c.vcseditable = h.authorized(h.HasPermname('VCS_CREATE')) c.contents = vcscomp.mountcontents c.title = '%s:browse' % c.vcs.name # HTML page generation if c.jsonobj and c.view == 'js': html = self.handlejson(environ) else: c.pmounts = vcscomp.projmounts(c.project) fn = lambda mnt: [ mnt[0], h.fix2repospath(mnt[3], [mnt[7]]).lstrip('/') ] c.mountdirs = map(fn, c.pmounts) html = render('/derived/projects/vcsbrowse.html') c.rclose.append(html) return c.rclose
def roadmap( self, environ, projectname ) : """Milestones and report cards for project, `projectname` URLS : /p/<projectname>/roadmap """ from zeta.config.environment import projcomp, tckcomp c.rclose = h.ZResp() # Setup context for page generation c.projsummary = c.project.summary c.tck_typenames = tckcomp.tcktypenames c.tck_statusnames = tckcomp.tckstatusnames c.tck_severitynames = tckcomp.tckseveritynames c.title = projectname + ':roadmap' c.chart13_data = [] c.mstnresolved = {} fn = lambda k, v : { 'name' : k, 'y' : v } for m in c.project.milestones : bystatus, bytypes, byseverity, byowner, c.mstnresolved[m.id] = \ h.chartify_mstn( c.mstntickets[m.id] ) c.chart13_data.append( [ m.id, map( fn, bytypes.iteritems() ), map( fn, byseverity.iteritems() ), map( fn, bystatus.iteritems() ), map( fn, byowner.iteritems() ), ] ) c.rclose.append(render( '/derived/projects/projroadmap.html' )) return c.rclose
def timeline( self, environ, projectname ) : """Aggregate all the activities under the project URLS : /p/<projectname>/timeline """ from zeta.config.environment import projcomp, tlcomp 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.project = c.project or projcomp.get_project( projectname ) c.projectname = c.project.projectname c.projsummary = c.project.summary c.title = projectname + ':timeline' c.alllogs = tlcomp.fetchprojlogs( c.project, limit=h.TLCOUNT+2, id=logid, direction=dir ) routeargs = { 'projectname' : projectname } self.tline_controller( h.r_projtline, routeargs, [], fromoff, logid, dir, c.project ) h.url_rssfeed = h.url_for( h.r_projfeed, projectname=projectname ) c.datatline, c.startdt = h.tlineplot( c.logs[:] ) c.rclose.append(render( '/derived/projects/projtline.html' )) return c.rclose
def index( self, environ ) : """List all the projects. URLS : /p /p?alphaindex=<alphaindex> """ from zeta.config.environment import projcomp, vfcomp c.rclose = h.ZResp() # Setup context for page generation x = projcomp.get_project( attrload=['admin', 'project_info'] ) c.projects = x c.urlprojects = dict([ ( p.id, self.url_forproject( p.projectname )) for p in x ]) c.title = 'ProjectIndex' byindex = {} [ byindex.setdefault( p.projectname[0], [] ).append(p) for p in x ] c.indexlist = sorted( byindex.keys() ) if (c.alphaindex == None) and (len(c.projects) > h.MAX2SWITCH_ALPHAINDEX) : c.alphaindex = c.indexlist[0] if c.alphaindex : c.projects = byindex[c.alphaindex] # Html page generation c.rclose.append(render( '/derived/projects/index.html' )) return c.rclose
def tagname( self, environ, tgnm ) : """Show tag details""" from zeta.config.environment import tagcomp, projcomp c.rclose = h.ZResp() # Setup context for page generation c.tag = tagcomp.get_tag( tgnm, attrload=[ 'attachments', 'licenses', 'projects', 'tickets', 'reviews', 'wikipages' ], attrload_all=[ 'tickets.project', 'reviews.project', 'wikipages.project' ] ) c.projecturls = self.projecturls( projcomp.projectnames ) # Pie Chart for tagged resource type ta = ca.get_analyticobj( 'tags' ) c.chart1_rtags= getattr( ta, 'chart1_rtags', {} ).get( tgnm, [] ) c.chart1_data = getattr( ta, 'chart1_data', {} ).get( tgnm, [] ) c.title = tgnm # Html page generation c.rclose.append(render( '/derived/tag/tag.html' )) return c.rclose
def timeline( self, environ ) : """Timeline on attachments. URLS : /attachment/timeline """ c.rclose = h.ZResp() # Action specific query parameters 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.links = [ '', '', '' ] self.tline_controller( h.r_attachtimeline, {}, 'attachment', fromoff, logid, dir, modelobj=None ) c.title = 'AttachTimeline' c.timeline = True # Html page generation c.rclose.append(render( '/derived/attachs/tline.html' )) return c.rclose
def timeline(self, environ, projectname, tckid): """Activities under project tickets or individual ticket URLS : /p/{projectname}/t/timeline/{tckid} """ from zeta.config.environment import projcomp, tckcomp 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.seltickets = self._seltickets() routeargs = {'projectname': projectname, 'tckid': tckid} self.tline_controller(h.r_projtcktline, routeargs, 'ticket', fromoff, logid, dir, c.ticket) c.title = 'Ticket:%s:timeline' % tckid c.datatline, c.startdt = h.tlineplot(c.logs[:]) c.rclose.append(render('/derived/projects/tickettline.html')) return c.rclose
def downloads( self, environ, projectname ) : """Action to present project downloads URLS : /p/<projectname>/downloads """ from zeta.config.environment import projcomp c.rclose = h.ZResp() # Setup context for html page c.projsummary = c.project.summary c.title = 'ProjectDownloads' attachments = projcomp.attachments( c.project ) c.attachments = {} for pkey, adict in attachments.iteritems() : attachs = [] for aid, a in adict.iteritems() : if 'download' not in a[-1] : continue a[-1].remove( 'download' ) attachs.append( [ aid ] + adict[aid][:-1] + [ ', '.join(a[-1]) ] + \ [ self.url_attachdownl( aid ) ] ) c.attachments[ pkey[1] ] = attachs # Html page generation c.rclose.append(render( '/derived/projects/projdownloads.html' )) return c.rclose
def create(self, environ, projectname): """Create a new project review URLS : /p/{projectname}/r/createrevw?form=request&formname=createrev /p/{projectname}/r/createrevw?form=submit&formname=createrev """ from zeta.config.environment import projcomp, userscomp, vcscomp, vfcomp cfok = lambda cf : ( cf['mime_type'] != 'text/directory' ) and \ ( cf['changetype'] != 'deleted' ) c.rclose = h.ZResp() # Handle forms def errhandler(errmsg): c.errmsg = errmsg vfcomp.process(request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['createrev'], user=c.authuser) # Setup context for page generation c.projsummary = c.project.summary c.projusers = self.projusers(c.project) c.usernames = sorted(userscomp.usernames) c.rsets = [[rs.id, rs.name] for rs in c.project.reviewsets] c.forsrc = request.params.getall('rurl') c.forversion = request.params.get('ver', None) c.forversion = int(c.forversion) if c.forversion != None else None vcsid = request.params.get('vcsid', None) c.vcs = vcsid and vcscomp.get_vcs(int(vcsid)) c.vrep = c.vcs and va.open_repository(c.vcs) c.title = 'CreateReview' if c.vrep: c.changedfiles = c.vrep.changedfiles(c.vcs.rooturl, revstart=c.forversion - 1, revend=c.forversion) c.forsrc = [ join(c.vcs.rooturl, cf['repos_path'].lstrip('/')) for cf in c.changedfiles if cfok(cf) ] # HTML page generation if c.errmsg: html = self.returnerrmsg(environ) elif c.form == 'submit' and c.formname == 'createrev': # Skip breadcrumbing, if it is a form submit c.title = '-Skip-' h.redirect_url(h.url_revwcreate) else: html = render('/derived/projects/reviewcreate.html') c.rclose.append(html) return c.rclose
def charts( self, environ, projectname ) : """Chart analytics for project `projectname` URLS : /p/<projectname>/charts /p/<projectname>/charts?chartname=<name> """ c.rclose = h.ZResp() # Setup context for page rendering c.projectname = c.project.projectname c.projsummary = c.project.summary c.chartname = c.chartname or 'chart14' c.selectedchart = (c.chartname, self._charts[c.chartname]) c.chartoptions = [ ( self.url_projchart( projectname, name), text ) for name, text in self._charts.iteritems() ] c.pa = ca.get_analyticobj( 'projects' ) c.title = '%s:Charts' % projectname # Html page generation if c.chartname == 'chart14' : c.chart14_data = getattr( c.pa, 'chart14_data', {} ).get( projectname, {} ).items() elif c.chartname == 'chart15' : dates = [] mstns = [] for m in c.project.milestones : created_on = timezone('UTC').localize(m.created_on) dates.extend([ created_on, m.due_date ]) mstns.append(( m, created_on, m.due_date )) mstns = sorted( mstns, key=lambda x: x[1] ) dates = sorted(filter( None, dates )) c.chart15_data = [] for mstn in mstns : m = mstn[0] mrange = mstn[1:3] # stacked bar : open, cancelled, completed if not mrange[1] : days = (dates[-1]-mrange[0]).days elif mrange[1] > mrange[0] : days = (mrange[1]-mrange[0]).days elif mrange[1] <= mrange[0] : days = 0 bar = [ (mrange[0]-dates[0]).days ] if m.completed : bar.extend( [0, 0, days] ) elif m.cancelled : bar.extend( [0, days, 0] ) else : bar.extend( [days, 0, 0] ) c.chart15_data.append( [m.milestone_name] + bar ) date = dates and dates[0] or None c.chart15_frmdt = h.date2jsdate( date, [ '2000', '0', '1' ] ) c.rclose.append(render( '/derived/projects/projcharts.html' )) return c.rclose
def index( self, environ ) : """List of all attachments URLS : /attachment /attachment?fromid=<number> /attachment?all=1 /attachment?form=submit&formname=attachssummary&view=js /attachment?form=submit&formname=attachstags&view=js """ from zeta.config.environment import attcomp, vfcomp c.rclose = h.ZResp() h.url_attachpages = self.url_attachpages() # Form handling def errhandler( errmsg ) : c.errmsg = errmsg vfcomp.process( request, c, defer=True, errhandler=errhandler, user=c.authuser, formnames=['attachssummary', 'attachstags'] ) try : fromid = c.fromid and int(c.fromid) fromid -= 1 except : fromid = None c.title = 'Attachments' c.aa = ca.get_analyticobj( 'attachs' ) c.ua = ca.get_analyticobj( 'users' ) c.la = ca.get_analyticobj( 'license' ) c.pa = ca.get_analyticobj( 'projects' ) c.ta = ca.get_analyticobj( 'tickets' ) c.ra = ca.get_analyticobj( 'reviews' ) c.wa = ca.get_analyticobj( 'wiki' ) # Html page generation if c.errmsg : html = self.returnerrmsg(environ) elif c.view == 'js' : html = '' else : limit = 100 if c.all == None else None attachments = attcomp.attachments( offset=fromid, limit=limit ) attachs = [ [ aid ] + attachments[aid][:-1] + \ [ ', '.join(attachments[aid][-1]) ] + \ [ self.url_attachdownl( aid ) ] for aid in attachments ] c.attachassc= attcomp.attachassc() c.attachments = { 'all-attachments' : attachs } c.editable = h.authorized( h.ValidUser( strict='True' )) html = render( '/derived/attachs/index.html' ) c.rclose.append( html ) return c.rclose
def charts(self, environ, projectname): """Charts and analytics for project wiki URLS : /p/{projectname}/wiki/charts /p/{projectname}/wiki/charts?chartname=<name> """ from zeta.config.environment import wikicomp c.rclose = h.ZResp() # Setup context for page generation c.projsummary = c.project.summary c.selectedchart = (c.chartname, self._charts[c.chartname]) c.chartoptions = [(self.url_wikichart(projectname, name), text) for name, text in self._charts.iteritems()] c.ta = ca.get_analyticobj('tags') c.wa = ca.get_analyticobj('wiki') if c.chartname == 'chart16': # Wiki comments and versions c.chart16_data = getattr(c.wa, 'chart16_data', {}).get(c.project.id, []) c.chart16_wiki = getattr(c.wa, 'chart16_wiki', {}).get(c.project.id, []) elif c.chartname == 'chart17': # Wiki votes c.chart17_data = getattr(c.wa, 'chart17_data', {}).get(c.project.id, []) elif c.chartname == 'chart18': # Wiki authors c.chart18_data = getattr(c.wa, 'chart18_data', {}).get(c.project.id, []) c.chart18_usrs = getattr(c.wa, 'chart18_usrs', {}).get(c.project.id, []) elif c.chartname == 'chart19': # Wiki commentors c.chart19_data = getattr(c.wa, 'chart19_data', {}).get(c.project.id, []) c.chart19_usrs = getattr(c.wa, 'chart19_usrs', {}).get(c.project.id, []) elif c.chartname == 'chart20': # Tagged wiki pages c.chart20_data = getattr(c.ta, 'chart20_data', {}).get(c.project.id, []) c.chart20_tags = getattr( c.ta, 'chart20_tags', {}, ).get(c.project.id, []) c.title = 'WikiCharts' c.rclose.append(render('/derived/projects/wikicharts.html')) return c.rclose