Example #1
0
def update_comment(auth_token, uid):
    try:
        comment = db_session.query(Comment).filter(Comment.uid == uid).one()
    except NoResultFound:
        abort(404)

    try:
        post_data = request.get_json(force=True)
    except BadRequest as e:
        raise ApiError(e.description)

    post_data['updated_at'] = utcnow()

    comment.update(post_data)

    db_session.commit()

    return jsonify(comment.to_dict(max_depth=2))
Example #2
0
def update_issue(auth_token, uid):
    try:
        issue = db_session.query(Issue).filter(Issue.uid == uid).one()
    except NoResultFound:
        abort(404)

    try:
        post_data = request.get_json(force=True)
    except BadRequest as e:
        raise ApiError(e.description)

    # Update the closing time if the status of the issue gets updated.
    if ('status' in post_data) and post_data['status'] != issue.status:
        if post_data['status'] == 'closed':
            post_data['closed_at'] = utcnow()
        else:
            post_data['closed_at'] = None

    issue.update(post_data)

    db_session.commit()

    return jsonify(issue.to_dict(max_depth=2))
Example #3
0
 def has_expired(self):
     return utcnow() > self.expires_at