From 61ad627f98458776e22a6bf1ef03740f6a3bbf80 Mon Sep 17 00:00:00 2001 From: Adam Drake <drakeadam02@gmail.com> Date: Thu, 2 May 2024 01:10:37 +0100 Subject: [PATCH] ai dashboard foundation --- .../__pycache__/urls.cpython-310.pyc | Bin 787 -> 834 bytes .../__pycache__/views.cpython-310.pyc | Bin 6666 -> 7207 bytes .../templates/prediction_service/home-AI.html | 37 ++++++++++++++++ .../templates/prediction_service/home.html | 2 +- prediction_service/urls.py | 1 + prediction_service/views.py | 41 ++++++++++++++---- 6 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 prediction_service/templates/prediction_service/home-AI.html diff --git a/prediction_service/__pycache__/urls.cpython-310.pyc b/prediction_service/__pycache__/urls.cpython-310.pyc index 406367e661d8f47678e9558094ac176faa799321..ea10bfd9f4249a2e49a846eeaf1fa474d1f635bc 100644 GIT binary patch delta 158 zcmbQtc8E<opO=@5fq{Wx?Ioi$GiC;c#~=<e=4D`DaA06yC_XY#d!s}uV~Rv7a~6M! zWC~|5b2?{~K#Ei_gQoPvXJ5qFGxBp&6EpRzczk^v9fNg2Tu0BzHyNE71t-fgRdPhJ kL4~F<#Vg1#Ffi~i@G$Z)@i2<9@PSB1J|;d!2;}$*06>}`9{>OV delta 110 zcmX@aHknO3pO=@5fq{V`r^+bpFB1d9V-N=!^Dr<lI503U6mOfTy^$-OBZ@yoBA7u_ xa^jaSlm9b1F$zp}Vyc{cm?>UPih+TFhk=KYhlz(#jD-(GGV(F;F@hk+HvofG6R-dP diff --git a/prediction_service/__pycache__/views.cpython-310.pyc b/prediction_service/__pycache__/views.cpython-310.pyc index e9aa17e3345c700c626306adbe7ced8b8388f99c..e6336417a5b6bdf19b05b40494f4f6ed9448aeec 100644 GIT binary patch delta 2396 zcmeA&S#H6X&&$ijz`($8_oh)=xZ*@U8OEB4+Qnh194S00ye$mPj8TFqd@1}b3{gTU z3@OYxthsDaY>W&ktSM|coVi?4Twu094tK6_lyI&{lt`{<lqe%ZieQRR3qz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0AeJhK0J-NDTViQRMt)I|K1f7*5|6mMCWr<0iwTHj03yI1VupAK zWb7@Lg8bqV^u)srNrmwsx#-DpJgSTqn_GAmGBQeTR^yw`$Y?X!QAlO-EB+Qnr^yrf zTqbW8u!697UTz23;>p0k@UnLDMsbbFX@Y@lV6MgFjpCYY_F(DB4@Dd%>j-f{WMn}K z*<a3wNKNE(U;_nRk>})%LdI;N5Ya|K!^zUZB8;As4TRx>nZgd-$snu#fE2k+HWbzK zNdoczf{3>u;yg$u3r=K!SYYS;0?B>=aRWfCeh@1L!~zB8%a<T-_T-6tGLr)Y#Z}5d z5*tBcg_y)kkd;M&AjLc{(?Ied3yR!90+Ry-#U?lKIZjp(WrKLO6G_;Ky9B2Er6saB zW65L%u{tE#1Y}u+c##XHILNJN;*~I4z~V}iJtTM-t0sp^)G{hhzAO>WV+qP3Ecpeg zc}1#|%_Q|yz}W(nd2TTmmlWM%%So(EEh;VoCmudX;xU=rA?dGI3)0D+o0FTLlA066 z1y+}wUz&%WqKYOkFff!)W|c~11F<wUCKpJph!qC8OB6(a3qVMj2jXghj1^AFO3X{o z*GtaND=ErM(gUUMB2Z>70%uJ_kV0^7umGuM$}cWzW?*25V$CbfEvPJNm|P_-U*7~4 z$t}o9F}}qd;OSEY@@i2#NGr%4Na-Gti8*X?^HWN5QtdzmWw8sW$Y%g$U>-&uHXbGr ti;0Pgk%Nneg@;juk%LJ<f`>_fQ2>;!nRvu_7{Ri_9E=={Jd<T)xB<I@q#^(S diff --git a/prediction_service/templates/prediction_service/home-AI.html b/prediction_service/templates/prediction_service/home-AI.html new file mode 100644 index 0000000..bd04034 --- /dev/null +++ b/prediction_service/templates/prediction_service/home-AI.html @@ -0,0 +1,37 @@ +{% include "prediction_service/base.html" %} +{% include "prediction_service/navbar.html" %} + +{% block content %} + + <br> + + <div class="container"> + <h1>AI Engineer Dashboard!</h1> + <div class="row col-sm-12"> + {% for post in posts %} + <div class="card" style="width: 18rem; margin-right: 15px;"> + <div class="card-body"> + <h5 class="card-title">{{post.title}} ID: {{post.mlmodel.id}}</h5> + <h6 class="card-subtitle mb-2 text-muted">By {{ post.author }} on {{ post.date_posted }}</h6> + <p class="card-text">{{ post.content }}</p> + <a href="/mlmodel/{{post.mlmodel.id}}" class="card-link">Ml-Model</a> + <a href="#" class="card-link">Inspect Model</a> + </div> + </div> + {% endfor %} + </div> + + + </div> + + <!-- Square plus button --> + <div style="position: fixed; bottom: 20px; right: 20px;"> + <a href="{% url 'MLAAS-create_post' %}"> + <button style="width: 50px; height: 50px; border-radius: 50%; background-color: #007bff; color: white; font-size: 24px; border: none;">+</button> + </a> + </div> + + + + +{% endblock content %} \ No newline at end of file diff --git a/prediction_service/templates/prediction_service/home.html b/prediction_service/templates/prediction_service/home.html index 3f08283..160d379 100644 --- a/prediction_service/templates/prediction_service/home.html +++ b/prediction_service/templates/prediction_service/home.html @@ -15,7 +15,7 @@ <h6 class="card-subtitle mb-2 text-muted">By {{ post.author }} on {{ post.date_posted }}</h6> <p class="card-text">{{ post.content }}</p> <a href="/mlmodel/{{post.mlmodel.id}}" class="card-link">Ml-Model</a> - <a href="#" class="card-link">Another link</a> + </div> </div> {% endfor %} diff --git a/prediction_service/urls.py b/prediction_service/urls.py index 85f499e..2dd9b36 100644 --- a/prediction_service/urls.py +++ b/prediction_service/urls.py @@ -14,6 +14,7 @@ urlpatterns = [ path('about/', views.about, name='MLAAS-about'), path('home/', views.home, name='MLAAS-home'), + path('homeai/', views.homeAI, name='MLAAS-homeAI'), path('mlmodel/<str:pk>/', views.mlmodel, name='MLAAS-model'), path('create_post/', views.create_post, name='MLAAS-create_post'), ] diff --git a/prediction_service/views.py b/prediction_service/views.py index 62349c9..852e7a0 100644 --- a/prediction_service/views.py +++ b/prediction_service/views.py @@ -23,6 +23,27 @@ def home(request): context['posts'] = Post.objects.all()#loads all posts from Post table into the context return render(request, 'prediction_service/home.html',context) + +@login_required +def homeAI(request): + if request.user.is_authenticated and request.method == "GET": + user = request.user + #try: + if user.userprofile.role == 'AI Engineer': + context = {'posts':'',} + + context['posts'] = Post.objects.all()#loads all posts from Post table into the context + + return render(request, 'prediction_service/home-AI.html',context) + else: + return HttpResponse(f"<h1> You are logged in and not an AI engineer! you are a {user.userprofile.role}</h1>") + # except: + # return HttpResponse("<h1> youre in the except for some reason </h1>") + + else: + return HttpResponse("<h1> you are not authenticated but are logged in? </h1>") + + def about(request): return render(request, 'prediction_service/about.html', {'title':'About'}) @@ -70,14 +91,18 @@ def MLAAS_login(request): user = authenticate(request, username=username, password=password) if user is not None: - if user.userprofile.role == 'ai_engineer': - ai_engineer = AIEngineer.objects.get(user=user.userprofile) - if not ai_engineer.is_authorized: - messages.error(request, 'You are not authorized to access the MLaaS system. Please wait for admin authorization.') - return redirect('MLAAS-login') # Redirect to login page - - login(request, user) - return redirect('MLAAS-home') + try: + if user.userprofile.role == 'ai_engineer': + ai_engineer = AIEngineer.objects.get(user=user.userprofile) + if not ai_engineer.is_authorized: + messages.error(request, 'You are not authorized to access the MLaaS system. Please wait for admin authorization.') + return redirect('MLAAS-login') # Redirect to login page + + login(request, user) + return redirect('MLAAS-home') + except: + messages.error(request, 'user has no userprofile.') + return redirect('MLAAS-login') # Redirect to login else: messages.error(request, 'Invalid username or password.') -- GitLab