diff --git a/apps/establishment/urls/back.py b/apps/establishment/urls/back.py index ce1fea10..64bf736d 100644 --- a/apps/establishment/urls/back.py +++ b/apps/establishment/urls/back.py @@ -63,7 +63,7 @@ urlpatterns = [ path('employees/search/', views.EmployeesListSearchViews.as_view(), name='employees-search'), path('employees//', views.EmployeeRUDView.as_view(), name='employees-rud'), path('employees//', views.RemoveAwardView.as_view(), name='employees-award-delete'), - path('/employee//position/', + path('/employee//position//', views.EstablishmentEmployeeCreateView.as_view(), name='employees-establishment-create'), path('employee/position//delete/', views.EstablishmentEmployeeDeleteView.as_view(), diff --git a/apps/establishment/views/back.py b/apps/establishment/views/back.py index 325638bb..921470ad 100644 --- a/apps/establishment/views/back.py +++ b/apps/establishment/views/back.py @@ -69,8 +69,28 @@ class EstablishmentListCreateView(EstablishmentMixinViews, generics.ListCreateAP class EmployeeEstablishmentPositionsView(generics.ListAPIView): - """Establishment by employee view.""" - + """ + ## Establishment employee positions filtered by employee identifier. + ### *GET* + #### Description + Return paginated list of results from an intermediate table filtered by employee + identifier, that contains connection between employee establishment, + employee hiring dates, position, status `'I' (Idle)`, `'A' (Accepted)`, `'D' (Declined)`. + ##### Response + ``` + { + "count": 58, + "next": 2, + "previous": null, + "results": [ + { + "id": 1, + ... + } + ] + } + ``` + """ queryset = models.EstablishmentEmployee.objects.all() serializer_class = serializers.EstablishmentEmployeePositionsSerializer permission_classes = get_permission_classes( @@ -85,7 +105,26 @@ class EmployeeEstablishmentPositionsView(generics.ListAPIView): class EmployeeEstablishmentsListView(generics.ListAPIView): - """Establishment by employee list view.""" + """ + ## Employee establishments filtered by employee identifier. + ### *GET* + #### Description + Return paginated list of establishments filtered by employee identifier. + ##### Response + ``` + { + "count": 58, + "next": 2, + "previous": null, + "results": [ + { + "id": 1, + ... + } + ] + } + ``` + """ serializer_class = serializers.EstablishmentListCreateSerializer permission_classes = get_permission_classes( IsEstablishmentManager, @@ -99,8 +138,25 @@ class EmployeeEstablishmentsListView(generics.ListAPIView): class EmployeePositionsListView(generics.ListAPIView): - """Establishment position by employee list view.""" - + """ + ## Paginated list of establishments filtered by employee identifier + ### *GET* + #### Description + Return a paginated list of establishments of an employee by employee identifier. + ##### Response + ``` + { + "count": 2, + "next": null, + "previous": null, + "results": [ + { + "id": 1, + ... + } + } + ``` + """ queryset = models.Establishment.objects.all() serializer_class = serializers.EstablishmentPositionListSerializer permission_classes = get_permission_classes( @@ -942,6 +998,29 @@ class EstablishmentNoteRUDView(EstablishmentMixinViews, class EstablishmentEmployeeCreateView(generics.CreateAPIView): + """ + ## Create employee position for establishment + ### *POST* + #### Description + Creating position for an employee for establishment, + by `establishment identifier`, `employee identifier` and + `position identifier`. + + ##### Request data + Available fields: + * from_date - datetime (datetime in a format `ISO-8601`), by default `timezone.now()` + * to_date - datetime (datetime in a format `ISO-8601`), by default `null` + + ##### Response data + E.g.: + ``` + { + "id": 47405, + "from_date": "2020-02-06T11:01:04.961000Z", + "to_date": "2020-02-06T11:01:04.961000Z" + } + ``` + """ serializer_class = serializers.EstablishmentEmployeeCreateSerializer queryset = models.EstablishmentEmployee.objects.all() permission_classes = get_permission_classes( @@ -951,6 +1030,18 @@ class EstablishmentEmployeeCreateView(generics.CreateAPIView): class EstablishmentEmployeeDeleteView(generics.DestroyAPIView): + """ + ## Delete employee position for establishment + ### *DELETE* + #### Description + Deleting position for an employee from establishment, by `position identifier`. + + + ##### Response data + ``` + No content + ``` + """ queryset = EstablishmentEmployee.objects.all() permission_classes = get_permission_classes( IsEstablishmentManager,