Пример #1
0
    def fetch_destinations(self, request_user: UserModel, tenant: TenantModel):
        self.logger.info("START: fetch_destinations")
        if not request_user.can_control_notification():
            raise PermissionDenied

        if not request_user.is_belong_to_tenant(tenant):
            raise PermissionDenied(
                "request user doesn't belong to tenant. user_id:{}, tenant_id: {}"
                .format(request_user.id, tenant.id))

        destinations = NotificationDestinationModel.all().filter(tenant=tenant)
        self.logger.info("END: fetch_destinations")
        return destinations
Пример #2
0
    def delete_group(self, request_user: UserModel,
                     group: NotificationGroupModel):
        self.logger.info("START: delete_group")
        if not request_user.can_control_notification():
            raise PermissionDenied

        if not request_user.is_belong_to_tenant(group.tenant):
            raise PermissionDenied(
                "request user doesn't belong to tenant. user_id:{}, tenant_id: {}"
                .format(request_user.id, group.tenant.id))

        # 作成
        group.delete()

        self.logger.info("END: delete_group")
Пример #3
0
    def delete_destination(self, request_user: UserModel,
                           destination: NotificationDestinationModel):
        self.logger.info("START: delete_destination")
        if not request_user.can_control_notification():
            raise PermissionDenied

        if not request_user.is_belong_to_tenant(destination.tenant):
            raise PermissionDenied(
                "request user doesn't belong to tenant. user_id:{}, tenant_id: {}"
                .format(request_user.id, destination.tenant.id))

        # 削除
        destination.delete()

        self.logger.info("END: delete_destination")