wbcore 1.61.2__py2.py3-none-any.whl → 1.61.4__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. wbcore/configurations/base.py +2 -2
  2. wbcore/configurations/configurations/apps.py +1 -1
  3. wbcore/configurations/configurations/rest_framework.py +1 -1
  4. wbcore/contrib/agenda/viewsets/menu/calendar_items.py +1 -2
  5. wbcore/contrib/agenda/viewsets/menu/conference_room.py +4 -5
  6. wbcore/contrib/authentication/admin.py +15 -2
  7. wbcore/contrib/authentication/factories/users.py +4 -2
  8. wbcore/contrib/authentication/migrations/0008_user_is_internal.py +18 -0
  9. wbcore/contrib/authentication/models/users.py +16 -6
  10. wbcore/contrib/authentication/serializers/users.py +1 -1
  11. wbcore/contrib/authentication/viewsets/menu/user_activities.py +6 -3
  12. wbcore/contrib/authentication/viewsets/menu/users.py +1 -2
  13. wbcore/contrib/authentication/viewsets/users.py +2 -2
  14. wbcore/contrib/currency/tests/test_serializers.py +3 -1
  15. wbcore/contrib/directory/admin/entries.py +1 -1
  16. wbcore/contrib/directory/models/entries.py +21 -30
  17. wbcore/contrib/directory/tests/test_permissions.py +2 -4
  18. wbcore/contrib/directory/viewsets/endpoints/relationships.py +1 -2
  19. wbcore/contrib/directory/viewsets/entries.py +1 -1
  20. wbcore/contrib/directory/viewsets/menu/contacts.py +2 -3
  21. wbcore/contrib/directory/viewsets/menu/entries.py +5 -14
  22. wbcore/contrib/directory/viewsets/menu/relationships.py +2 -3
  23. wbcore/contrib/directory/viewsets/menu/utils.py +8 -9
  24. wbcore/contrib/documents/models/documents.py +1 -1
  25. wbcore/contrib/documents/viewsets/documents.py +3 -3
  26. wbcore/contrib/geography/viewsets/geography.py +1 -1
  27. wbcore/contrib/permission/apps.py +15 -0
  28. wbcore/contrib/permission/configurations.py +3 -0
  29. wbcore/contrib/{guardian → permission}/filters.py +2 -2
  30. wbcore/contrib/permission/internal/registry.py +43 -0
  31. wbcore/contrib/permission/management/__init__.py +4 -0
  32. wbcore/contrib/{guardian → permission}/models/mixins.py +73 -3
  33. wbcore/{permissions → contrib/permission}/permissions.py +1 -3
  34. wbcore/contrib/{guardian → permission}/tasks.py +1 -1
  35. wbcore/{tests/test_permissions → contrib/permission/tests}/test_backend.py +4 -6
  36. wbcore/contrib/{guardian → permission}/tests/test_model_mixins.py +6 -6
  37. wbcore/contrib/{guardian → permission}/tests/test_tasks.py +7 -7
  38. wbcore/contrib/{guardian → permission}/tests/test_utils.py +12 -12
  39. wbcore/contrib/{guardian → permission}/tests/test_viewsets.py +3 -3
  40. wbcore/contrib/{guardian → permission}/urls.py +1 -1
  41. wbcore/contrib/{guardian → permission}/utils.py +32 -4
  42. wbcore/contrib/{guardian → permission}/viewsets/configs/buttons.py +2 -2
  43. wbcore/contrib/{guardian → permission}/viewsets/configs/displays.py +1 -1
  44. wbcore/contrib/{guardian → permission}/viewsets/configs/endpoints.py +3 -3
  45. wbcore/contrib/{guardian → permission}/viewsets/configs/titles.py +1 -1
  46. wbcore/contrib/{guardian → permission}/viewsets/mixins.py +2 -2
  47. wbcore/contrib/{guardian → permission}/viewsets/viewsets.py +2 -2
  48. wbcore/contrib/workflow/viewsets/menu/condition.py +2 -3
  49. wbcore/contrib/workflow/viewsets/menu/data.py +2 -7
  50. wbcore/contrib/workflow/viewsets/menu/process.py +2 -5
  51. wbcore/contrib/workflow/viewsets/menu/step.py +16 -21
  52. wbcore/contrib/workflow/viewsets/menu/transition.py +2 -3
  53. wbcore/contrib/workflow/viewsets/menu/workflow.py +2 -5
  54. wbcore/tests/models.py +1 -1
  55. wbcore/urls.py +2 -2
  56. {wbcore-1.61.2.dist-info → wbcore-1.61.4.dist-info}/METADATA +1 -1
  57. {wbcore-1.61.2.dist-info → wbcore-1.61.4.dist-info}/RECORD +69 -70
  58. wbcore/contrib/guardian/apps.py +0 -6
  59. wbcore/contrib/guardian/configurations.py +0 -3
  60. wbcore/permissions/mixins.py +0 -72
  61. wbcore/permissions/registry.py +0 -33
  62. wbcore/permissions/shortcuts.py +0 -38
  63. wbcore/permissions/utils.py +0 -26
  64. /wbcore/contrib/{guardian → permission}/__init__.py +0 -0
  65. /wbcore/contrib/{guardian/migrations → permission/internal}/__init__.py +0 -0
  66. /wbcore/{permissions → contrib/permission/internal}/backend.py +0 -0
  67. /wbcore/contrib/{guardian → permission}/migrations/0001_initial.py +0 -0
  68. /wbcore/contrib/{guardian/tests → permission/migrations}/__init__.py +0 -0
  69. /wbcore/contrib/{guardian → permission}/models/__init__.py +0 -0
  70. /wbcore/contrib/{guardian → permission}/models/models.py +0 -0
  71. /wbcore/{permissions → contrib/permission/tests}/__init__.py +0 -0
  72. /wbcore/contrib/{guardian → permission}/tests/conftest.py +0 -0
  73. /wbcore/contrib/{guardian → permission}/viewsets/__init__.py +0 -0
  74. /wbcore/contrib/{guardian → permission}/viewsets/configs/__init__.py +0 -0
  75. {wbcore-1.61.2.dist-info → wbcore-1.61.4.dist-info}/WHEEL +0 -0
@@ -1,72 +0,0 @@
1
- from django.db import models
2
-
3
-
4
- class PermissionMixin(models.Model):
5
- class Meta:
6
- abstract = True
7
-
8
- @classmethod
9
- @property
10
- def view_perm_str(cls) -> str:
11
- """
12
- Get the view string permission identifer
13
-
14
- Returns:
15
- The view string permission identifier
16
- """
17
- return f"{cls._meta.app_label}.view_{cls._meta.model_name}"
18
-
19
- @classmethod
20
- @property
21
- def change_perm_str(cls) -> str:
22
- """
23
- Get the change string permission identifer
24
-
25
- Returns:
26
- The change string permission identifier
27
- """
28
- return f"{cls._meta.app_label}.change_{cls._meta.model_name}"
29
-
30
- @classmethod
31
- @property
32
- def delete_perm_str(cls) -> str:
33
- """
34
- Get the delete string permission identifer
35
-
36
- Returns:
37
- The delete string permission identifier
38
- """
39
- return f"{cls._meta.app_label}.delete_{cls._meta.model_name}"
40
-
41
- @classmethod
42
- @property
43
- def select_perm_str(cls) -> str:
44
- """
45
- Get the select string permission identifer
46
-
47
- Returns:
48
- The select string permission identifier
49
- """
50
- return f"{cls._meta.app_label}.select_{cls._meta.model_name}"
51
-
52
- @classmethod
53
- @property
54
- def admin_perm_str(cls) -> str:
55
- """
56
- Get the admin string permission identifer
57
-
58
- Returns:
59
- The admin string permission identifier
60
- """
61
- return f"{cls._meta.app_label}.administrate_{cls._meta.model_name}"
62
-
63
- @classmethod
64
- @property
65
- def add_perm_str(cls) -> str:
66
- """
67
- Get the add string permission identifer
68
-
69
- Returns:
70
- The add string permission identifier
71
- """
72
- return f"{cls._meta.app_label}.add_{cls._meta.model_name}"
@@ -1,33 +0,0 @@
1
- from contextlib import suppress
2
-
3
- from django.conf import settings
4
- from django.contrib.auth.models import Group
5
- from django.db.models import QuerySet
6
- from django.utils.functional import cached_property
7
- from django.utils.module_loading import import_string
8
-
9
- from wbcore.contrib.authentication.models import User
10
-
11
-
12
- class UserBackendRegistry:
13
- def __init__(self):
14
- internal_users_backend_path = getattr(settings, "USER_BACKEND", "wbcore.permissions.backend.UserBackend")
15
- internal_users_backend_class = import_string(internal_users_backend_path)
16
- self.backend = internal_users_backend_class()
17
-
18
- @cached_property
19
- def internal_groups(self) -> QuerySet[Group]:
20
- return self.backend.get_internal_groups().all()
21
-
22
- @cached_property
23
- def internal_users(self) -> QuerySet[User]:
24
- return self.backend.get_internal_users().all()
25
-
26
- def reset_cache(self):
27
- with suppress(AttributeError):
28
- del self.internal_users
29
- with suppress(AttributeError):
30
- del self.internal_groups
31
-
32
-
33
- user_registry = UserBackendRegistry()
@@ -1,38 +0,0 @@
1
- from django.contrib.auth.models import Group
2
- from django.db.models.query import QuerySet
3
-
4
- from wbcore.contrib.authentication.models.users import User
5
-
6
-
7
- def get_internal_groups() -> QuerySet[Group]:
8
- from wbcore.permissions.registry import user_registry
9
-
10
- """
11
- Return the cached groups of internals users
12
-
13
- Returns:
14
- A queryset of group corresponding to the internal notion defined by the set UserBackend
15
-
16
- Raises:
17
- ValueError: If user backend path does not correspond to a valid module
18
- """
19
- return user_registry.internal_groups
20
-
21
-
22
- def get_internal_users() -> QuerySet[User]:
23
- from wbcore.permissions.registry import user_registry
24
-
25
- """
26
- Return the cached queryset of internals users
27
-
28
- Returns:
29
- A queryset of user corresponding to the internal notion defined by the set UserBackend
30
-
31
- Raises:
32
- ValueError: If user backend path does not correspond to a valid module
33
- """
34
- return user_registry.internal_users
35
-
36
-
37
- def is_internal_user(user: User, include_superuser: bool = False) -> bool:
38
- return user and (user.is_internal or (include_superuser and user.is_superuser))
@@ -1,26 +0,0 @@
1
- from django.contrib.auth.models import Permission
2
-
3
-
4
- def perm_to_permission(perm: str) -> Permission:
5
- """
6
- Convert a identifier string permission format in 'app_label.codename'
7
- (teremd as *perm*) to a django permission instance.
8
-
9
- Args:
10
- perm: The string permission identifier in the form 'app_label.codename'
11
-
12
- Returns:
13
- The Permission object corresponding to the given string identifier
14
-
15
- Raises:
16
- AttributeError: When the given string identifier does not match the expected format 'app_label.codename'
17
- """
18
- try:
19
- app_label, codename = perm.split(".", 1)
20
- except IndexError as e:
21
- raise AttributeError(
22
- "The format of identifier string permission (perm) is wrong. " "It should be in 'app_label.codename'."
23
- ) from e
24
- else:
25
- permission = Permission.objects.get(content_type__app_label=app_label, codename=codename)
26
- return permission
File without changes