-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4651 from mikhailprivalov/WTS-currentBranc
Wts current branc
- Loading branch information
Showing
12 changed files
with
834 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from django.urls import path | ||
from api.working_time import views | ||
|
||
urlpatterns = [path('get-departments', views.get_departments), path('get-work-time', views.get_work_time), path('update-time', views.update_time)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import json | ||
|
||
from django.contrib.auth.decorators import login_required | ||
from django.http import JsonResponse | ||
from laboratory.decorators import group_required | ||
from employees.models import Department, EmployeeWorkingHoursSchedule | ||
|
||
|
||
@login_required() | ||
@group_required('График рабочего времени') | ||
def get_departments(request): | ||
departments = Department.get_active() | ||
return JsonResponse({"result": departments}) | ||
|
||
|
||
@login_required() | ||
@group_required('График рабочего времени') | ||
def get_work_time(request): | ||
request_data = json.loads(request.body) | ||
result = EmployeeWorkingHoursSchedule.get_work_time(request_data["year"], request_data["month"], request_data["departmentId"]) | ||
return JsonResponse({"result": result}) | ||
|
||
|
||
@login_required() | ||
@group_required('График рабочего времени') | ||
def update_time(request): | ||
request_data = json.loads(request.body) | ||
start_work = request_data["startWork"] | ||
end_work = request_data["endWork"] | ||
type_work = request_data["type"] | ||
employee_position_id = request_data["employeePositionId"] | ||
date = request_data["date"] | ||
result = EmployeeWorkingHoursSchedule.update_time(start_work, end_work, type_work, employee_position_id, date) | ||
return JsonResponse(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.db import connection | ||
|
||
from utils.db import namedtuplefetchall | ||
|
||
|
||
def get_work_time_by_document(document_id: int): | ||
with connection.cursor() as cursor: | ||
cursor.execute( | ||
""" | ||
SELECT employees_employee.family, employees_employee.name, employees_employee.patronymic, employees_position.name as position_name, | ||
employees_employeeworkinghoursschedule.id as worktime_id, start, "end", day, work_day_status_id, employee_position_id FROM employees_employeeWorkingHoursSchedule | ||
INNER JOIN employees_employeeposition ON employees_employeeWorkingHoursSchedule.employee_position_id = employees_employeeposition.id | ||
INNER JOIN employees_employee ON employees_employeeposition.employee_id = employees_employee.id | ||
INNER JOIN employees_position ON employees_employeeposition.position_id = employees_position.id | ||
WHERE time_tracking_document_id = %(document_id)s | ||
ORDER BY employee_position_id | ||
""", | ||
params={'document_id': document_id}, | ||
) | ||
row = namedtuplefetchall(cursor) | ||
return row | ||
|
||
|
||
def get_employees_by_department(department_id: int): | ||
with connection.cursor() as cursor: | ||
cursor.execute( | ||
""" | ||
SELECT employees_employeeposition.id as employee_position_id, employees_position.name as position_name, family, | ||
employees_employee.name, patronymic FROM employees_employeeposition | ||
INNER JOIN employees_position ON employees_employeeposition.position_id = employees_position.id | ||
INNER JOIN employees_employee ON employees_employeeposition.employee_id = employees_employee.id | ||
WHERE department_id = %(department_id)s and employees_employeeposition.is_active = true | ||
ORDER BY family | ||
""", | ||
params={'department_id': department_id}, | ||
) | ||
row = namedtuplefetchall(cursor) | ||
return row |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.