示例#1
0
def add_news():
    author = request.json.get('author')
    post_id = request.json.get('post_id')
    body = request.json.get('body')
    timestamp = datetime.fromtimestamp(request.json.get('timestamp') / 1000)

    new = News(author=author, post_id=post_id, timestamp=timestamp, body=body)
    db.session.add(new)
    db.session.commit()
    return jsonify(author=author,
                   post_id=post_id,
                   body=body,
                   timestamp=timestamp)
def list_mostre(request):
    category = db.Query(Categoria).filter("name =", 'mostre').get()
    if category:
      return object_list(request, News.all().order('-created').filter('published =', True).filter('category  =', category.key()), paginate_by=5)
    else:
      return render_to_response(request, 'no_items.html')
def home(request):
    return object_list(request, News.all(), paginate_by=5)