示例#1
0
 def index(self):
     if c.user and c.user.issysadmin:
         c.items = meta.DBSession.query(Site).all()
     if c.user:
         qry = model.help.Help.by_site(c.user.site_id)
         c.new_ticket_ct = qry.count()
         c.helptickets = qry.limit(5)
         c.comments = Comment.by_site(c.user.site_id).limit(5)
         
     return render('/dashboard.html')
示例#2
0
文件: api.py 项目: cccarey/demisauce
 def comment(self,format='json',id=''):
     site = request.environ['site']
     #site2 = Site.by_slug(str(id))
     #if site2.id != site.id and 'apikey' in request.params and request.params['apikey'] == site2.key:
     #    site = site2 # logged in user not same as 
     c.len = 0
     
     if id != '' and id != None:
         rid = urllib.unquote_plus(id)
         log.info('comment rid= %s' % id)
         c.comments = Comment.for_url(site_id=site.id,url=rid)
     else:
         c.comments = Comment.all(site.id)
     
     c.items = c.comments
     c.resource_id = urllib.quote_plus(id)
     
     if format == 'html':
         return render('/api/comment.html')
     elif format == 'xml':
         response.headers['Content-Type'] = 'application/xhtml+xml'
         if c.comments == []:
             #log.info('404, no comments siteid=%s, uri=%s' %(site.id,rid))
             #abort(404, 'No items found')
             c.len = 0 # no comments is ok, right?
         else:
             c.len = len(c.comments)
         return render('/api/comment.xml')
     elif format == 'view':
         c.show_form = True
         c.source = 'remote_html'
         c.len = len(c.comments)
         c.hasheader = True
         c.site_slug = site.slug
         #raise 'eh'
         return render('/comment/comment_nobody.html')
     elif format == 'json':
         return render('/api/comment.js')
     else:
         raise NotImplementedError('format of type %s not supported' % format)