'Approve/Reject the status of a pending entry'

@api.response(201, model=pending_entry_schema)
@api.response(BadRequest)
@api.validate(operation_schema, description=description)
def put(self, entry_id, session=None):

    try:
        entry = get_entry_by_id(session, entry_id)
    except NoResultFound:
        raise NotFoundError((u'No    pending    entry    with    ID    %s' % entry_id))
    data = request.json
    approved = (data[u'operation'] == u'approve')
    operation_text = (u'approved' if approved else u'pending')
    if (entry.approved is approved):
        raise BadRequest(u'Entry    with    id    {}    is    already    {}'.format(entry_id, operation_text))
    entry.approved = approved
    session.commit()
    rsp = jsonify(entry.to_dict())
    rsp.status_code = 201
    return rsp
