Skip to content

Commit

Permalink
Limpiando algunas esquinas más
Browse files Browse the repository at this point in the history
  • Loading branch information
josjimjim committed Apr 24, 2017
1 parent 7d3fcd0 commit 98d80f3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ def ajax_profit_per_date(request, department_id):
# Profit
# for each date, we will find all logs, calculate the sum and acumulate it
index = 0
for logDate in dates:
for log_date in dates:
logs = TimeLog.objects.filter(task_id__projectDepartment_id__department_id_id=department_id,
workDate__year=logDate.year, workDate__month=logDate.month,
workDate__day=logDate.day).distinct()
workDate__year=log_date.year, workDate__month=log_date.month,
workDate__day=log_date.day).distinct()
expenses = logs.aggregate(total_expenses=Sum(F("duration")/60.0*F("employee_id__price_per_hour"), output_field=FloatField()))["total_expenses"]
expenses = expenses if expenses is not None else 0
income = logs.aggregate(total_income=Sum(F("task_id__price_per_unit")*F("produced_units")))["total_income"]
Expand Down
22 changes: 11 additions & 11 deletions Metronus-Project/metronus_app/controllers/employeeController.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ def ajax_productivity_per_task_and_date(request, username):

# Save productivity for each date
# for each date, we will find the asociated timelog
for logDate in dates:
log = TimeLog.objects.filter(task_id=task.id, workDate__year=logDate.year, workDate__month=logDate.month,
workDate__day=logDate.day, employee_id=employee).first()
for log_date in dates:
log = TimeLog.objects.filter(task_id=task.id, workDate__year=log_date.year, workDate__month=log_date.month,
workDate__day=log_date.day, employee_id=employee).first()
if log is None:
# He did not work that day
total_productivity = 0
Expand All @@ -446,10 +446,10 @@ def ajax_productivity_per_task_and_date(request, username):

# Find the registry date of production goal evolution which is closest to the date
expected_productivity = GoalEvolution.objects.filter(task_id_id=task.id,
registryDate__gte=logDate).first()
registryDate__gte=log_date).first()

# If we do not find the goal or if the date is after the last task update, it may be the current task goal
if expected_productivity is None or task.registryDate <= logDate:
if expected_productivity is None or task.registryDate <= log_date:
expected_productivity = task.production_goal
else:
expected_productivity = expected_productivity.production_goal
Expand Down Expand Up @@ -522,10 +522,10 @@ def ajax_profit_per_date(request, employee_id):
# Profit
# for each date, we will find all logs, calculate the sum and acumulate it
index = 0
for logDate in dates:
for log_date in dates:
logs = TimeLog.objects.filter(employee_id=employee_id,
workDate__year=logDate.year, workDate__month=logDate.month,
workDate__day=logDate.day).distinct()
workDate__year=log_date.year, workDate__month=log_date.month,
workDate__day=log_date.day).distinct()
expenses = logs.aggregate(
total_expenses=Sum(F("duration") / 60.0 * F("employee_id__price_per_hour"), output_field=FloatField()))[
"total_expenses"]
Expand Down Expand Up @@ -608,11 +608,11 @@ def ajax_profit_per_date_in_project(request, employee_id, project_id):
# Profit
# for each date, we will find all logs, calculate the sum and acumulate it
index = 0
for logDate in dates:
for log_date in dates:
logs = TimeLog.objects.filter(employee_id=employee_id,
employee_id__projectdepartmentemployeerole__projectDepartment_id__project_id=project_id,
workDate__year=logDate.year, workDate__month=logDate.month,
workDate__day=logDate.day).distinct()
workDate__year=log_date.year, workDate__month=log_date.month,
workDate__day=log_date.day).distinct()
expenses = logs.aggregate(
total_expenses=Sum(F("duration") / 60.0 * F("employee_id__price_per_hour"), output_field=FloatField()))[
"total_expenses"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def login(request, template_name='registration/login.html',
return HttpResponseRedirect("/timeLog/list_all")
else:
return HttpResponseRedirect("/app/")
# return HttpResponseRedirect(_get_login_redirect_url(request, redirect_to))
else:
form = authentication_form(request)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ def ajax_profit_per_date(request, project_id):
# Profit
# for each date, we will find all logs, calculate the sum and acumulate it
index = 0
for logDate in dates:
for log_date in dates:
logs = TimeLog.objects.filter(task_id__projectDepartment_id__project_id=project_id,
workDate__year=logDate.year, workDate__month=logDate.month,
workDate__day=logDate.day).distinct()
workDate__year=log_date.year, workDate__month=log_date.month,
workDate__day=log_date.day).distinct()
expenses = logs.aggregate(total_expenses=Sum(F("duration")/60.0*F("employee_id__price_per_hour"), output_field=FloatField()))["total_expenses"]
expenses = expenses if expenses is not None else 0
income = logs.aggregate(total_income=Sum(F("task_id__price_per_unit")*F("produced_units")))["total_income"]
Expand Down

0 comments on commit 98d80f3

Please sign in to comment.