diff --git a/.DS_Store b/.DS_Store index 1cafa8f6..ed53ceb8 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/osinaweb/.DS_Store b/osinaweb/.DS_Store index 58a0e6e3..b808fa34 100644 Binary files a/osinaweb/.DS_Store and b/osinaweb/.DS_Store differ diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index db026d21..ff6fbd28 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/.DS_Store b/osinaweb/osinacore/.DS_Store new file mode 100644 index 00000000..2068222b Binary files /dev/null and b/osinaweb/osinacore/.DS_Store differ diff --git a/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc b/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc index e041fb0c..28f6354f 100644 Binary files a/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index 37df28a6..2a5ddbe4 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/custom_context.py b/osinaweb/osinacore/custom_context.py index 426a8c0b..487d3c40 100644 --- a/osinaweb/osinacore/custom_context.py +++ b/osinaweb/osinacore/custom_context.py @@ -4,27 +4,40 @@ from datetime import datetime, timedelta def utilities(request): - minutes_ago = 0 if request.user.is_authenticated and request.user.is_superuser: open_task_count = Task.objects.filter(status='Open').count() working_on_task_count = Task.objects.filter(status='Working On').count() - last_status = Status.objects.filter(staff=request.user.staffprofile).last() - if last_status: - # Convert the 'time' field to a datetime object - status_time = datetime.strptime(last_status.time, '%I:%M %p') - - # Get the current time - current_time = datetime.now().time() - - # Calculate the time difference - time_difference = abs(datetime.combine(datetime.today(), current_time) - datetime.combine(datetime.today(), status_time.time())) - # Get the time difference in minutes - minutes_ago = time_difference.total_seconds() / 60 - minutes_ago = int(minutes_ago) + elif request.user.is_authenticated: open_task_count = Task.objects.filter(assigned_to=request.user.staffprofile, status='Open').count() working_on_task_count = Task.objects.filter(assigned_to=request.user.staffprofile, status='Working On').count() + + + else: + # Handle the case when the user is not logged in + open_task_count = 0 + working_on_task_count = 0 + + + + + total_tasks = open_task_count + working_on_task_count + latest_statuses = Status.objects.all().order_by('-id')[:12] + + + + return {'total_tasks': total_tasks, 'latest_statuses' : latest_statuses,} + + + + +def last_status(request): + minutes_ago = 0 + hours_ago = 0 + hours_minutes_ago = "" + current_date = datetime.now().strftime('%Y-%m-%d') + if request.user.is_authenticated: last_status = Status.objects.filter(staff=request.user.staffprofile).last() if last_status: # Convert the 'time' field to a datetime object @@ -41,12 +54,17 @@ def utilities(request): else: # Handle the case when the user is not logged in - open_task_count = 0 - working_on_task_count = 0 last_status = None - total_tasks = open_task_count + working_on_task_count - latest_statuses = Status.objects.all().order_by('-id')[:12] - current_date = datetime.now().strftime('%Y-%m-%d') + if minutes_ago > 60: + hours_ago = minutes_ago // 60 # Calculate the number of hours + remaining_minutes = minutes_ago % 60 # Calculate the remaining minutes + hours_minutes_ago = f"{hours_ago}hr {remaining_minutes}min ago" + else: + hours_minutes_ago = f"{minutes_ago}min ago" + - return {'total_tasks': total_tasks, 'last_status' : last_status, 'latest_statuses' : latest_statuses, 'minutes_ago' : minutes_ago, 'current_date' : current_date, } + + return {'last_status' : last_status, 'current_date' : current_date, 'minutes_ago' : minutes_ago, 'hours_minutes_ago': hours_minutes_ago,} + + diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index a1f0365e..da61cb70 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -55,7 +55,7 @@ def home(request, *args, **kwargs): else: # Non-superadmin user can only see their assigned tasks - tasks = Task.objects.filter(Q(assigned_to=request.user.staffprofile) & (Q(status='Open') | Q(status='Working On'))) + tasks = Task.objects.filter(Q(assigned_to=request.user.staffprofile) & (Q(status='Open') | Q(status='Working On'))).order_by('-id') # Initialize last_note_color with a default color last_note_color = 'black' @@ -96,8 +96,13 @@ def my_projects(request, *args, **kwargs): @login_required def my_tasks(request, *args, **kwargs): - my_tasks = Task.objects.all().filter(assigned_to=request.user.staffprofile).order_by('-id') - + if request.user.is_superuser: + # Superadmin can see all projects + my_tasks = Task.objects.all().order_by('-id') + else: + # Non-superuser, filter projects where the user is either the manager or a member + my_tasks = Task.objects.all().filter(assigned_to=request.user.staffprofile).order_by('-id') + context = { 'my_tasks' : my_tasks @@ -441,12 +446,24 @@ def timeline_modal(request, *args, **kwargs): } return render(request, 'timeline-modal.html', context) -def update_status_modal(request, *args, **kwargs): + +def update_status_modal(request, *, task_id): + task = get_object_or_404(Task, task_id=task_id) + if request.method == 'POST': + status = request.POST.get('status') + + task.status = status + + + task.save() + context = { + 'task' : task, } return render(request, 'update-status-modal.html', context) + def add_projecttype_modal(request, *args, **kwargs): context = { diff --git a/osinaweb/osinaweb/.DS_Store b/osinaweb/osinaweb/.DS_Store new file mode 100644 index 00000000..e3aa90fe Binary files /dev/null and b/osinaweb/osinaweb/.DS_Store differ diff --git a/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc index cad76087..dec6b68c 100644 Binary files a/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc and b/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc differ diff --git a/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc index 8425a51a..903fb0bf 100644 Binary files a/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinaweb/settings.py b/osinaweb/osinaweb/settings.py index 46b5bcdc..433ebdcf 100644 --- a/osinaweb/osinaweb/settings.py +++ b/osinaweb/osinaweb/settings.py @@ -66,6 +66,7 @@ TEMPLATES = [ 'OPTIONS': { 'context_processors': [ 'osinacore.custom_context.utilities', + 'osinacore.custom_context.last_status', 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', diff --git a/osinaweb/osinaweb/urls.py b/osinaweb/osinaweb/urls.py index 3fd4bcbe..553d413c 100644 --- a/osinaweb/osinaweb/urls.py +++ b/osinaweb/osinaweb/urls.py @@ -62,7 +62,7 @@ urlpatterns = [ path('addnote/', views.add_note_modal, name='addnote'), path('addfile/', views.add_file_modal, name='addfile'), path('addcredentials/', views.add_credentials_modal, name='addcredentials'), - path('updatestatus/', views.update_status_modal, name='updatestatus'), + path('updatestatus//', views.update_status_modal, name='updatestatus'), path('addpoint//', views.add_point_modal, name='addpoint'), path('showpoints//', views.show_points_modal, name='showpoints'), path('addtime/', views.add_time_modal, name='addtime'), diff --git a/osinaweb/static/images/Screenshot_2023-09-25_at_1.47.42_PM.png b/osinaweb/static/images/Screenshot_2023-09-25_at_1.47.42_PM.png new file mode 100644 index 00000000..db2cda85 Binary files /dev/null and b/osinaweb/static/images/Screenshot_2023-09-25_at_1.47.42_PM.png differ diff --git a/osinaweb/templates/index.html b/osinaweb/templates/index.html index 4fcfb8b7..7744b60f 100644 --- a/osinaweb/templates/index.html +++ b/osinaweb/templates/index.html @@ -146,7 +146,7 @@ class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Close - + \ No newline at end of file