Esempio n. 1
0
def create_milestone(auth_token):
    try:
        post_data = request.get_json(force=True)
    except BadRequest as e:
        raise ApiError(e.description)
    if 'due_date' in post_data:
        post_data['due_date'] = from_unix_timestamp(post_data['due_date'])

    new_milestone = Milestone()
    new_milestone.update(post_data)

    db_session.add(new_milestone)
    db_session.commit()

    return jsonify(new_milestone.to_dict(max_depth=2))
Esempio n. 2
0
def update_milestone(auth_token, slug):
    try:
        milestone = db_session.query(Milestone).filter(Milestone.slug == slug).one()
    except NoResultFound:
        abort(404)

    try:
        post_data = request.get_json(force=True)
    except BadRequest as e:
        raise ApiError(e.description)
    if 'due_date' in post_data:
        post_data['due_date'] = from_unix_timestamp(post_data['due_date'])

    milestone.update(post_data)

    db_session.commit()

    return jsonify(milestone.to_dict(max_depth=2))