From f228cf2c567ccb0542c835886aedd0eb672c4061 Mon Sep 17 00:00:00 2001 From: emile Date: Sat, 23 Sep 2023 21:27:35 +0300 Subject: [PATCH] New improvements --- osinaweb/db.sqlite3 | Bin 421888 -> 421888 bytes .../custom_context.cpython-310.pyc | Bin 924 -> 1329 bytes .../__pycache__/views.cpython-310.pyc | Bin 19513 -> 19537 bytes osinaweb/osinacore/custom_context.py | 28 +++++++++++++++++- osinaweb/osinacore/views.py | 6 ++-- osinaweb/templates/index.html | 2 +- osinaweb/templates/main.html | 2 +- 7 files changed, 32 insertions(+), 6 deletions(-) diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 88b9e3a11b0e9a2a4008dc3ebc2da8f26295e673..96498fa7aa9c328b1ec21de952ff279800550fae 100644 GIT binary patch delta 1237 zcmah|ZERCj7(VBo`(Z!seXW@k*t*`bIw7Xx_V%`GD+z29#()Wd%#ZnFT}BIzcI{Z3 z2#IcyAA}z)Dlzw$j6{$hBu-Yw6^YK6nfV1S5vmSk1w;Jahg(R5NIY$ExWt5^l+j`RN=}b>mcHE=w zC2sSDBf_yp#(W`LC%?O2)=|j;RTST>(VJHB!xtOX=UpayJ*xpNC+41e$q%+lEe7HVq~%) zW;NOBgpa8BAw+G?Q`05OIcoR|7=`y?$dDCs^q#6u){?bO7^VDk2=2fw_zm)KnKDOU z25!Oxd=2Lec^x@^kN??LvZiEq8<_^M95q*0>12iEk$d^Xb;})CC1%e zmXEjrhD-0w!td}CZORYu9ee{9;d82S1U`UaI87UK5cI)mme-%1ChPUv)2!JI;toVR zk%D@VqzUPyl#w<{mExTEt$1F1OMFG#Ath;yPl&y%s(7^8*dBu$8Cto@eV=6X|waErgp4YG&mtS8u&uU1ua z%?DcQ9`xsqMBX^FX^-}l8cqgdZF@3L*L%_pt-j6;n>(8PZT_asiPl}u1vg}#Nqgg) zwx=4pL$&LhikklS6B&aX=W4b2{`i6~wx5 YmdXi+RexBktqJ-=il!Rnz~7Ag1A0zfQvd(} delta 824 zcmah{TS!z<6g_9oy>pwZ_pXd#2J>}IrJ%;f@i`Xwh$y1af{5xvMWiIq@zt;X`K2Tw z_b-JcKZGWo?37VPm_&vNsgxOxh7>(~Bc&vraRfhO!TLC?z4uyspQd1RQ!x5g3>|2T zJwXS0OE0^e!*+wYXmwp>Ratp;ZAD34eOY}&U3_57l~K!*)Ro&x=czz}(WOes>>M?@ zEE@qw&%zoTmK87N;aLO3kSm z%fV2Mh7N*1SiyIE!6%I4t|8p~vtBLwJtI+;FoyJFZ^lvAnSU3Be}T@dH6j2<0G_ zFpnv`!w@&}S=WyKbrCxr4qMEYfzV8mRSSis*x*VjTZI-{qkZ?yC*HPq(7e^i_*SE2 zElpN28lJa|pZF>qe#Qs9$0&MtAr8|F)4wRzyjS!;13@QsLHU}XW08WgOy43qVs0!- zYO<=W5^*CR3Zd&$dbi%7pVs5GRlRx_f%Co*jj#TdqAU)Z>?it^_As(F;<{RBi&fUG z6S7}?p>~=3WjXOml*dTR&dtooP4}i|r+IU7GWl$YoYF+yrV^A>sat3_B2x}KZN!;K zNg|1>sHiEgxl~aeLBTZm-MZ;TM0&{(UM#48c8|MT`iifycl)U-}QT CWc2O; diff --git a/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc b/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc index 40d3483793d8c39b113c22363a3584369d0d7de8..946c4b971d6e667cf64863dfa3a60fefc3d107a4 100644 GIT binary patch literal 1329 zcmcIkOOGQp5caDdNjj74z`_8RxeQB?m|RzAK_Ivw!Hz^gNX;SYw4K43?snF8Ysjc0 zApsYp{RbS96Y!UOu8V>si*44Ws@j(xvKRt822rwVP zHcx?Y#BqU2oZ^zC1S3v3EojM7)}C1rltCJlVHyG-@bD*;Mm(CKNqmpNd_o-iDl<1O zoY~CQ<{mIK!EX3*rK(M-YV)-b8nj}bSz%=Mw17H)!Z8;lZA48F0fr z+9ez`Xk^Tn$|BpyR9&a&h!hJ<>LtaPQ*w<_K3RL1%-rHlCh5pav4YchwaYLJ4 z6Y;^X40@eBckF5{DrjtI+CJa)zft-|R@diO9t{9pF7M)t&)&cI;{0NL{|veaT_0q| z$m>e*xm6lw5oreGj=m@Ped1M^8(3wtVs2rGj2jf0vGdM_8x=4z53B%bDXSWwd3LQP zj~%OFwA@$%U)%3QWn~Tq+$DgRdM&h1bm#>!9M&?#iDSr(p>2I zVl(NxNQ)OWB$SR6)UwTZ-iDDrzU_)RSI4j(K@jPntH#_%kS2MpHDuaxBah9wTrLHG zxzLZmK%aOr2J#2e7x4Kjo%(;!OhpO#iK37jG5u7S8>`mSSyssM{PS$>nJXhLBsNt> zR#``H#iBdpN{eY;8>>nPy0YSXd%51YUTtL|trR8zSM7^3rl zhnSqJ`=~u?EvMZv4@D>!odp!+Gn*N6lG2qq z2bsUpozBPrBc%uiB;^TB*d|HE*bK$Yo|Bma=9~fn>ycGSDie|LM8evXqft9QWA#0s z6;3~n2iKzjdgDl$=uc_4_q;iPUl%K%=kKh+d^i7L7aIld4~K;nDF{^Wa^f5L3vZXT zPC1%9q&K3fxhKM=UKH1mO1wEhdrb8nDmD)_3cL9Q`~%2Ji5uH#U=Tb82sy=(Q*M7wDAP$am}&BPQP#~1#5bA% E0J6Ccxc~qF diff --git a/osinaweb/osinacore/custom_context.py b/osinaweb/osinacore/custom_context.py index a5fc332d..01241d8c 100644 --- a/osinaweb/osinacore/custom_context.py +++ b/osinaweb/osinacore/custom_context.py @@ -1,5 +1,6 @@ from .models import Task, Status from django.contrib.auth.models import AnonymousUser +from datetime import datetime, timedelta def utilities(request): @@ -8,10 +9,35 @@ def utilities(request): 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() 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) else: # Handle the case when the user is not logged in open_task_count = 0 @@ -21,4 +47,4 @@ def utilities(request): total_tasks = open_task_count + working_on_task_count latest_statuses = Status.objects.all().order_by('-id')[:12] - return {'total_tasks': total_tasks, 'last_status' : last_status, 'latest_statuses' : latest_statuses, } + return {'total_tasks': total_tasks, 'last_status' : last_status, 'latest_statuses' : latest_statuses, 'minutes_ago' : minutes_ago, } diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index 6950dee3..7af7dc20 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -107,7 +107,7 @@ def my_tasks(request, *args, **kwargs): @login_required def customers(request, *args, **kwargs): - customers = CustomerProfile.objects.all().order_by('-id') + customers = CustomerProfile.objects.all().order_by('-customer_id') context = { 'customers' : customers, @@ -237,7 +237,7 @@ def businessdetails(request, business_id): @login_required def businesses(request): - businesses = Business.objects.all().order_by('-id') + businesses = Business.objects.all().order_by('-business_id') context = { 'businesses' : businesses, @@ -286,7 +286,7 @@ def staff_positions(request): @login_required def staffs(request): - staffs = StaffProfile.objects.all().order_by('-id') + staffs = StaffProfile.objects.all().order_by('-staff_id') context = { 'staffs' : staffs, diff --git a/osinaweb/templates/index.html b/osinaweb/templates/index.html index 2f9da78f..4fcfb8b7 100644 --- a/osinaweb/templates/index.html +++ b/osinaweb/templates/index.html @@ -33,7 +33,7 @@ id="notesContainer"> {% for note in notes %} -
+

{{note.text}}

{% endfor %} diff --git a/osinaweb/templates/main.html b/osinaweb/templates/main.html index 2de178f6..299892a7 100644 --- a/osinaweb/templates/main.html +++ b/osinaweb/templates/main.html @@ -219,9 +219,9 @@
-

Your last update: 2023-08-31 08:13:31, 32 mins ago

Recent Status: {{last_status.text}}

+

Last update: {{last_status.date}} | {{last_status.time}}, {% if minutes_ago == 0 %} Just Now {%else%} {{minutes_ago}} mins ago {%endif%}