Example #1
0
def create_issue(auth_token):
    try:
        post_data = request.get_json(force=True)
    except BadRequest as e:
        raise ApiError(e.description)
    post_data['author'] = auth_token.owner.email

    new_issue = Issue()
    new_issue.update(post_data)

    db_session.add(new_issue)
    db_session.commit()

    return jsonify(new_issue.to_dict(max_depth=2))
Example #2
0
def create_issue(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)
    post_data['author'] = auth_token.owner.email

    new_issue = Issue()
    new_issue.update(post_data)

    milestone.issues.append(new_issue)
    db_session.commit()

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