[UPDT] HORILLA API: Employee bank details user permission
This commit is contained in:
@@ -182,6 +182,7 @@ class AttendanceView(APIView):
|
||||
|
||||
def get_queryset(self, request, type):
|
||||
if type == "ot":
|
||||
|
||||
condition = AttendanceValidationCondition.objects.first()
|
||||
minot = strtime_seconds("00:30")
|
||||
if condition is not None:
|
||||
@@ -190,6 +191,14 @@ class AttendanceView(APIView):
|
||||
overtime_second__gte=minot,
|
||||
attendance_validated=True,
|
||||
)
|
||||
if request.user.has_perm("attendance.view_attendance"):
|
||||
queryset = queryset
|
||||
subordinates = Employee.objects.filter(
|
||||
employee_work_info__reporting_manager_id=request.user.employee_get
|
||||
)
|
||||
|
||||
print("subordinates: ", subordinates)
|
||||
print(subordinates)
|
||||
|
||||
elif type == "validated":
|
||||
queryset = Attendance.objects.filter(attendance_validated=True)
|
||||
|
||||
@@ -410,12 +410,18 @@ class WorkTypeRequestView(APIView):
|
||||
WorkTypeRequest, "base.change_worktyperequest"
|
||||
)
|
||||
def put(self, request, pk):
|
||||
print("request.user.employee_get: ", request.user.employee_get)
|
||||
print()
|
||||
print("request.data: ", request.data)
|
||||
work_type_request = object_check(WorkTypeRequest, pk)
|
||||
if work_type_request is None:
|
||||
return Response({"error": "WorkTypeRequest not found"}, status=404)
|
||||
serializer = self.serializer_class(work_type_request, data=request.data)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
print()
|
||||
print("serializer.data: ", serializer.data)
|
||||
print()
|
||||
return Response(serializer.data, status=200)
|
||||
return Response(serializer.errors, status=400)
|
||||
|
||||
|
||||
@@ -98,21 +98,17 @@ class EmployeeAPIView(APIView):
|
||||
{"error": "Employee does not exist"},
|
||||
status=status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
|
||||
serializer = EmployeeSerializer(employee)
|
||||
return Response(serializer.data)
|
||||
|
||||
paginator = PageNumberPagination()
|
||||
employees_queryset = Employee.objects.all()
|
||||
employees_filter_queryset = self.filterset_class(
|
||||
request.GET, queryset=employees_queryset
|
||||
).qs
|
||||
|
||||
field_name = request.GET.get("groupby_field", None)
|
||||
if field_name:
|
||||
url = request.build_absolute_uri()
|
||||
return groupby_queryset(request, url, field_name, employees_filter_queryset)
|
||||
|
||||
page = paginator.paginate_queryset(employees_filter_queryset, request)
|
||||
serializer = EmployeeSerializer(page, many=True)
|
||||
return paginator.get_paginated_response(serializer.data)
|
||||
@@ -223,7 +219,6 @@ class EmployeeBankDetailsAPIView(APIView):
|
||||
bank_detail.employee_id.get_reporting_manager(),
|
||||
]
|
||||
) or request.user.has_perm("employee.view_employeebankdetails"):
|
||||
|
||||
serializer = EmployeeBankDetailsSerializer(bank_detail)
|
||||
return Response(serializer.data)
|
||||
|
||||
@@ -294,9 +289,9 @@ class EmployeeWorkInformationAPIView(APIView):
|
||||
def get(self, request, pk):
|
||||
work_info = EmployeeWorkInformation.objects.get(pk=pk)
|
||||
if (
|
||||
request.user.employee_get == work_info.reporting_manager_id
|
||||
or request.user.has_perm("employee.view_employeeworkinformation")
|
||||
):
|
||||
request.user.employee_get
|
||||
in [work_info.employee_id, work_info.reporting_manager_id]
|
||||
) or request.user.has_perm("employee.view_employeeworkinformation"):
|
||||
serializer = EmployeeWorkInformationSerializer(work_info)
|
||||
return Response(serializer.data, status=200)
|
||||
return Response({"message": "No permission"}, status=400)
|
||||
|
||||
Reference in New Issue
Block a user