diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index ff815cec..b0d350e6 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc index 4f212282..3d5378ad 100644 Binary files a/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc index bc039f7e..c6dce4e3 100644 Binary files a/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/edit/urls.py b/osinaweb/osinacore/edit/urls.py index f2390bf2..b2b65e8c 100644 --- a/osinaweb/osinacore/edit/urls.py +++ b/osinaweb/osinacore/edit/urls.py @@ -24,5 +24,5 @@ urlpatterns = [ path('mark_point_completed///', views.mark_point_completed, name='mark_point_completed'), path('mark_point_completed_task_page///', views.mark_point_completed_task_page, name='mark_point_completed_task_page'), path('mark_point_paused///', views.mark_point_paused, name='mark_point_paused'), - + path('mark_point_paused_task_page///', views.mark_point_paused, name='mark_point_paused_task_page'), ] \ No newline at end of file diff --git a/osinaweb/osinacore/edit/views.py b/osinaweb/osinacore/edit/views.py index f898fc53..c50bf020 100644 --- a/osinaweb/osinacore/edit/views.py +++ b/osinaweb/osinacore/edit/views.py @@ -457,6 +457,32 @@ def mark_point_paused(request, point_id, task_id): +@login_required +def mark_point_paused_task_page(request, point_id, task_id): + task = get_object_or_404(Task, id=task_id) + point = get_object_or_404(Point, id=point_id) + point.status = 'Paused' + current_datetime = datetime.now() + + point.save() + + last_activity = PointActivity.objects.filter(point=point).last() + if last_activity: + last_activity.end_time = timezone.make_aware(current_datetime, timezone.get_current_timezone()) + last_activity.save() + + status_text = f'{point.text} - Paused' + status = Status(text=status_text, date=current_datetime.date(), time=current_datetime.strftime("%I:%M %p"), staff=request.user.staffprofile) + status.save() + + + task_id_str = task.task_id + + showpoints_url = reverse('showpoints', args=[task_id_str]) + return HttpResponseRedirect(showpoints_url) + + + @login_required def mark_point_completed(request, point_id, task_id): task = get_object_or_404(Task, id=task_id) @@ -491,9 +517,7 @@ def mark_point_completed(request, point_id, task_id): status = Status(text=status_text, date=current_datetime.date(), time=current_datetime.strftime("%I:%M %p"), staff=request.user.staffprofile) status.save() - task_id_str = task.task_id - showpoints_url = reverse('showpoints', args=[task_id_str]) - return HttpResponseRedirect(showpoints_url) + return redirect('detailed-task', task_id=task.task_id) @@ -502,18 +526,32 @@ def mark_point_completed_task_page(request, point_id, task_id): task = get_object_or_404(Task, id=task_id) point = get_object_or_404(Point, id=point_id) point.status = 'Completed' - current_datetime = datetime.now() + current_datetime = datetime.now() point.save() - + # Update the end time of the last activity to the current time last_activity = PointActivity.objects.filter(point=point).last() - last_activity.end_time = datetime.now() - last_activity.save() + if last_activity: + last_activity.end_time = timezone.make_aware(current_datetime, timezone.get_current_timezone()) + last_activity.save() + + total_time_hours, total_time_minutes, total_time_seconds = point.total_activity_time() + + formatted_time = "" + if total_time_hours > 0: + formatted_time += f"{total_time_hours}{'hr' if total_time_hours == 1 else 'hrs'}" + if total_time_minutes > 0: + formatted_time += f" {total_time_minutes}{'min' if total_time_minutes == 1 else 'mins'}" + if total_time_seconds > 0: + formatted_time += f" {total_time_seconds}{'sec' if total_time_seconds == 1 else 'secs'}" status_text = f'{point.text} - Completed' + if formatted_time: + status_text += f' in {formatted_time}' + status = Status(text=status_text, date=current_datetime.date(), time=current_datetime.strftime("%I:%M %p"), staff=request.user.staffprofile) status.save() diff --git a/osinaweb/osinacore/templates/add-edit-main.html b/osinaweb/osinacore/templates/add-edit-main.html index 6c117e33..f21b2bcd 100644 --- a/osinaweb/osinacore/templates/add-edit-main.html +++ b/osinaweb/osinacore/templates/add-edit-main.html @@ -585,7 +585,7 @@
-

Tasks

+

Tasks

-

Projects

+

Projects

-

Tickets

+

Tickets

- {% if task.status == 'Open' %} -
-

{{task.name}}

-
- {% endif %} - {% if task.status == 'Working On' %} -
-

{{task.name}}

-
- {% endif %} - {% if task.status == 'Closed' %} -
+ +

{{task.name}}

- {% endif %} -
+ +
+
+ +

Total Time: {{ task.total_task_time.0 }}{% if task.total_task_time.0 == 1 %}hr{% else %}hrs{% endif %} {{ task.total_task_time.1 }}{% if task.total_task_time.1 == 1 %}min{% else %}mins{% endif %} {{ task.total_task_time.2 }}{% if task.total_task_time.2 == 1 %}sec{% else %}secs{% endif %}

+ +
+
-
- - - - - - - - - - - - +
{% if points %} {% for point in points %} -
- - - {% if point.status == 'Not Completed' %} - - {% endif %} - - {% if point.status == 'Completed' %} - - {% endif %} - - {% if point.status == 'Working On' %} - - {% endif %} - + + +
+
+

Total Time: + + {{ point.total_activity_time.0 }} hours, + {{ point.total_activity_time.1 }} minutes, + {{ point.total_activity_time.2 }} seconds + +

+
+ +
+ {% if point.status == 'Completed' %} +

Completed

+ {% elif point.status == 'Working On' %} +

Working On

+ {% elif point.status == 'Paused' %} +

Paused

+ {% else %} +

Created

+ {% endif %} +
+
+ {% endfor %} {% else %} @@ -200,96 +217,10 @@ - - -
-
-
-
-

Timline

-
- - -
- -
-
- Point - - Status -
-

{{point.text}}

-
-
-
- {% csrf_token %} - -
-
- {% csrf_token %} - -
-
- {% csrf_token %} - -
+ +
+
+
+ {% if point.status == 'Completed' %} +

{{point.text}}

+ {% else %} +

{{point.text}}

+ {% endif %}
-
- - -
+
+ {% if point.status == 'Not Completed' or point.status == 'Paused' and not point.status == 'Completed' %} + + + + {% endif %} + + {% if point.status == 'Working On' and not point.status == 'Completed' %} + + + + {% endif %} + + {% if not point.status == 'Completed' and not point.status == 'Paused' %} + + + + {% endif %} + + + {% if point.status == 'Completed' %} -
+ class="w-[40px] h-[40px] rounded-full bg-transparent shadow-md text-white border border-white flex justify-center items-center opacity-30 cursor-default"> + + + {% endif %} + + {% if not point.status == 'Completed' %} + {% csrf_token %} -
-
- {% csrf_token %} -
+ {% endif %}
-
- - - - - - - - - - - - - - - - - - - - - - - - -
- Task Time: 300 min - - User - - Date - - Total Time -
- - - Nataly - - 6-9-2023 - - 50min -
-
-
-
- - - - -
-

Description:

-
-

- {{task.description}} -

-
-
- - - -
+

Tags:

-
+
@@ -308,7 +239,7 @@ -