コード例 #1
0
ファイル: ns_api.py プロジェクト: mdeng1024/inbox
def draft_delete_api(public_id):
    data = request.get_json(force=True)
    if data.get('version') is None:
        return err(400, 'Must specify version to delete')
    version = data.get('version')

    try:
        valid_public_id(public_id)
        draft = g.db_session.query(Message).filter(
            Message.public_id == public_id).one()
    except InputError:
        return err(400, 'Invalid public id {}'.format(public_id))
    except NoResultFound:
        return err(404, 'No draft found with public_id {}'.
                   format(public_id))

    if draft.namespace != g.namespace:
        return err(404, 'No draft found with public_id {}'.
                   format(public_id))

    if not draft.is_draft:
        return err(400, 'Message with public id {} is not a draft'.
                   format(public_id))

    if draft.version != version:
        return err(409, 'Draft {0}.{1} has already been updated to version '
                   '{2}'.format(public_id, version, draft.version))

    result = sendmail.delete_draft(g.db_session, g.namespace.account,
                                   public_id)
    return g.encoder.jsonify(result)
コード例 #2
0
def draft_delete_api(public_id):
    data = request.get_json(force=True)
    if data.get('version') is None:
        return err(400, 'Must specify version to delete')
    version = data.get('version')

    try:
        valid_public_id(public_id)
        draft = g.db_session.query(Message).filter(
            Message.public_id == public_id).one()
    except InputError:
        return err(400, 'Invalid public id {}'.format(public_id))
    except NoResultFound:
        return err(404, 'No draft found with public_id {}'.format(public_id))

    if draft.namespace != g.namespace:
        return err(404, 'No draft found with public_id {}'.format(public_id))

    if not draft.is_draft:
        return err(
            400, 'Message with public id {} is not a draft'.format(public_id))

    if draft.version != version:
        return err(
            409, 'Draft {0}.{1} has already been updated to version '
            '{2}'.format(public_id, version, draft.version))

    try:
        result = sendmail.delete_draft(g.db_session, g.namespace.account,
                                       public_id)
    except ActionError as e:
        return err(e.error, str(e))

    return g.encoder.jsonify(result)
コード例 #3
0
ファイル: ns_api.py プロジェクト: apolmig/inbox
def draft_delete_api(public_id):
    data = request.get_json(force=True)
    # Validate draft id, version, etc.
    draft = get_draft(public_id, data.get('version'), g.namespace.id,
                      g.db_session)

    try:
        result = sendmail.delete_draft(g.db_session, g.namespace.account,
                                       draft)
    except ActionError as e:
        return err(e.error, str(e))

    return g.encoder.jsonify(result)
コード例 #4
0
ファイル: ns_api.py プロジェクト: olofster/inbox
def draft_delete_api(public_id):
    data = request.get_json(force=True)
    # Validate draft id, version, etc.
    draft = get_draft(public_id, data.get('version'), g.namespace.id,
                      g.db_session)

    try:
        result = sendmail.delete_draft(g.db_session, g.namespace.account,
                                       draft)
    except ActionError as e:
        return err(e.error, str(e))

    return g.encoder.jsonify(result)
コード例 #5
0
ファイル: ns_api.py プロジェクト: 0xcd03/inbox
def draft_delete_api(public_id):
    try:
        draft = g.db_session.query(Message).filter(
            Message.public_id == public_id).one()
    except NoResultFound:
        return err(404, 'No draft found with public_id {}'.
                   format(public_id))

    if draft.namespace != g.namespace:
        return err(404, 'No draft found with public_id {}'.
                   format(public_id))

    if not draft.is_draft:
        return err(400, 'Message with public id {} is not a draft'.
                   format(public_id))

    result = sendmail.delete_draft(g.db_session, g.namespace.account,
                                   public_id)
    return g.encoder.jsonify(result)
コード例 #6
0
def draft_delete_api(public_id):
    try:
        draft = g.db_session.query(Message).filter(
            Message.public_id == public_id).one()
    except NoResultFound:
        return err(404, 'No draft found with public_id {}'.
                   format(public_id))

    if draft.namespace != g.namespace:
        return err(404, 'No draft found with public_id {}'.
                   format(public_id))

    if not draft.is_draft:
        return err(400, 'Message with public id {} is not a draft'.
                   format(public_id))

    result = sendmail.delete_draft(g.db_session, g.namespace.account,
                                   public_id)
    return g.encoder.jsonify(result)