|
15 | 15 | from django.db.models import QuerySet, Count, Q, UUIDField, Sum, F, BigIntegerField, Value, ExpressionWrapper, \ |
16 | 16 | IntegerField, Window |
17 | 17 | from django.db.models.functions import Cast, Coalesce, RowNumber |
| 18 | +from django.forms import CharField |
18 | 19 | from django.http import HttpResponse |
19 | 20 | from django.utils import timezone |
20 | 21 | from django.utils.translation import gettext_lazy as _, gettext |
@@ -57,7 +58,10 @@ def has_all_permission(auth, permission, workspace_id): |
57 | 58 | or has_extends_workspace_manage_permission(auth, |
58 | 59 | permission, |
59 | 60 | workspace_id) |
60 | | - or hasPermission(auth, permission)) |
| 61 | + or hasPermission(auth, |
| 62 | + permission) |
| 63 | + or RoleConstants.USER.name + f':/WORKSPACE/{workspace_id}' in auth.role_list |
| 64 | + or RoleConstants.WORKSPACE_MANAGE.name + f':/WORKSPACE/{workspace_id}' in auth.role_list) |
61 | 65 |
|
62 | 66 |
|
63 | 67 | def is_workspace_manage(auth, workspace_id): |
@@ -125,7 +129,7 @@ def aggregation(self, auth, with_valid=True): |
125 | 129 | user_id=user_id, |
126 | 130 | auth_target_type="APPLICATION", |
127 | 131 | permission_list__overlap=permission_list |
128 | | - ) |
| 132 | + ).exclude(target='default') |
129 | 133 | .annotate( |
130 | 134 | target_uuid=Cast( |
131 | 135 | "target", |
@@ -184,7 +188,7 @@ def aggregation(self, auth, with_valid=True): |
184 | 188 | user_id=user_id, |
185 | 189 | auth_target_type="APPLICATION", |
186 | 190 | permission_list__overlap=permission_list |
187 | | - ) |
| 191 | + ).exclude(target='default') |
188 | 192 | .annotate( |
189 | 193 | target_uuid=Cast( |
190 | 194 | "target", |
@@ -348,7 +352,7 @@ def _apply_permission_filter(self, queryset, auth, workspace_id, user_id): |
348 | 352 | user_id=user_id, |
349 | 353 | auth_target_type="APPLICATION", |
350 | 354 | permission_list__overlap=permission_list, |
351 | | - ) |
| 355 | + ).exclude(target='default') |
352 | 356 | .annotate(target_uuid=Cast("target", output_field=UUIDField())) |
353 | 357 | .values_list("target_uuid", flat=True) |
354 | 358 | ) |
@@ -421,7 +425,7 @@ def get_queryset(self, auth): |
421 | 425 | user_id=user_id, |
422 | 426 | auth_target_type="APPLICATION", |
423 | 427 | permission_list__overlap=permission_list, |
424 | | - ) |
| 428 | + ).exclude(target='default') |
425 | 429 | .annotate( |
426 | 430 | target_uuid=Cast("target", output_field=UUIDField()) |
427 | 431 | ) |
@@ -563,7 +567,7 @@ def get_queryset(self, auth): |
563 | 567 | user_id=user_id, |
564 | 568 | auth_target_type="APPLICATION", |
565 | 569 | permission_list__overlap=permission_list |
566 | | - ) |
| 570 | + ).exclude(target='default') |
567 | 571 | .annotate(target_uuid=Cast("target", output_field=UUIDField())) |
568 | 572 | .values_list("target_uuid", flat=True) |
569 | 573 | ) |
@@ -751,7 +755,7 @@ def get_aggregation_query_set(self, auth): |
751 | 755 | user_id=user_id, |
752 | 756 | auth_target_type="APPLICATION", |
753 | 757 | permission_list__overlap=permission_list |
754 | | - ).annotate(target_uuid=Cast("target", output_field=UUIDField())) |
| 758 | + ).exclude(target='default').annotate(target_uuid=Cast("target", output_field=UUIDField())) |
755 | 759 | .values_list("target_uuid", flat=True)) |
756 | 760 |
|
757 | 761 | def aggregation(self, auth, with_valid=True): |
@@ -790,7 +794,7 @@ def get_aggregation_query_set(self, auth): |
790 | 794 | user_id=user_id, |
791 | 795 | auth_target_type="KNOWLEDGE", |
792 | 796 | permission_list__overlap=permission_list |
793 | | - ).annotate( |
| 797 | + ).exclude(target='default').annotate( |
794 | 798 | target_uuid=Cast("target", output_field=UUIDField())) |
795 | 799 | .values_list("target_uuid", flat=True)) |
796 | 800 |
|
@@ -839,7 +843,8 @@ def get_aggregation_query_set(self, auth): |
839 | 843 | user_id=user_id, |
840 | 844 | auth_target_type="TOOL", |
841 | 845 | permission_list__overlap=permission_list |
842 | | - ).annotate( |
| 846 | + ) |
| 847 | + .exclude(target='default').annotate( |
843 | 848 | target_uuid=Cast("target", output_field=UUIDField())) |
844 | 849 | .values_list("target_uuid", flat=True)) |
845 | 850 |
|
@@ -885,7 +890,7 @@ def get_aggregation_query_set(self, auth): |
885 | 890 | user_id=user_id, |
886 | 891 | auth_target_type="MODEL", |
887 | 892 | permission_list__overlap=permission_list |
888 | | - ).annotate( |
| 893 | + ).exclude(target='default').annotate( |
889 | 894 | target_uuid=Cast("target", output_field=UUIDField())) |
890 | 895 | .values_list("target_uuid", flat=True)) |
891 | 896 |
|
|
0 commit comments