From d8ffe6090992f11963529202abe84c89bdd65ea6 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Thu, 7 Nov 2024 08:17:10 +0100 Subject: [PATCH] Add templates --- db.sqlite3 | Bin 0 -> 131072 bytes waiting_room/tasks.py | 10 ++++++--- waiting_room/templates/base.html | 9 ++++++-- .../templates/components/tasks/layout.html | 15 +++++++++++++ .../templates/components/tasks/update.html | 11 ++++++++++ waiting_room/templates/index.html | 5 ++++- waiting_room/templates/progress_bar.html | 20 ------------------ waiting_room/views.py | 13 ++++++++++-- 8 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 db.sqlite3 create mode 100644 waiting_room/templates/components/tasks/layout.html create mode 100644 waiting_room/templates/components/tasks/update.html delete mode 100644 waiting_room/templates/progress_bar.html diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..20fc4fb9884242015c09ebe77067fc90e8c560d7 GIT binary patch literal 131072 zcmeI5TWlNIdB-{8kQ617M^{sgEsLU8yJlsrIJ}D9rd_R9v6c18yS{W|puu!Vj$}H# z$RyIiuP&S0!fM%Z64YH z{m$VGXE+>DS|1V8`;KmY_l00cmwk3f3L=b2wxZ|SX8rBQDslSxIb)GO_ZR!t>SnH5D@ zNoHb-az2|ppUJ{F^%ZR<^SuSJ{fO0(5g>sn1$YubIa zs@Hegx7<9X3duq)|MCQRx@dY*)Vm>kH8#|S{THmX>_L`JZD5P>P z2g!%o*2#?BM~_Wox9wh$WHzs4E{u`~v#pb9y9d3dRjP+{Ii-+JX9|}B zeeEc{Mp;W1GTBRhpJ(afx*a2@NPKIJyFI)r=PR7L;Z<^lT(+?3^Le7Asa&hn$wgWv zp42kU2cn&|Qk%x6x?Ri31RpQl3Yt?GPyi0vM((;(G5LPGNV<4@mF>>l>pYX8nv#+tgXJ2B!PYHZL00ck)1V8`;KmY_l00ck)1V8`; zo)m!@dH$qiJ~(9j^`DZL&PetrB5dD%VR?2|gb{dzK#s_>QIQhi1MjpvyC{;@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FZv|`=(aJOdS`vSR0^}9JN z^|7B`2}Bnbq+dB>!QcVe9FakSl4QE$tweB^V6iGA#kxFXK>Q&TNs#>e9 zRvSB&x;@%R3#gP=X{oI}ifwlfUu-n0_Fl&K9!}ak#1Ko~V{2NaYKcr`GkqetkhZqH z9gjIhP>xn=SME|U)tMz`gxl1sT?46f(Ctc->OMqRqVrsw7S@;h7S^p;zglY0qI12i zwjb>3d`%;@oyq6)On33cvWplkYJU>I%01AFZMDL(=HtO}Sel8hEe4_wmZg1WEyP$w z1`bealyzQfHK}ODbUv$DYcN(RzaiRX@x?MaqU$5qgc`*ZN6!f?#R7a`;GtxV6zkAp zyjV$}%c!w(A8QtIVjdiM_GM6GnzR=(j(YfG1HC$1qcmxovxrK6C+%BINOUeO1fq?! z)cL6W^k^5N(t3hg)rxvmtx?-o)qJj4PM6a~(eN(HW!J`cF&yr>?=)%`#L4tD@zpjV zi#qb==|D7{mi7zwQ>wkBi-!6BrgyP;tme1$9oQ;e)$ZAe&cwWZ#nzCem1~tcpKp6B zwxw(?qZhTD)8Ld*t^TW)gUk29?wRqb^NE@-v?n@ePX(eXEh4{Z?+u6)j5GPD7P6VPQs?5#9Dr3-AwL(_c%8Knd4rjf8>d4h_`aDVn zj50K5+?%DRJc8@e{_0V+_f=k1GFq;fOQ)=h4B^{ZojIdAF4r5b_PzOY$kE@Mq2!H?xfB*=900@8p2!H?xfWWg)AWT*8v$s9$d+hJnU$HN; zcPN1m2!H?xfB*=900@8p2!H?xfB*=9z!M@c?Uz0CCyifXYZ-q}`ee`28RM5Z`0qls zY~Mq&?3tbAKNG-z(je@mRFtR0zwSRZLdiv*w0?(RQj$H{message}', + 'message': render_to_string('components/tasks/update.html', { + 'progress': progress, + 'result': result, + }), } ) @@ -64,7 +68,7 @@ def calculate_min_distance(group_name): route_distance += distances[perm[-1]][perm[0]] # Back to the start city shortest_route = min(shortest_route, route_distance) - render_progress_bar(group_name, 100) + render_progress_bar(group_name, 100, shortest_route) return shortest_route return calculate_shortest_route(distances) diff --git a/waiting_room/templates/base.html b/waiting_room/templates/base.html index adf3b37..61d5b04 100644 --- a/waiting_room/templates/base.html +++ b/waiting_room/templates/base.html @@ -6,11 +6,16 @@ {% block title %}Waiting Room{% endblock %} +
- {% include 'progress_bar.html' %} -
{% block content %}{% endblock %}
+ {% include 'components/tasks/layout.html' %} + {% block content %}{% endblock %}
diff --git a/waiting_room/templates/components/tasks/layout.html b/waiting_room/templates/components/tasks/layout.html new file mode 100644 index 0000000..38d56f3 --- /dev/null +++ b/waiting_room/templates/components/tasks/layout.html @@ -0,0 +1,15 @@ +
+ {% include 'components/tasks/update.html' %} +
+ diff --git a/waiting_room/templates/components/tasks/update.html b/waiting_room/templates/components/tasks/update.html new file mode 100644 index 0000000..cbf1b57 --- /dev/null +++ b/waiting_room/templates/components/tasks/update.html @@ -0,0 +1,11 @@ +
+

Task

+ {% if result %} +

Done!

+ Go to result + {% elif progress %} + {{ progress }} + {% else %} +

Nothing

+ {% endif %} +
diff --git a/waiting_room/templates/index.html b/waiting_room/templates/index.html index 7f924d4..6c81b58 100644 --- a/waiting_room/templates/index.html +++ b/waiting_room/templates/index.html @@ -5,13 +5,16 @@ {% block content %}

Index

+
{% if result %}

The result is {{ result }}

diff --git a/waiting_room/templates/progress_bar.html b/waiting_room/templates/progress_bar.html deleted file mode 100644 index 51ee509..0000000 --- a/waiting_room/templates/progress_bar.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
- -
diff --git a/waiting_room/views.py b/waiting_room/views.py index 8f1fe42..c3b6913 100644 --- a/waiting_room/views.py +++ b/waiting_room/views.py @@ -1,8 +1,17 @@ from django.shortcuts import render +import uuid + +def make_user_id(): + return str(uuid.uuid4()).replace('-', '') def index(request): result = request.GET.get('result', None) - return render(request, 'index.html', {'result': result}) + return render(request, 'index.html', { + 'result': result, + 'user_id': make_user_id(), + }) def about_us(request): - return render(request, 'about_us.html') + return render(request, 'about_us.html', { + 'user_id': make_user_id(), + })