emile 1 year ago
parent 63a33b850d
commit ab9905d1ab

@ -2,6 +2,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -16,110 +17,43 @@
<div id="hiddenContent">
<h1 class="text-secondosiblue text-2xl font-semibold text-center mb-2">Timeline</h1>
<div class="w-full border-t border-x border-gray-300 rounded-t-md">
<!-- HEADER -->
<div class="w-full h-[60px] flex items-center justify-between">
<div class="w-[30%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">Task Time: <span class="text-sm text-gray-500">560 minutes</span></p>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">User</p>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">Date</p>
</div>
<div class="w-[20%] h-full flex justify-center items-center">
<p class="text-sm">Total Time</p>
</div>
</div>
<!-- BODY -->
<div class="w-full border-t border-gray-300">
<!-- 1ST ROW -->
<div class="w-full h-[50px] flex justify-between items-center border-b border-gray-300">
<div class="w-[30%] h-full border-r border-gray-300 flex justify-center items-center">
<button
class="w-fit py-1 px-3 bg-red-500 border border-red-500 text-white text-base rounded-md">Delete</button>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">Nataly</p>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">6-9-2023</p>
</div>
<div class="w-[20%] h-full flex justify-center items-center">
<p class="text-sm">360 minutes</p>
</div>
</div>
<!-- 2ND ROW -->
<div class="w-full h-[50px] flex justify-between items-center border-b border-gray-300">
<div class="w-[30%] h-full border-r border-gray-300 flex justify-center items-center">
<button
class="w-fit py-1 px-3 bg-red-500 border border-red-500 text-white text-base rounded-md">Delete</button>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">Salim</p>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">12-9-2023</p>
</div>
<div class="w-[20%] h-full flex justify-center items-center">
<p class="text-sm">200 minutes</p>
</div>
</div>
<!-- 3RD ROWS -->
<div class="w-full h-[50px] flex justify-between items-center border-b border-gray-300">
<div class="w-[30%] h-full border-r border-gray-300 flex justify-center items-center">
<button
class="w-fit py-1 px-3 bg-red-500 border border-red-500 text-white text-base rounded-md">Delete</button>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">Salim</p>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">12-9-2023</p>
</div>
<div class="w-[20%] h-full flex justify-center items-center">
<p class="text-sm">200 minutes</p>
</div>
</div>
<!-- 4TH ROW -->
<div class="w-full h-[50px] flex justify-between items-center border-b border-gray-300">
<div class="w-[30%] h-full border-r border-gray-300 flex justify-center items-center">
<button
class="w-fit py-1 px-3 bg-red-500 border border-red-500 text-white text-base rounded-md">Delete</button>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">Reine</p>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">12-9-2023</p>
</div>
<div class="w-[20%] h-full flex justify-center items-center">
<p class="text-sm">200 minutes</p>
</div>
</div>
<!-- 5TH ROW -->
<div class="w-full h-[50px] flex justify-between items-center border-b border-gray-300">
<div class="w-[30%] h-full border-r border-gray-300 flex justify-center items-center">
<button
class="w-fit py-1 px-3 bg-red-500 border border-red-500 text-white text-base rounded-md">Delete</button>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">Nataly</p>
</div>
<div class="w-[25%] h-full border-r border-gray-300 flex justify-center items-center">
<p class="text-sm">12-9-2023</p>
</div>
<div class="w-[20%] h-full flex justify-center items-center">
<p class="text-sm">200 minutes</p>
</div>
</div>
</div>
<div class="overflow-x-auto border border-gray-300 rounded-md mt-5">
<table class="min-w-full divide-y">
<thead>
<tr>
<th scope="col"
class="px-6 py-3 text-sm font-medium text-gray-500 uppercase bg-gray-100 border-r border-gray-300 whitespace-nowrap">
Date</th>
<th scope="col"
class="px-6 py-3 text-sm font-medium text-gray-500 uppercasen bg-gray-100 whitespace-nowrap">
Total Time Worked</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
{% for date, total_hours, total_minutes, total_seconds in formatted_totals %}
<tr>
<td class="px-6 py-4 text-center text-sm border-r border-gray-300">{{ date }}</td>
<td class="px-6 py-4 text-center text-sm"> <p>
{% 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 %}
</p></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</body>

@ -131,7 +131,7 @@
<button
class="p-2 border border-gray-200 text-base h-[70px] bg-gray-100 text-gray-500 rounded-br-md timelineButton"
data-modal-url="{% url 'timeline' %}">Timeline</button>
data-modal-url="{% url 'timeline' task.task_id %}">Timeline</button>
</div>
</div>
</div>
@ -237,7 +237,7 @@
</a>
<button class="p-2 border border-gray-200 text-sm h-[70px] bg-gray-100 text-gray-500 timelineButton"
data-modal-url="{% url 'timeline' %}">Timeline</button>
data-modal-url="{% url 'timeline' task.task_id %}">Timeline</button>
</div>
</div>
</div>

@ -56,7 +56,7 @@ urlpatterns = [
path('projectdetails/<str:project_id>/', views.projectdetails, name='detailed-project'),
path('tasks/<str:task_id>/', views.taskdetails, name='detailed-task'),
path('show-points/<str:task_id>/', views.show_points_modal, name='showpoints'),
path('timeline/', views.timeline_modal, name='timeline'),
path('timeline/<str:task_id>/', views.timeline_modal, name='timeline'),
#Fetch urls

@ -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)

Loading…
Cancel
Save