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)))
def perform_tips_operation(store, receiver_id, operation, rtips_ids): receiver = store.find(models.Receiver, models.Receiver.id == receiver_id).one() for itip in store.find( models.InternalTip, models.ReceiverTip.receiver_id == receiver_id, In(models.ReceiverTip.id, rtips_ids), models.InternalTip.id == models.ReceiverTip.internaltip_id): if operation == 'postpone': can_postpone_expiration = State.tenant_cache[ 1].can_postpone_expiration or receiver.can_postpone_expiration if not can_postpone_expiration: raise errors.ForbiddenOperation db_postpone_expiration_date(store, itip) elif operation == 'delete': can_delete_submission = State.tenant_cache[ 1].can_delete_submission or receiver.can_delete_submission if not can_delete_submission: raise errors.ForbiddenOperation db_delete_itip(store, itip) log.debug("Multiple %s of %d Tips completed" % (operation, len(rtips_ids)))
def perform_tips_operation(session, tid, receiver_id, operation, rtips_ids): receiver = session.query(models.Receiver).filter(models.Receiver.id == receiver_id).one() can_postpone_expiration = State.tenant_cache[tid].can_postpone_expiration or receiver.can_postpone_expiration can_delete_submission = State.tenant_cache[tid].can_delete_submission or receiver.can_delete_submission for itip in session.query(models.InternalTip) \ .filter(models.ReceiverTip.receiver_id == receiver_id, models.ReceiverTip.id.in_(rtips_ids), models.InternalTip.id == models.ReceiverTip.internaltip_id, models.InternalTip.tid == tid): if operation == 'postpone' and can_postpone_expiration: db_postpone_expiration_date(session, tid, itip) elif operation == 'delete' and can_delete_submission: db_delete_itip(session, itip) else: raise errors.ForbiddenOperation
def perform_tips_operation(session, tid, receiver_id, operation, rtips_ids): receiver = models.db_get(session, models.User, models.User.id == receiver_id) can_postpone_expiration = State.tenant_cache[tid].can_postpone_expiration or receiver.can_postpone_expiration can_delete_submission = State.tenant_cache[tid].can_delete_submission or receiver.can_delete_submission for itip in session.query(models.InternalTip) \ .filter(models.ReceiverTip.receiver_id == receiver_id, models.ReceiverTip.id.in_(rtips_ids), models.InternalTip.id == models.ReceiverTip.internaltip_id, models.InternalTip.tid == tid): if operation == 'postpone' and can_postpone_expiration: db_postpone_expiration_date(session, tid, itip) elif operation == 'delete' and can_delete_submission: db_delete_itip(session, itip) else: raise errors.ForbiddenOperation
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)))