diff --git a/prediction_service/__pycache__/urls.cpython-310.pyc b/prediction_service/__pycache__/urls.cpython-310.pyc index 406367e661d8f47678e9558094ac176faa799321..ea10bfd9f4249a2e49a846eeaf1fa474d1f635bc 100644 Binary files a/prediction_service/__pycache__/urls.cpython-310.pyc and b/prediction_service/__pycache__/urls.cpython-310.pyc differ diff --git a/prediction_service/__pycache__/views.cpython-310.pyc b/prediction_service/__pycache__/views.cpython-310.pyc index e9aa17e3345c700c626306adbe7ced8b8388f99c..e6336417a5b6bdf19b05b40494f4f6ed9448aeec 100644 Binary files a/prediction_service/__pycache__/views.cpython-310.pyc and b/prediction_service/__pycache__/views.cpython-310.pyc differ 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 0000000000000000000000000000000000000000..bd040344d32f871288dcf0d8caa8f8ff521afb44 --- /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 3f08283350cc74d1571e4357245852b1e200f182..160d3793a66dc192026da5ac9164fc1493a159ac 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 85f499e7e99f687a797f3919ea28aff2938bf614..2dd9b3615771559a4081b3fc3f8608daac2c07e0 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 62349c948b55986e5e88cac19b0e9f81491b1121..852e7a004aee49556b8bbd2901dcfa970f47bdf5 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.')