예제 #1
0
def delete_account(record_id):
    """
    Deletes a single account record, removes all traces of account from other
    tables
    """
    try:
        # Delete this account's subscriptions
        Interactions.delete_specific(DEFAULT_SUBSCRIPTIONS_TABLE,
                                     filters={'account_id': record_id})

        # Loop and delete any records subscribed to their registrations
        registrations = Interactions.query(DEFAULT_REGISTRATIONS_TABLE,
                                           filters={'account_id': record_id})

        for registration in registrations:
            delete_registration(registration['id'])

        return make_response(
            jsonify(Interactions.delete(DEFAULT_ACCOUNTS_TABLE, record_id)),
            client.OK)
    except RqlRuntimeError as runtime_err:
        return make_response(jsonify({'Error': runtime_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except RqlDriverError as rql_err:
        return make_response(jsonify({'Error': rql_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except TypeError:
        return make_response(jsonify({'Error': 'Invalid id parameter'}),
                             client.BAD_REQUEST)
예제 #2
0
def delete_account(record_id):
    """
    Deletes a single account record, removes all traces of account from other
    tables
    """
    try:
        # Delete this account's subscriptions
        Interactions.delete_specific(
            DEFAULT_SUBSCRIPTIONS_TABLE, filters={'account_id': record_id})

        # Loop and delete any records subscribed to their registrations
        registrations = Interactions.query(DEFAULT_REGISTRATIONS_TABLE,
                                           filters={'account_id': record_id})

        for registration in registrations:
            delete_registration(registration['id'])

        return make_response(
            jsonify(Interactions.delete(DEFAULT_ACCOUNTS_TABLE, record_id)),
            client.OK)
    except RqlRuntimeError as runtime_err:
        return make_response(jsonify({'Error': runtime_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except RqlDriverError as rql_err:
        return make_response(jsonify({'Error': rql_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except TypeError:
        return make_response(
            jsonify({'Error': 'Invalid id parameter'}), client.BAD_REQUEST)
예제 #3
0
def delete_registration(registration_id):
    """
    Deletes a single registration record, removes all traces of this
    registration from the subscription table
    """
    try:
        Interactions.delete_specific(
            DEFAULT_SUBSCRIPTIONS_TABLE,
            filters={'registration_id': registration_id})

        return make_response(
            jsonify(Interactions.delete_specific(
                DEFAULT_REGISTRATIONS_TABLE,
                filters={'id': registration_id})), client.OK)
    except RqlRuntimeError as runtime_err:
        return make_response(jsonify({'Error': runtime_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except RqlDriverError as rql_err:
        return make_response(jsonify({'Error': rql_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except TypeError:
        return make_response(
            jsonify({'Error': 'Invalid id parameter'}), client.BAD_REQUEST)
예제 #4
0
def delete_registration(registration_id):
    """
    Deletes a single registration record, removes all traces of this
    registration from the subscription table
    """
    try:
        Interactions.delete_specific(
            DEFAULT_SUBSCRIPTIONS_TABLE,
            filters={'registration_id': registration_id})

        return make_response(
            jsonify(
                Interactions.delete_specific(DEFAULT_REGISTRATIONS_TABLE,
                                             filters={'id': registration_id})),
            client.OK)
    except RqlRuntimeError as runtime_err:
        return make_response(jsonify({'Error': runtime_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except RqlDriverError as rql_err:
        return make_response(jsonify({'Error': rql_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except TypeError:
        return make_response(jsonify({'Error': 'Invalid id parameter'}),
                             client.BAD_REQUEST)
예제 #5
0
def delete_accounts_except_admins():
    """
    Deletes all account records except those marked as admins, removes all
    traces of account from other tables
    """
    try:
        return make_response(
            jsonify(Interactions.delete_specific(
                DEFAULT_ACCOUNTS_TABLE,
                filters={'is_admin': False})), client.OK)
    except RqlRuntimeError as runtime_err:
        return make_response(jsonify({'Error': runtime_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except RqlDriverError as rql_err:
        return make_response(jsonify({'Error': rql_err.message}),
                             client.INTERNAL_SERVER_ERROR)
예제 #6
0
def delete_accounts_except_admins():
    """
    Deletes all account records except those marked as admins, removes all
    traces of account from other tables
    """
    try:
        return make_response(
            jsonify(
                Interactions.delete_specific(DEFAULT_ACCOUNTS_TABLE,
                                             filters={'is_admin': False})),
            client.OK)
    except RqlRuntimeError as runtime_err:
        return make_response(jsonify({'Error': runtime_err.message}),
                             client.INTERNAL_SERVER_ERROR)
    except RqlDriverError as rql_err:
        return make_response(jsonify({'Error': rql_err.message}),
                             client.INTERNAL_SERVER_ERROR)