Skip to content
Snippets Groups Projects
Commit 51a66173 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

indentation

parent 1ffa87f1
No related branches found
No related tags found
1 merge request!336Pylint checks
......@@ -122,10 +122,10 @@ def serialize_worker(worker):
return result
def add_worker_availability(request, worker_id, weekday, start_hour, end_hour):
if worker_id is None or weekday is None or start_hour is None or end_hour is None:
context = {
'status': '400', 'reason': 'Either worker_id, weekday, start_hour, end_hour or all of them are invalid.'
'status': '400', 'reason': 'Either worker_id, weekday, start_hour, end_hour or all of them are invalid.'
}
response = HttpResponse(json.dumps(context), content_type='application/json')
response.status_code = 400
......@@ -133,17 +133,17 @@ def add_worker_availability(request, worker_id, weekday, start_hour, end_hour):
worker = get_object_or_404(Worker, id=int(worker_id))
availability, _ = Availability.objects.update_or_create(person=worker, day_number=weekday,
availability, _ = Availability.objects.update_or_create(person=worker, day_number=weekday,
defaults={'available_from': start_hour, 'available_till': end_hour})
availability.save()
return JsonResponse({}, status=200)
return JsonResponse({}, status=200)
def add_worker_extra_availability(request, worker_id, start_str_date, end_str_date):
if start_str_date is None or end_str_date is None or worker_id is None:
context = {
'status': '400', 'reason': 'Either start_date, end_str_date, worker_id or all of them are invalid.'
'status': '400', 'reason': 'Either start_date, end_str_date, worker_id or all of them are invalid.'
}
response = HttpResponse(json.dumps(context), content_type='application/json')
response.status_code = 400
......@@ -153,7 +153,10 @@ def add_worker_extra_availability(request, worker_id, start_str_date, end_str_da
end_date = datetime.datetime.strptime(end_str_date, "%Y-%m-%d-%H-%M").replace(tzinfo=timezone.now().tzinfo)
worker = get_object_or_404(Worker, id=int(worker_id))
extra_availability, _ = Holiday.objects.update_or_create(person=worker, datetime_start=start_date, datetime_end=end_date, kind=AVAILABILITY_EXTRA)
extra_availability, _ = Holiday.objects.update_or_create(person=worker,
datetime_start=start_date,
datetime_end=end_date,
kind=AVAILABILITY_EXTRA)
extra_availability.save()
return JsonResponse({}, status=200)
......@@ -162,10 +165,10 @@ def get_worker_availability(request):
start_str_date = request.GET.get("start_date")
end_str_date = request.GET.get("end_date")
worker_id = request.GET.get("worker_id")
if start_str_date is None or worker_id is None:
context = {
'status': '400', 'reason': 'Either start_date, worker_id or both are invalid.'
'status': '400', 'reason': 'Either start_date, worker_id or both are invalid.'
}
response = HttpResponse(json.dumps(context), content_type='application/json')
response.status_code = 400
......@@ -181,7 +184,7 @@ def get_worker_availability(request):
result = {
'start_date': start_date,
'end_date': end_date,
'end_date': end_date,
'availability': round(worker.availability_percentage(start_date=start_date, end_date=end_date), 0)
}
return JsonResponse(result)
\ No newline at end of file
return JsonResponse(result)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment