added documentation for /api/back/establishments/<id>/employees/

This commit is contained in:
Anatoly 2020-02-06 13:12:01 +03:00
parent 2ffe4bc3ea
commit cd766e6bbf
7 changed files with 133 additions and 16 deletions

View File

@ -118,7 +118,7 @@ class GuideListCreateView(GuideBaseView, generics.ListCreateAPIView):
### Response ### Response
Return paginated list of guides. Return paginated list of guides.
I.e.: E.g.:
``` ```
{ {
"count": 58, "count": 58,

View File

@ -15,7 +15,7 @@ from establishment import models, serializers as model_serializers
from establishment.models import ContactEmail, ContactPhone, EstablishmentEmployee from establishment.models import ContactEmail, ContactPhone, EstablishmentEmployee
from establishment.serializers.common import ContactPhonesSerializer from establishment.serializers.common import ContactPhonesSerializer
from gallery.models import Image from gallery.models import Image
from location.serializers import AddressDetailSerializer, TranslatedField, AddressBaseSerializer from location.serializers import AddressDetailSerializer, TranslatedField
from main import models as main_models from main import models as main_models
from main.models import Currency from main.models import Currency
from main.serializers import AwardSerializer from main.serializers import AwardSerializer
@ -529,10 +529,8 @@ class EstEmployeeBackSerializer(EmployeeBackSerializers):
'toque_number', 'toque_number',
'available_for_events', 'available_for_events',
'photo', 'photo',
'photo_id',
] ]
extra_kwargs = {
'phone': {'write_only': True}
}
class EstablishmentBackOfficeGallerySerializer(serializers.ModelSerializer): class EstablishmentBackOfficeGallerySerializer(serializers.ModelSerializer):

View File

@ -531,17 +531,18 @@ class EmployeeListCreateView(generics.ListCreateAPIView):
#### Request #### Request
Required fields: Required fields:
* available_for_events (bool) - flag that responds for availability for events * name (`str`) - employee name
Non-required fields: Non-required fields:
* name (`str`) - name * name (`str`) - employee name
* last_name (`str`) - last name * last_name (`str`) - employee last name
* user (`int`) - user identifier * user (`int`) - user identifier
* sex (`int`) - enum: `0 (Male), 1 (Female)` * sex (`int`) - enum: `0 (Male), 1 (Female)`
* birth_date (`str`) - birth datetime (datetime in a format `ISO-8601`) * birth_date (`str`) - birth datetime (datetime in a format `ISO-8601`)
* email (`str`) - email address * email (`str`) - email address
* phone (`str`) - phone number in a format `E164` * phone (`str`) - phone number in a format `E164`
* photo_id (`int`) - photo identifier * photo_id (`int`) - photo identifier
* available_for_events (bool) - flag that responds for availability for events
""" """
filter_class = filters.EmployeeBackFilter filter_class = filters.EmployeeBackFilter
serializer_class = serializers.EmployeeBackSerializers serializer_class = serializers.EmployeeBackSerializers
@ -590,7 +591,47 @@ class EmployeesListSearchViews(generics.ListAPIView):
class EstablishmentEmployeeListView(generics.ListCreateAPIView): class EstablishmentEmployeeListView(generics.ListCreateAPIView):
"""Establishment employees list view.""" """
## Establishment employees List/Create view.
### *GET*
#### Description
Returning non-paginated list of employees by establishment identifier.
##### Response
E.g.:
```
[
{
"id": 1,
...
}
]
```
### *POST*
#### Description
Create a new instance of employee for establishment by establishment identifier.
#### Request
Required:
* name (`str`) - employee name
Additional:
* last_name (`str`) - employee last name
* user (`int`) - user identifier
* sex (`int`) - enum: `0 (Male), 1 (Female)`
* birth_date (`str`) - birth datetime (datetime in a format `ISO-8601`)
* email (`str`) - email address
* phone (`str`) - phone number in a format `E164`
* available_for_events (bool) - flag that responds for availability for events
* photo_id (`int`) - photo identifier
#### Response
```
{
"id": 1,
...
}
```
"""
serializer_class = serializers.EstEmployeeBackSerializer serializer_class = serializers.EstEmployeeBackSerializer
pagination_class = None pagination_class = None
permission_classes = get_permission_classes( permission_classes = get_permission_classes(
@ -613,7 +654,8 @@ class EmployeeRUDView(generics.RetrieveUpdateDestroyAPIView):
""" """
## Employee Retrieve/Update/Destroy view ## Employee Retrieve/Update/Destroy view
### *GET* ### *GET*
#### Retrieve a serialized object of employee. #### Description
Retrieve a serialized object of employee.
##### Response ##### Response
``` ```
{ {
@ -638,7 +680,7 @@ class EmployeeRUDView(generics.RetrieveUpdateDestroyAPIView):
* photo_id (`int`) - image identifier * photo_id (`int`) - image identifier
##### Response ##### Response
Return an employee serialized object Return an employee serialized object
I.e.: E.g.:
``` ```
{ {
"id": 1, "id": 1,
@ -651,7 +693,7 @@ class EmployeeRUDView(generics.RetrieveUpdateDestroyAPIView):
Delete an instance of employee Delete an instance of employee
##### Response ##### Response
``` ```
No response data No content
``` ```
""" """
serializer_class = serializers.EmployeeBackSerializers serializer_class = serializers.EmployeeBackSerializers
@ -663,6 +705,16 @@ class EmployeeRUDView(generics.RetrieveUpdateDestroyAPIView):
class RemoveAwardView(generics.DestroyAPIView): class RemoveAwardView(generics.DestroyAPIView):
"""
## Remove award view.
### *DELETE*
#### Description
Remove an award from an employee by an employee identifier and an award identifier.
##### Response
```
No content
```
"""
lookup_field = 'pk' lookup_field = 'pk'
serializer_class = serializers.EmployeeBackSerializers serializer_class = serializers.EmployeeBackSerializers
queryset = models.Employee.objects.with_back_office_related() queryset = models.Employee.objects.with_back_office_related()
@ -923,7 +975,25 @@ class EstablishmentPositionListView(generics.ListAPIView):
class EstablishmentAdminView(generics.ListAPIView): class EstablishmentAdminView(generics.ListAPIView):
"""Establishment admin list view.""" """
## List establishment admins
### *GET*
#### Description
Returning paginated list of establishment administrators by establishment slug.
##### Response
```
{
"count": 58,
"next": 2,
"previous": null,
"results": [
{
"id": 1,
...
}
]
}
``` """
serializer_class = serializers.EstablishmentAdminListSerializer serializer_class = serializers.EstablishmentAdminListSerializer
permission_classes = get_permission_classes( permission_classes = get_permission_classes(
IsEstablishmentManager, IsEstablishmentManager,

View File

@ -13,7 +13,7 @@ class ReportListCreateView(ReportBaseView, ListCreateAPIView):
* category: integer (0 - Bug, 1 - Suggestion improvement) * category: integer (0 - Bug, 1 - Suggestion improvement)
* url: char (URL) * url: char (URL)
* description: text (problem description) * description: text (problem description)
I.e.: E.g.:
``` ```
{ {
"category": 1, "category": 1,

View File

@ -38,7 +38,7 @@ class ReportRetrieveView(ReportBaseView, generics.RetrieveAPIView):
## View for retrieving serialized instance. ## View for retrieving serialized instance.
### Response ### Response
Return serialized object. Return serialized object.
I.e.: E.g.:
``` ```
{ {
"count": 7, "count": 7,

View File

@ -13,7 +13,7 @@ class ReportListCreateView(ReportBaseView, ListCreateAPIView):
* category: integer (0 - Bug, 1 - Suggestion improvement) * category: integer (0 - Bug, 1 - Suggestion improvement)
* url: char (URL) * url: char (URL)
* description: text (problem description) * description: text (problem description)
I.e.: E.g.:
``` ```
{ {
"category": 1, "category": 1,

File diff suppressed because one or more lines are too long