diff --git a/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc index bb1d3cc2..3a6cf4df 100644 Binary files a/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index 410b0423..856ad4e7 100644 Binary files a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/templates/details_templates/timeline-modal.html b/osinaweb/osinacore/templates/details_templates/timeline-modal.html index 2d157bce..5552f777 100644 --- a/osinaweb/osinacore/templates/details_templates/timeline-modal.html +++ b/osinaweb/osinacore/templates/details_templates/timeline-modal.html @@ -2,6 +2,7 @@ + @@ -16,110 +17,43 @@

Timeline

-
- -
-
-

Task Time: 560 minutes

-
-
-

User

-
-
-

Date

-
-
-

Total Time

-
-
- - -
- -
-
- -
-
-

Nataly

-
-
-

6-9-2023

-
-
-

360 minutes

-
-
- - -
-
- -
-
-

Salim

-
-
-

12-9-2023

-
-
-

200 minutes

-
-
- - -
-
- -
-
-

Salim

-
-
-

12-9-2023

-
-
-

200 minutes

-
-
- - -
-
- -
-
-

Reine

-
-
-

12-9-2023

-
-
-

200 minutes

-
-
- - -
-
- -
-
-

Nataly

-
-
-

12-9-2023

-
-
-

200 minutes

-
-
-
+
+ + + + + + + + + {% for date, total_hours, total_minutes, total_seconds in formatted_totals %} + + + + + {% endfor %} + +
+ Date + Total Time Worked
{{ date }}

+ {% if total_hours == 1 %} + {{ total_hours }}hr, + {% else %} + {{ total_hours }}hrs, + {% endif %} + {% if total_minutes == 1 %} + {{ total_minutes }}min, + {% else %} + {{ total_minutes }}mins, + {% endif %} + {% if total_seconds == 1 %} + {{ total_seconds }}sec + {% else %} + {{ total_seconds }}secs + {% endif %} +

diff --git a/osinaweb/osinacore/templates/index.html b/osinaweb/osinacore/templates/index.html index 5bbeddba..c3863c56 100644 --- a/osinaweb/osinacore/templates/index.html +++ b/osinaweb/osinacore/templates/index.html @@ -131,7 +131,7 @@ + data-modal-url="{% url 'timeline' task.task_id %}">Timeline
@@ -237,7 +237,7 @@ + data-modal-url="{% url 'timeline' task.task_id %}">Timeline diff --git a/osinaweb/osinacore/urls.py b/osinaweb/osinacore/urls.py index baaa66f6..0dfbc04d 100644 --- a/osinaweb/osinacore/urls.py +++ b/osinaweb/osinacore/urls.py @@ -56,7 +56,7 @@ urlpatterns = [ path('projectdetails//', views.projectdetails, name='detailed-project'), path('tasks//', views.taskdetails, name='detailed-task'), path('show-points//', views.show_points_modal, name='showpoints'), - path('timeline/', views.timeline_modal, name='timeline'), + path('timeline//', views.timeline_modal, name='timeline'), #Fetch urls diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index 98690d3c..07c28e7c 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -352,9 +352,39 @@ def show_points_modal(request, task_id): } return render(request, 'details_templates/showpoints-modal.html', context) -def timeline_modal(request, *args, **kwargs): - context = { + + + + +def timeline_modal(request, task_id): + task = Task.objects.get(task_id=task_id) + point_activities = PointActivity.objects.filter(point__task=task) + # Dictionary to store total time worked on each day + daily_totals = {} + + for activity in point_activities: + date = activity.start_time.date() + hours, minutes, seconds = activity.total_time_in_hours_minutes_seconds() + total_time = timedelta(hours=hours, minutes=minutes, seconds=seconds) + + # Add the total time to the corresponding day's total + if date in daily_totals: + daily_totals[date] += total_time + else: + daily_totals[date] = total_time + + sorted_daily_totals = sorted(daily_totals.items()) + formatted_totals = [] + for date, total_time in sorted_daily_totals: + total_hours = total_time.days * 24 + total_time.seconds // 3600 + total_minutes = (total_time.seconds % 3600) // 60 + total_seconds = total_time.seconds % 60 + formatted_totals.append((date, total_hours, total_minutes, total_seconds)) + context = { + 'task': task, + 'sorted_daily_totals': sorted_daily_totals, + 'formatted_totals':formatted_totals, } return render(request, 'details_templates/timeline-modal.html', context)