Example #1
0
def perform_tips_operation(store, receiver_id, operation, rtips_ids):
    receiver = store.find(Receiver, Receiver.id == receiver_id).one()

    rtips = store.find(
        ReceiverTip,
        And(ReceiverTip.receiver_id == receiver_id,
            In(ReceiverTip.id, rtips_ids)))

    if operation == 'postpone':
        can_postpone_expiration = GLSettings.memory_copy.can_postpone_expiration or receiver.can_postpone_expiration
        if not can_postpone_expiration:
            raise errors.ForbiddenOperation

        for rtip in rtips:
            db_postpone_expiration_date(rtip)

    elif operation == 'delete':
        can_delete_submission = GLSettings.memory_copy.can_delete_submission or receiver.can_delete_submission
        if not can_delete_submission:
            raise errors.ForbiddenOperation

        for rtip in rtips:
            db_delete_rtip(store, rtip)

    log.debug("Multiple %s of %d Tips completed" % (operation, len(rtips_ids)))
Example #2
0
def perform_tips_operation(store, receiver_id, operation, rtips_ids):
    receiver = store.find(Receiver, Receiver.id == receiver_id).one()

    rtips = store.find(ReceiverTip, And(ReceiverTip.receiver_id == receiver_id, In(ReceiverTip.id, rtips_ids)))

    if operation == "postpone":
        can_postpone_expiration = GLSettings.memory_copy.can_postpone_expiration or receiver.can_postpone_expiration
        if not can_postpone_expiration:
            raise errors.ForbiddenOperation

        for rtip in rtips:
            db_postpone_expiration_date(rtip)

    elif operation == "delete":
        can_delete_submission = GLSettings.memory_copy.can_delete_submission or receiver.can_delete_submission
        if not can_delete_submission:
            raise errors.ForbiddenOperation

        for rtip in rtips:
            db_delete_rtip(store, rtip)

    log.debug("Multiple %s of %d Tips completed" % (operation, len(rtips_ids)))