def user_can_approve_order(user, project): if user.is_staff: return True if django_settings.WALDUR_MARKETPLACE['OWNER_CAN_APPROVE_ORDER'] and \ structure_permissions._has_owner_access(user, project.customer): return True if django_settings.WALDUR_MARKETPLACE['MANAGER_CAN_APPROVE_ORDER'] and \ structure_permissions._has_manager_access(user, project): return True if django_settings.WALDUR_MARKETPLACE['ADMIN_CAN_APPROVE_ORDER'] and \ structure_permissions._has_admin_access(user, project): return True return False
def check_permissions_for_state_change(request, view, order=None): if not order: return user = request.user if user.is_staff: return if settings.WALDUR_MARKETPLACE['OWNER_CAN_APPROVE_ORDER'] and \ structure_permissions._has_owner_access(user, order.project.customer): return if settings.WALDUR_MARKETPLACE['MANAGER_CAN_APPROVE_ORDER'] and \ structure_permissions._has_manager_access(user, order.project): return if settings.WALDUR_MARKETPLACE['ADMIN_CAN_APPROVE_ORDER'] and \ structure_permissions._has_admin_access(user, order.project): return raise rf_exceptions.PermissionDenied()