コード例 #1
0
    def perform_create(self, serializer):
        customer = serializer.validated_data['customer']

        if not self.can_create_project_with(customer):
            raise PermissionDenied()

        utils.check_customer_blocked(customer)

        super(ProjectViewSet, self).perform_create(serializer)
コード例 #2
0
    def perform_destroy(self, instance):
        self.check_customer_permissions(instance)
        utils.check_customer_blocked(instance)

        core_signals.pre_delete_validate.send(sender=models.Customer,
                                              instance=instance,
                                              user=self.request.user)

        return super(CustomerViewSet, self).perform_destroy(instance)
コード例 #3
0
    def perform_create(self, serializer):
        scope = serializer.validated_data[self.scope_field]
        role = serializer.validated_data.get('role')
        expiration_time = serializer.validated_data.get('expiration_time')

        if not scope.can_manage_role(self.request.user, role, expiration_time):
            raise PermissionDenied()

        utils.check_customer_blocked(scope)

        super(BasePermissionViewSet, self).perform_create(serializer)
コード例 #4
0
    def perform_destroy(self, instance):
        permission = instance
        scope = getattr(permission, self.scope_field)
        role = getattr(permission, 'role', None)
        affected_user = permission.user
        expiration_time = permission.expiration_time

        if not scope.can_manage_role(self.request.user, role, expiration_time):
            raise PermissionDenied()

        utils.check_customer_blocked(scope)

        scope.remove_user(affected_user, role, removed_by=self.request.user)
コード例 #5
0
    def perform_update(self, serializer):
        permission = serializer.instance
        scope = getattr(permission, self.scope_field)
        role = getattr(permission, 'role', None)

        utils.check_customer_blocked(scope)

        new_expiration_time = serializer.validated_data.get('expiration_time')
        old_expiration_time = permission.expiration_time
        if new_expiration_time == old_expiration_time:
            return

        if not scope.can_manage_role(self.request.user, role,
                                     new_expiration_time):
            raise PermissionDenied()

        serializer.save()
        structure_role_updated.send(
            sender=self.queryset.model,
            instance=permission,
            user=self.request.user,
        )
コード例 #6
0
ファイル: views.py プロジェクト: livenson/waldur-mastermind
    def perform_create(self, serializer):
        project = serializer.validated_data['project']
        structure_utils.check_customer_blocked(project)

        super(OrderViewSet, self).perform_create(serializer)
コード例 #7
0
ファイル: views.py プロジェクト: livenson/waldur-mastermind
    def perform_create(self, serializer):
        customer = serializer.validated_data['customer']
        structure_utils.check_customer_blocked(customer)

        super(OfferingViewSet, self).perform_create(serializer)
コード例 #8
0
 def perform_update(self, serializer):
     self.check_customer_permissions(serializer.instance)
     utils.check_customer_blocked(serializer.instance)
     return super(CustomerViewSet, self).perform_update(serializer)