def mainnav(self, projname=None, controller='projects'): """Generate the mainnavigation panel for project, `projname`, with the active tab for the panel specifying by the offset activetab. Freshly constructed 'mainnavs' array of anchor objects, for a specific project can be cached harmlessly. """ mainnavs = [ Anchor( href=h.url_projecthome, text=projname, title='%s project home' % projname, tab='inactive', ), Anchor( href=h.url_projectwiki, text='Wiki', title='Wiki Pages for ' + projname, tab='inactive', ), Anchor( href=h.url_projectticket, text='Tickets', title='Open Tickets and issues for ' + projname, tab='inactive', ), Anchor( href=h.url_projectvcs, text='Source', title='Browse Source code for ' + projname, tab='inactive', ), Anchor( href=h.url_projectreview, text='Review', title='Manage project reviews ' + projname, tab='inactive', ), ] # `Admin` tab is visible only for current project's administrator and # site administrator if h.authorized(h.SiteAdmin()) or h.authorized(h.ProjectAdmin()): mainnavs.append( Anchor( href=h.url_projectadmin, text='Admin', title='Adminstration for ' + projname, tab='inactive', )) [setattr(mainnavs[i], 'tab', 'inactive') for i in range(len(mainnavs))] mainnavs[tabmap[controller]].tab = 'active' return mainnavs
def publishwiki( self, projectname, pagename, content ) : """ === publishwiki( projectname, pagename, content ) :Description :: Publish new content, (or updated content) for wiki-page `pagename`, under project, `projectname`, Positional arguments, |= projectname | a valid project-name |= pagename | valid and existing wiki page-name |= content | content to be published (as the next version). :Return :: On success, [<PRE { 'rpcstatus' : 'ok' } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp wikiurl = unicode(self.url_wikiurl( projectname, self._stripurl( pagename) )) author = c.authuser res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'WIKI_CREATE' )) ) if res : return res else : rc, wiki, failmsg = xicomp.update_wiki( unicode(projectname), wikiurl, unicode(content), author ) return _result( rc, failmsg=failmsg )
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 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 listwikipages( self, projectname ) : """ === listwikipage( projectname ) :Description :: List wiki pages under project, `projectname`, Positional arguments, |= projectname | a valid project-name :Return :: On success, [<PRE { 'rpcstatus' : 'ok', 'wikipages' : [ <page-name>, <page-name>, .... ] } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'WIKI_VIEW' )) ) if res : return res else : rc, wikipages, failmsg = xicomp.list_wiki( unicode(projectname) ) return _result( True, d={ 'wikipages' : sorted(wikipages) })
def listtickets( self, projectname ) : """ === listtickets( projectname ) :Description :: List all tickets under project `projectname`, Positional arguments, |= projectname | a valid project-name :Return :: On success, [<PRE { 'rpcstatus' : 'ok', 'tickets' : { <ticket-id> : [ <summary> ], ... } } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'TICKET_VIEW' )) ) if res : return res else : rc, d, failmsg = xicomp.list_ticket( unicode(projectname) ) return _result( rc, d=d, failmsg=failmsg )
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 commentonticket( self, projectname, ticket, comment ) : """ === commentonticket( projectname, ticket, comment ) :Description :: Comment on `ticket` under project `projectname` Positional arguments, |= projectname | a valid project-name |= ticket | a valid ticket id |= comment | comment as wiki text :Return :: On success, [<PRE { 'rpcstatus' : 'ok' } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp commentor = c.authuser res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'TICKET_COMMENT_CREATE' )) ) if res : return res else : rc, tcmt, failmsg = xicomp.comment_ticket( unicode(projectname), int(ticket), unicode(comment), commentor ) return _result( rc, failmsg=failmsg )
def commentonwiki( self, projectname, pagename, comment ) : """ === commentonwiki( projectname, pagename, comment ) :Description :: Comment on wiki-page, `pagename under project, `projectname`, Positional arguments, |= projectname | a valid project-name |= pagename | valid and existing wiki page-name |= comment | comment as wiki text :Return :: On success, [<PRE { 'rpcstatus' : 'ok' } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp wikiurl = unicode(self.url_wikiurl( projectname, self._stripurl( pagename) )) commentor = c.authuser res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'WIKICOMMENT_CREATE' )) ) if res : return res else : rc, wcmt, failmsg = xicomp.comment_wiki( unicode(projectname), wikiurl, unicode(comment), commentor ) return _result( rc, failmsg=failmsg )
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 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 tos(self, environ): """Static Wiki - Terms of Service .... Deprecated .... """ from zeta.config.environment import syscomp c.rclose = h.ZResp() c.sweditable = h.authorized(h.HasPermname('STATICWIKI_CREATE')) c.swiki = syscomp.get_staticwiki(u'tos') c.swhtml = c.swiki and c.swiki.texthtml or '' c.rclose.append(render('/derived/home/guestwiki.html')) return c.rclose
def inviteuser( self, environ ) : """Invite a new user to join the site URLS : /u/inviteuser /u/inviteuser?form=submit&formname=inviteuser """ from zeta.config.environment import vfcomp c.rclose = h.ZResp() # Authorize: This context attribute should be set before calling the # viewcontext() method. regrbyinvite = h.str2bool( c.sysentries['regrbyinvite'] ) invitebyall = h.str2bool( c.sysentries['invitebyall'] ) c.usercaninvite = \ ( regrbyinvite and invitebyall and \ h.authorized( h.ValidUser( strict='True' )) \ ) or \ ( regrbyinvite and h.authorized( h.SiteAdmin() ) ) # Form handling def errhandler(errmsg) : c.errmsg = errmsg if c.usercaninvite : vfcomp.process( request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['inviteuser'], user=c.authuser, environ=environ ) c.title = 'InviteUser' # Html page generation if c.usercaninvite : html = render( '/derived/userpage/inviteuser.html' ) else : html = render( '/derived/userpage/inviteuser.html' ) c.rclose.append(html) return c.rclose
def attachs(self, environ): """Action to present attachment page for all license URLS : /license/attachs """ from zeta.config.environment import liccomp, vfcomp c.rclose = h.ZResp() c.editable = h.authorized(h.HasPermname('LICENSE_CREATE')) c.attachments = self.attachments(liccomp.attachments()) c.title = 'LicenseAttachs' # Html page generation c.rclose.append(render('/derived/license/licattachs.html')) return c.rclose
def index(self, environ): """Static Wiki - Home page. URLS : / """ from zeta.config.environment import syscomp c.rclose = h.ZResp() # Setup context for page generation c.sweditable = h.authorized(h.HasPermname('STATICWIKI_CREATE')) c.swiki = syscomp.get_staticwiki(u'frontpage') c.title = config['zeta.sitename'] c.swhtml = c.swiki and c.swiki.texthtml or '' c.rclose.append(render('/derived/home/guestwiki.html')) return c.rclose
def projecthome( self, environ, projectname ) : """Project main-page for `projectname` URLS : /p/<projectname> /p/<projectname>?translate=1 /p/<projectname>?jsonobj=projectlogo&view=js /p/<projectname>?jsonobj=projecticon&view=js /p/<projectname>?form=submit&formname=projfav&view=js """ from zeta.config.environment import projcomp, wikicomp, vfcomp c.rclose = h.ZResp() # Form handling def errhandler(errmsg) : c.errmsg = errmsg vfcomp.process( request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['projfav'], user=c.authuser ) # Setup context for page generation c.projsummary = c.project.summary pt = {} [ pt.setdefault( t.teamtype.team_type, [] ).append( t.user.username ) for t in c.project.team ] c.projectteams = pt c.att_editable = h.authorized( h.ProjectAdmin() ) c.tag_editable = c.att_editable c.isfavorite = projcomp.checkfavorite( c.project.id, c.authuser.id ) c.tags = self._prjtags( c.project ) c.title = c.projectname fpurl = unicode( self.url_wikiurl( c.projectname, PROJHOMEPAGE )) w = wikicomp.get_wiki( fpurl, attrload=[ 'tablemap' ] ) c.fpwcnt = wikicomp.get_content( w, translate=True ) if w else None c.fphtml = wikipage2html( c.fpwcnt, c.translate ) # Html page generation if c.errmsg : html = self.returnerrmsg(environ) elif c.jsonobj and c.view == 'js' : html = self.handlejson(environ) elif c.view != 'js' : html = render( '/derived/projects/project.html' ) c.rclose.append(html) return c.rclose
def attachs(self, environ, projectname): """Action to present attachment page for wiki pages under project `projectname` URLS : p/{projectname}/wiki/attachs """ from zeta.config.environment import wikicomp, vfcomp c.rclose = h.ZResp() c.projsummary = c.project.summary c.wikipagenames = self.wikipagename(wikicomp.wikiurls(c.project)) attachments = wikicomp.attachments(c.project) c.attachments = self.attachments(attachments) c.editable = h.authorized(h.HasPermname('WIKI_CREATE')) c.title = 'WikiAttachs' c.rclose.append(render('/derived/projects/wikiattachs.html')) return c.rclose
def wikiindex(self, environ, projectname): """Project wiki pages. URLS : /p/{projectname}/wiki /p/{projectname}/wiki?jsonobj=wikilist&view=js /p/{projectname}/wiki?form=submit&formname=vcsfile2wiki&view=js /p/{projectname}/wiki?form=submit&formname=configwiki&view=js """ from zeta.config.environment import projcomp, wikicomp, vfcomp c.rclose = h.ZResp() # Handle forms def errhandler(errmsg): c.errmsg = errmsg if self.formpermission(): c.errmsg = 'Do not have %s permission !!' % tckperm[c.formname] else: vfcomp.process( request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['vcsfile2wiki', 'configwiki'], ) # Setup context for page generation c.projsummary = c.project.summary if not c.jsonobj and c.formname != 'vcsfile2wiki': c.wikitypenames = wikicomp.typenames c.wikipagenames = self.wikipagename(wikicomp.wikiurls(c.project)) c.wikipagename = None c.wikieditable = h.authorized(h.HasPermname('WIKI_CREATE')) c.title = '%s:wiki' % projectname # HTML page generation html = '' if c.errmsg: html = self.returnerrmsg(environ) elif c.view == 'js' and c.jsonobj: html = self.handlejson(environ) elif c.view != 'js': html = render('/derived/projects/wikiindex.html') c.rclose.append(html) return c.rclose
def preference( self, environ, username, **kwargs ) : """Handle user preference URLS : /u/{username}/preference?form=request /u/{username}/preference?form=submit&formname=updateuser&view=js /u/{username}/preference?form=submit&formname=updtpass&view=js /u/{username}/preference?form=submit&formname=userphoto&view=js /u/{username}/preference?form=submit&formname=deluserphoto&view=js /u/{username}/preference?form=submit&formname=usericon&view=js /u/{username}/preference?form=submit&formname=delusericon&view=js /u/{username}/preference?form=submit&formname=adduserrels&view=js /u/{username}/preference?form=submit&formname=approveuserrels&view=js /u/{username}/preference?form=submit&formname=deluserrels&view=js """ from zeta.config.environment import vfcomp c.rclose = h.ZResp() # Form handling def errhandler(errmsg) : c.errmsg = errmsg if c.usercaninvite : vfcomp.process( request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=[ 'updateuser', 'updtpass', 'userphoto', 'deluserphoto', 'usericon', 'delusericon', 'adduserrels', 'approveuserrels', 'deluserrels' ], user=c.authuser ) # Setup context for page rendering uinfo = c.authuser.userinfo c.title = 'Preference' c.photo_editable = c.icon_editable = h.authorized( h.ValidUser( strict='True' )) c.photoattach = self._userphoto( c.authuser ) c.iconattach = self._usericon( c.authuser ) c.googlemaps = h.gmapkey( c.sysentries ) c.fulladdress = h.useraddress( uinfo ) # Html page generation if c.view == 'js' and c.formname in [ 'userphoto', 'usericon' ] : html = IFRAME_RET else : html = render( '/derived/userpage/preference.html' ) c.rclose.append(html) return c.rclose
def attachs(self, environ, projectname): """Action to present attachment page for tickets under project `projectname` URLS : /p/{projectname}/t/attachs """ from zeta.config.environment import vfcomp, tckcomp c.rclose = h.ZResp() # Setup context for page generation c.projsummary = c.project.summary attachments = tckcomp.attachments(c.project) c.attachments = self.attachments(attachments) c.editable = h.authorized(h.HasPermname('TICKET_CREATE')) c.title = 'TicketAttachs' c.rclose.append(render('/derived/projects/tckattachs.html')) return c.rclose
def attachs(self, environ, projectname): """Action to present attachment page for reviews under project `projectname` URLS : /p/{projectname}/r/attachs """ from zeta.config.environment import revcomp, vfcomp c.rclose = h.ZResp() # Setup context for html page c.projsummary = c.project.summary attachments = revcomp.attachments(c.project) c.attachments = self.attachments(attachments) c.editable = h.authorized(h.HasPermname('REVIEW_CREATE')) c.title = 'ReviewAttachs' c.rclose.append(render('/derived/projects/revwattachs.html')) return c.rclose
def vcsindex(self, environ, projectname): """Project source control URLS : /p/{projectname}/s /p/{projectname}/s?jsonobj=vcslist&view=js /p/{projectname}/s?form=submit&formname=configvcs&view=js """ from zeta.config.environment import vfcomp, projcomp, vcscomp c.rclose = h.ZResp() # Handle forms def errhandler(errmsg): c.errmsg = errmsg if self.formpermission(): c.errmsg = 'Do not have %s permission !!' % tckperm[c.formname] else: vfcomp.process( request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['configvcs'], ) # Setup context for page generation c.projsummary = c.project.summary c.vcs_typenames = vcscomp.vcstypenames c.vcseditable = h.authorized(h.HasPermname('VCS_CREATE')) c.title = '%s:source' % projectname # HTML page generation if c.errmsg: html = self.returnerrmsg(environ) elif c.view == 'js' and c.jsonobj: html = self.handlejson(environ) elif c.view != 'js': html = render('/derived/projects/vcsindex.html') else: html = '' c.rclose.append(html) return c.rclose
def titleindex(self, environ): """Static Wiki - titleindex URLS : /titleindex /TitleIndex """ from zeta.config.environment import syscomp c.rclose = h.ZResp() c.sweditable = h.authorized(h.HasPermname('STATICWIKI_CREATE')) c.swikis = [(sw.id, sw.path, self.url_editsw(sw.path), self.suburl_delsw(sw.path)) for sw in syscomp.get_staticwiki()] c.swikis = sorted(c.swikis, key=lambda sw: sw[1]) c.swa = ca.get_analyticobj('staticwiki') c.swsnippets = getattr(c.swa, 'pagesnippets', {}) c.title = 'TitleIndex' c.rclose.append(render('/derived/home/titleindex.html')) return c.rclose
def newwikipage( self, projectname, pagename, wtype, summary, sourceurl ) : """ === newwikipage( projectname, wtype, summary, sourceurl ) :Description :: Create a new wiki-page for project, `projectname`. Positional arguments, |= projectname | a valid project-name |= pagename | new wiki page-name under project, |= wtype | type of wiki page, if False, default type will be used |= summary | summary string, if False, will assume empty string |= sourceurl | source url, if False, will assume empty string :Return :: On success, [<PRE { 'rpcstatus' : 'ok' } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp wikiurl = unicode(self.url_wikiurl( projectname, self._stripurl( pagename) )) res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'WIKI_CREATE' )) ) if res : return res else : wtype, summary, sourceurl = \ self._demarshalNone( wtype, summary, sourceurl ) rc, wiki, failmsg = xicomp.create_wiki( unicode(projectname), wikiurl, wtype=unicode(wtype), summary=unicode(summary), sourceurl=unicode(sourceurl), byuser=c.authuser ) return _result( rc, failmsg=failmsg )
def attachs( self, environ, projectname ) : """Action to present attachment page for `projectname` URLS : /p/<projectname>/attachs """ from zeta.config.environment import projcomp, vfcomp c.rclose = h.ZResp() # Setup context for page rendering c.editable = c.att_editable = h.authorized( h.ProjectAdmin() ) c.title = 'ProjectAttachs' c.projsummary = c.project.summary attachments = projcomp.attachments( c.project ) c.attachments = self.attachments( attachments ) c.attachs = self._prjattachs( c.project ) c.isfavorite = projcomp.checkfavorite( c.project.id, c.authuser.id ) # Html page generation c.rclose.append(render( '/derived/projects/projattachs.html' )) return c.rclose
def newstaticwiki( self, path, content, swtype, sourceurl ) : """ === newstaticwiki( path, content ) :Description :: Create a new static wiki page, under path-url `path`, published with `content` Positional arguments, |= path | url-path, for the new static wiki page |= content | wiki text to publish. |= wtype | type of wiki page, if False, will be skipped |= sourceurl | source url, if False, will be skipped :Return :: On success, [<PRE { 'rpcstatus' : 'ok' } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'STATICWIKI_CREATE' )) ) if res : return res else : path = self._stripurl( path ) swtype, sourceurl = self._demarshalNone( swtype, sourceurl ) rc, sw, failmsg = xicomp.create_sw( path, unicode(content), swtype=swtype, sourceurl=sourceurl ) return _result( rc, failmsg=failmsg )
def licenses(self, environ): """Action for all license pages. URLS : /license /license?form=submit&formname=rmlic&view=js """ from zeta.config.environment import liccomp, vfcomp c.rclose = h.ZResp() # Form handling def errhandler(errmsg): c.errmsg = errmsg c.liceditable = h.authorized(h.HasPermname(['LICENSE_CREATE'])) c.att_editable = c.liceditable c.tag_editable = c.liceditable if c.form == 'submit' and c.liceditable: vfcomp.process(request, c, defer=True, errhandler=h.hitchfn(errhandler), formnames=['rmlic'], user=c.authuser) else: c.errmsg = 'Need `LICENSE_CREATE` to access the page' # Setup context for page generation c.licprojects = c.licensetable = [] c.licensenames, c.licenselist, licfields = self._selectoptions() c.licensetable = self._lictable(licfields) c.attachs = {} c.tags = {} c.title = 'LicenseTable' # Html page generation c.rclose.append(render('/derived/license/license.html')) return c.rclose
def metanav(environ): metanavs = [ Anchor(href=h.url_projindex, text='projects', title='All hosted projects') ] if h.authorized(h.ValidUser(strict='True')): metanavs.extend([ Anchor(href=None, type='pointer', text='quick-links', title='Quick shortcut to useful links'), Anchor(href=None, type='pointer', text='myprojects', title='Goto projects'), Anchor(href=h.url_userpref, text='preference', title='Your account preference'), Anchor(href=h.url_signout, text='signout', title='Sign out'), ]) else: metanavs.extend([ Anchor(href=h.url_signin, text='signin', title='Sign in if already registered'), Anchor(href=h.url_register, text='register', title='New User ? Sign up'), ]) metanavs.extend([ Anchor(href=h.url_aboutus, text='aboutus', title='About Us'), Anchor(href=h.url_helppages, text='help', title='Learn how to use ' + config['zeta.sitename']), ]) return metanavs
def wiki( self, projectname, pagename ) : """ === wiki( projectname, pagename ) :Description :: Read wiki-page `pagename`, for project, `projectname`, Positional arguments, |= projectname | a valid project-name |= pagename | valid and existing wiki page-name :Return :: On success, { 'rpcstatus' : 'ok', 'type' : <wiki type string> 'summary' : <wiki summary string> 'sourceurl' : <source url to be interpreted based on wiki type> 'text' : <wiki text string> } On failure, { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } """ from zeta.config.environment import xicomp wikiurl = unicode(self.url_wikiurl( projectname, self._stripurl( pagename) )) if res : return res else : res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'WIKI_VIEW' )) ) rc, d, failmsg = xicomp.read_wiki( unicode(projectname), wikiurl ) # Marshal None into 'None' for k in d : d[k] = self._marshalNone( d[k] ) return _result( rc, d=d, failmsg=failmsg )
def tagwiki( self, projectname, pagename, addtags, deltags ) : """ === tagwiki( projectname, pagename, addtags, deltags ) :Description :: Add or delete tags from wiki-page `pagename`, under project `projectname`. Positional arguments, |= projectname | a valid project-name |= pagename | valid and existing wiki page-name |= addtags | list of tagnames to add, if False, will be skipped |= deltags | list of tagnames to delete, if False, will be skipped :Return :: On success, [<PRE { 'rpcstatus' : 'ok' } >] On failure, [<PRE { 'rpcstatus' : 'fail', 'message' : <msg string indicating reason for failure> } >] """ from zeta.config.environment import xicomp wikiurl = unicode(self.url_wikiurl( projectname, self._stripurl( pagename) )) res = self._permissions( c.authuser, h.authorized( h.HasPermname( 'WIKI_CREATE' )) ) if res : return res else : addtags, deltags = self._demarshalNone( addtags, deltags ) addtags = addtags and [ unicode(t) for t in addtags ] deltags = deltags and [ unicode(t) for t in deltags ] rc, wiki, failmsg = xicomp.wiki_tags( unicode(projectname), wikiurl, addtags, deltags ) return _result( rc, failmsg=failmsg )