Skip to content
Snippets Groups Projects
Commit 61ad627f authored by Adam Drake's avatar Adam Drake
Browse files

ai dashboard foundation

parent fc682dc8
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
{% 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
......@@ -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 %}
......
......@@ -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'),
]
......@@ -24,6 +24,27 @@ def home(request):
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,6 +91,7 @@ def MLAAS_login(request):
user = authenticate(request, username=username, password=password)
if user is not None:
try:
if user.userprofile.role == 'ai_engineer':
ai_engineer = AIEngineer.objects.get(user=user.userprofile)
if not ai_engineer.is_authorized:
......@@ -78,6 +100,9 @@ def MLAAS_login(request):
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.')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment