wbhuman_resources 1.59.15__py2.py3-none-any.whl → 1.59.16__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.
- wbhuman_resources/models/absence.py +11 -0
- wbhuman_resources/serializers/__init__.py +1 -0
- wbhuman_resources/serializers/absence.py +5 -0
- wbhuman_resources/viewsets/absence.py +13 -1
- wbhuman_resources/viewsets/endpoints/absence.py +3 -1
- {wbhuman_resources-1.59.15.dist-info → wbhuman_resources-1.59.16.dist-info}/METADATA +1 -1
- {wbhuman_resources-1.59.15.dist-info → wbhuman_resources-1.59.16.dist-info}/RECORD +8 -8
- {wbhuman_resources-1.59.15.dist-info → wbhuman_resources-1.59.16.dist-info}/WHEEL +0 -0
|
@@ -38,6 +38,17 @@ from .preferences import get_previous_year_balance_expiration_date
|
|
|
38
38
|
User = get_user_model()
|
|
39
39
|
|
|
40
40
|
|
|
41
|
+
def can_edit_request(instance: "AbsenceRequest", user: "User") -> bool:
|
|
42
|
+
if (employee := getattr(user.profile, "human_resources", None)) and employee.is_active and user.profile:
|
|
43
|
+
requester = instance.employee
|
|
44
|
+
return instance.status == AbsenceRequest.Status.DRAFT and (
|
|
45
|
+
user.has_perm("wbhuman_resources.administrate_absencerequest")
|
|
46
|
+
or employee.is_manager_of(requester)
|
|
47
|
+
or user.profile == requester.profile
|
|
48
|
+
)
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
|
|
41
52
|
def can_cancel_request(instance: "AbsenceRequest", user: "User") -> bool:
|
|
42
53
|
"""
|
|
43
54
|
Check if the given user has cancel ability on the given request
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .absence import (
|
|
2
2
|
AbsenceRequestCrossBorderCountryModelSerializer,
|
|
3
3
|
AbsenceRequestModelSerializer,
|
|
4
|
+
ReadOnlyAbsenceRequestModelSerializer,
|
|
4
5
|
AbsenceRequestPeriodsModelSerializer,
|
|
5
6
|
AbsenceRequestTypeModelSerializer,
|
|
6
7
|
AbsenceRequestTypeRepresentationSerializer,
|
|
@@ -269,6 +269,11 @@ class AbsenceRequestModelSerializer(wb_serializers.ModelSerializer):
|
|
|
269
269
|
]
|
|
270
270
|
|
|
271
271
|
|
|
272
|
+
class ReadOnlyAbsenceRequestModelSerializer(AbsenceRequestModelSerializer):
|
|
273
|
+
class Meta(AbsenceRequestModelSerializer.Meta):
|
|
274
|
+
read_only_fields = AbsenceRequestModelSerializer.Meta.fields
|
|
275
|
+
|
|
276
|
+
|
|
272
277
|
class EmployeeAbsenceDaysModelSerializer(wb_serializers.ModelSerializer):
|
|
273
278
|
year = wb_serializers.YearField(read_only=True)
|
|
274
279
|
absence_type = wb_serializers.ChoiceField(read_only=True, choices=AbsenceRequestType.get_choices())
|
|
@@ -32,6 +32,7 @@ from wbhuman_resources.serializers import (
|
|
|
32
32
|
AbsenceRequestTypeModelSerializer,
|
|
33
33
|
AbsenceRequestTypeRepresentationSerializer,
|
|
34
34
|
EmployeeAbsenceDaysModelSerializer,
|
|
35
|
+
ReadOnlyAbsenceRequestModelSerializer,
|
|
35
36
|
)
|
|
36
37
|
from wbhuman_resources.viewsets.buttons import AbsenceRequestButtonConfig
|
|
37
38
|
from wbhuman_resources.viewsets.display import (
|
|
@@ -54,7 +55,7 @@ from wbhuman_resources.viewsets.titles import (
|
|
|
54
55
|
AbsenceTypeCountEmployeeTitleConfig,
|
|
55
56
|
)
|
|
56
57
|
|
|
57
|
-
from ..models.absence import can_validate_or_deny_request
|
|
58
|
+
from ..models.absence import can_edit_request, can_validate_or_deny_request
|
|
58
59
|
from .mixins import EmployeeViewMixin
|
|
59
60
|
|
|
60
61
|
|
|
@@ -108,6 +109,17 @@ class AbsenceRequestModelViewSet(EmployeeViewMixin, viewsets.ModelViewSet):
|
|
|
108
109
|
return can_validate_or_deny_request(obj, self.request.user)
|
|
109
110
|
return False
|
|
110
111
|
|
|
112
|
+
@cached_property
|
|
113
|
+
def can_edit_request(self) -> bool:
|
|
114
|
+
if "pk" in self.kwargs and (obj := self.get_object()):
|
|
115
|
+
return can_edit_request(obj, self.request.user)
|
|
116
|
+
return True
|
|
117
|
+
|
|
118
|
+
def get_serializer_class(self):
|
|
119
|
+
if self.can_edit_request:
|
|
120
|
+
return AbsenceRequestModelSerializer
|
|
121
|
+
return ReadOnlyAbsenceRequestModelSerializer
|
|
122
|
+
|
|
111
123
|
def add_messages(
|
|
112
124
|
self,
|
|
113
125
|
request,
|
|
@@ -18,7 +18,9 @@ class AbsenceRequestEndpointConfig(EndpointViewConfig):
|
|
|
18
18
|
return self.get_endpoint()
|
|
19
19
|
|
|
20
20
|
def get_create_endpoint(self, **kwargs):
|
|
21
|
-
|
|
21
|
+
if (profile := self.request.user.profile) and hasattr(profile, "human_resources"):
|
|
22
|
+
return self.get_endpoint()
|
|
23
|
+
return None
|
|
22
24
|
|
|
23
25
|
def get_delete_endpoint(self, **kwargs):
|
|
24
26
|
if self.instance:
|
|
@@ -44,7 +44,7 @@ wbhuman_resources/migrations/0023_alter_employeehumanresource_weekly_off_periods
|
|
|
44
44
|
wbhuman_resources/migrations/0024_alter_absencerequestperiods_unique_together_and_more.py,sha256=djPNPo9m_uWKEYJ3BmR_5-dJHjI7qxtU6oIixml3F1Y,1727
|
|
45
45
|
wbhuman_resources/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
wbhuman_resources/models/__init__.py,sha256=PW4LDmMpJqcynmnbdy_VSwbhxyDU9ZCR2LIXk6LkHlg,631
|
|
47
|
-
wbhuman_resources/models/absence.py,sha256=
|
|
47
|
+
wbhuman_resources/models/absence.py,sha256=ktrZNBcrviKTL1biIYQtcSfAUiCE1e1FS-rnds5l9qk,36463
|
|
48
48
|
wbhuman_resources/models/calendars.py,sha256=ci7bBdftBd_AWdSmbkH4a12Nq9CbGoyrP3rdx0LKFFA,14680
|
|
49
49
|
wbhuman_resources/models/employee.py,sha256=ICRaLNvhyqRRmJg9JP5ZLJ9DwOW5rPTKe9o4kLpYJiU,50563
|
|
50
50
|
wbhuman_resources/models/kpi.py,sha256=BrYKb56MKm5Ya0sIav3-jmw0qk4zKNoSRr0bYfNM9mk,7270
|
|
@@ -52,8 +52,8 @@ wbhuman_resources/models/preferences.py,sha256=iQhcu-jrEkk8DgM5hgakg5mdkbtlO11Ke
|
|
|
52
52
|
wbhuman_resources/models/review.py,sha256=YeQjxIs6uYxemErt1wUM4F4MwrK1SK55PLe3Tm7R-Kw,39582
|
|
53
53
|
wbhuman_resources/permissions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
wbhuman_resources/permissions/backend.py,sha256=lPIcCLkYG7gqtx7EgGquQrt_yhscZWj2ZGBqOWm8Cww,872
|
|
55
|
-
wbhuman_resources/serializers/__init__.py,sha256=
|
|
56
|
-
wbhuman_resources/serializers/absence.py,sha256=
|
|
55
|
+
wbhuman_resources/serializers/__init__.py,sha256=GBVNCUCPr5RSZhy3gx8fksMu0GP4ORKT-TOGVe4heF0,1663
|
|
56
|
+
wbhuman_resources/serializers/absence.py,sha256=J288306nQHHeK2W04BZhSST2-oEPXTvxCF9tSSy5c7A,12183
|
|
57
57
|
wbhuman_resources/serializers/calendars.py,sha256=bvnGbZZtr4QckwAkajuS_b69zJOF6msYjh0mu7d4Crs,2384
|
|
58
58
|
wbhuman_resources/serializers/employee.py,sha256=-ll-UAIVMGtaWtdtEc8q_qlzToa9W6Yd8HOZ0KcltmY,10101
|
|
59
59
|
wbhuman_resources/serializers/kpi.py,sha256=JjpazovWjY8MUjD_1NUudQot_BYwzetKzbiEvMPQOug,2636
|
|
@@ -71,7 +71,7 @@ wbhuman_resources/tests/models/test_employees.py,sha256=vubEioP9LDcH5OCi4gK4Mrto
|
|
|
71
71
|
wbhuman_resources/tests/models/test_review.py,sha256=YZHxBmvqEpvbSaePldJZ1vzFk7F6Hq1paDrrrODIoGY,4527
|
|
72
72
|
wbhuman_resources/tests/models/test_utils.py,sha256=f3df5rpk7--6_kM1XGspeCrDUYto0m97i8Cs8pYM7B4,4676
|
|
73
73
|
wbhuman_resources/viewsets/__init__.py,sha256=Yg_nkFnzkf_HGmScY6jcZBXcFcwJ4ePW5gKwpaG2ybU,2142
|
|
74
|
-
wbhuman_resources/viewsets/absence.py,sha256=
|
|
74
|
+
wbhuman_resources/viewsets/absence.py,sha256=gNWfz0nsW8l_FuZs1_gvAfucQJi5RZxX0aEEUdgZyWc,13630
|
|
75
75
|
wbhuman_resources/viewsets/absence_charts.py,sha256=eML8_ayANy0GjeUTpfXyivQAeFJxEUroOOk59j5Nod0,12307
|
|
76
76
|
wbhuman_resources/viewsets/calendars.py,sha256=qX5rPnw6f6LBYd8_vxc17AUtX22LGwhZs5_fiO2sBbE,3153
|
|
77
77
|
wbhuman_resources/viewsets/employee.py,sha256=ffJpIrV2f2n_a2I-Dx6XXlirLO6G3D83cdpwZDKBAVI,7345
|
|
@@ -91,7 +91,7 @@ wbhuman_resources/viewsets/display/employee.py,sha256=5DU_s61Ad0NsCqunes6vLDqzCt
|
|
|
91
91
|
wbhuman_resources/viewsets/display/kpis.py,sha256=40RM0Bq7nWpMc0b29kJhgynDjMyUoedcld1AlQ5w21I,3668
|
|
92
92
|
wbhuman_resources/viewsets/display/review.py,sha256=9vW-h8oY4GBf5I8scUI48EPZPWpNIZ70ht5QT9Hy-DY,18879
|
|
93
93
|
wbhuman_resources/viewsets/endpoints/__init__.py,sha256=4wnSFaRKJwTcK2_F7upzVZKPtK5BLcLRpOPcECq9in8,1450
|
|
94
|
-
wbhuman_resources/viewsets/endpoints/absence.py,sha256=
|
|
94
|
+
wbhuman_resources/viewsets/endpoints/absence.py,sha256=pYmgqd_0Loeby9N5rEcc-H-Ulv0EjQpbkdSBzJZJv8w,1978
|
|
95
95
|
wbhuman_resources/viewsets/endpoints/calendars.py,sha256=Rt-fMwNBQCugBE3-LLK3P3OsF7upbEPm2pyy175ZcPM,640
|
|
96
96
|
wbhuman_resources/viewsets/endpoints/employee.py,sha256=BAp6Y1YNlBFCA-jK-dk2L32kq-zF4u1aWxh526PvYOw,1653
|
|
97
97
|
wbhuman_resources/viewsets/endpoints/kpis.py,sha256=NzN641_p_J_-84pOXc6niG3gUXHDR72S6JGpLE-jxqQ,1498
|
|
@@ -108,6 +108,6 @@ wbhuman_resources/viewsets/titles/absence.py,sha256=4F4ENgmZBGKiDuC8DmgrklNXEsRo
|
|
|
108
108
|
wbhuman_resources/viewsets/titles/employee.py,sha256=VP_AC3E-3fpbO8-RUvi2haXcoJr9LVLYtJifGawVRGo,565
|
|
109
109
|
wbhuman_resources/viewsets/titles/kpis.py,sha256=OSH_vIsIjfThWn17X_K7ykBKAFqNvz8M4PyFCF8BRQo,491
|
|
110
110
|
wbhuman_resources/viewsets/titles/review.py,sha256=fL_PqTNAIK7alk_-7RaklkiR9guh54u8oS0m5AWOSSc,2458
|
|
111
|
-
wbhuman_resources-1.59.
|
|
112
|
-
wbhuman_resources-1.59.
|
|
113
|
-
wbhuman_resources-1.59.
|
|
111
|
+
wbhuman_resources-1.59.16.dist-info/METADATA,sha256=2Qq3yArIT71e2gAsoILlVML6EsvdmIEdxk1gUCvNS-Y,273
|
|
112
|
+
wbhuman_resources-1.59.16.dist-info/WHEEL,sha256=aha0VrrYvgDJ3Xxl3db_g_MDIW-ZexDdrc_m-Hk8YY4,105
|
|
113
|
+
wbhuman_resources-1.59.16.dist-info/RECORD,,
|
|
File without changes
|