def messages_new(page=1): try: page = int(page) except (TypeError, ValueError): page = 1 if not page: page = 1 offset = (page - 1) * settings.page_limit plist = posts.private_unread(offset=offset, limit=settings.page_limit + 1) if not plist and page == 1: return Response(redirect='%s://%s/messages/incoming' % \ (env.request.protocol, settings.domain)) if env.request.is_xhr: for p in plist: p['created'] = timestamp(p['created']) return Response(json.dumps(plist), mimetype='application/json') return render('/messages/index.html', section='messages', posts=plist, page=page)
def private_posts(show=False, offset=None, limit=None): if offset: offset = int(offset) if limit: limit = int(limit) else: offset = 0 limit = 10 plist = posts.private_unread(offset=offset, limit=limit) if not plist: plist = posts.private_incoming(offset=offset, limit=limit) plist.reverse() return xmpp_template('posts', posts=plist)
def messages_new(page=1): try: page = int(page) except (TypeError, ValueError): page = 1 if not page: page = 1 offset = (page - 1) * settings.page_limit plist = posts.private_unread(offset=offset, limit=settings.page_limit+1) if not plist and page == 1: return Response(redirect='%s://%s/messages/incoming' % \ (env.request.protocol, settings.domain)) if env.request.is_xhr: for p in plist: p['created'] = timestamp(p['created']) return Response(json.dumps(plist), mimetype='application/json') return render('/messages/index.html', section='messages', posts=plist, page=page)