Exemplo n.º 1
0
def comment_create(request):
    c = Comment(
        request.form["title"],
        request.form["author_fullname"],
        request.form["author_email"],
        request.form["author_website"],
        datetime.datetime.now().isoformat(),
        request.form["content"],
    )
    session.add(c)
    session.commit()
    return render_json(c.to_api_dict())
Exemplo n.º 2
0
def create_user(request):
    try:
        u = session.query(User).filter(User.username == request.form["username"]).one()
        logging.debug("Not creating user %s, username already in use." % request.form["username"])
        return DuplicateError
    except NoResultFound:
        pass
    u = User(
        request.form["username"],
        request.form["fullname"],
        hash_password(request.form["password"]),
        request.form["editor"] == "true",
        request.form["superuser"] == "true",
    )
    # handle query errors and return a valid response
    session.add(u)
    session.commit()
    u = session.query(User).filter(User.username == request.form["username"]).one()
    return render_json(u.to_api_dict())
Exemplo n.º 3
0
def create_entry(request):
    e = Entry(request.form["title"], request.form["content"], request.user.id)
    session.add(e)
    session.commit()
    return render_json(e.to_api_dict())
Exemplo n.º 4
0
def delete_entry(request, entry_id):
    session.query(Entry).filter(Entry.id == entry_id).delete()
    session.commit()
Exemplo n.º 5
0
def delete_user(request, user_id):
    session.query(User).filter(User.id == user_id).delete()
    session.commit()
    return render_json({"id": user_id})