Skip to content
Snippets Groups Projects
Commit 8e26bf1a authored by a272-jones's avatar a272-jones
Browse files

1) added more database stuff (mlModel, Billings, Interactions, Records). 2)...

1) added more database stuff (mlModel, Billings, Interactions, Records). 2) New Directory (mlModels) for storage of mlModels in the future. 3) Addeds separate dashboard htmls in new directory (templates/dashboards) in hopes of getting modelforms to work in the future.
parent 156cdfe9
No related branches found
No related tags found
No related merge requests found
Showing
with 164 additions and 16 deletions
......@@ -5,10 +5,14 @@ from core import models
from django.contrib import admin
from django.contrib.auth.models import User
from .models import Profile
from .models import Profile, mlModel, Interaction, Billing, Record
# Register the Profile model in the admin
admin.site.register(Profile)
admin.site.register(mlModel)
admin.site.register(Interaction)
admin.site.register(Billing)
admin.site.register(Record)
# Customize the User Admin to display profile fields
class UserAdmin(admin.ModelAdmin):
......
from django import forms
from django.forms import ModelForm
from django.contrib.auth.models import User
from .models import Record
class UserLoginForm(forms.Form):
username = forms.CharField(max_length=100)
password = forms.CharField(widget=forms.PasswordInput)
class UserUploadForm(forms.ModelForm):
class Meta:
model = Record
fields = '__all__'
\ No newline at end of file
......@@ -6,4 +6,39 @@ class Profile(models.Model):
role = models.CharField(max_length=100, choices=[('admin', 'Admin'), ('user', 'User'), ('ai_engineer', 'AI Engineer'), ('finance', 'Finance Team')])
def __str__(self):
return f"{self.user.username} - {self.role}"
\ No newline at end of file
return f"{self.user.username} - {self.role}"
class mlModel(models.Model):
modelID = models.AutoField(primary_key=True)
username = models.CharField(max_length=100, default="default")
modelName = models.CharField(max_length=100)
def __str__(self):
return self.modelName
class Interaction(models.Model):
interactionID = models.AutoField(primary_key=True)
username = models.CharField(max_length=100, default="default")
date = models.DateTimeField()
interaction = models.CharField(max_length=1000)
def __str__(self):
return self.interactionID
class Billing(models.Model):
billingID = models.AutoField(primary_key=True)
amount = models.FloatField()
username = models.CharField(max_length=100, default="company")
companyName = models.CharField(max_length=100)
def __str__(self):
return f"{self.companyName} - {self.billingID}"
class Record(models.Model):
username = models.CharField(max_length=100, default="default")
uploadedFile = models.FileField(upload_to='./records/')
chosenML = models.CharField(max_length=100, default="baseML")
responseByML = models.CharField(max_length=100, default="PLACEHOLDER RESPONSE") # change to actual response by ML
def __str__(self):
return f"{self.chosenML} Response to {self.userID}"
\ No newline at end of file
......@@ -3,8 +3,8 @@ from django.contrib.auth.forms import UserCreationForm
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from .models import Profile
from .forms import UserLoginForm
from .models import Profile, mlModel, Billing, Interaction, Record
from .forms import UserLoginForm, UserUploadForm
# Registration view
......@@ -36,7 +36,7 @@ def login_view(request):
role = profile.role
# Redirect to the correct profile page based on the user's role
if role == 'ai_engineer':
return redirect('ai_engineer_dashboard')
return redirect('ai_dashboard')
elif role == 'finance':
return redirect('finance_dashboard')
else:
......@@ -49,14 +49,16 @@ def login_view(request):
return render(request, 'login.html', {'form': form})
def user_dashboard(request):
return render(request, 'profile.html')
return render(request, 'dashboards/user_dashboard.html')
def ai_dashboard(request):
return render(request, 'dashboards/ai_dashboard.html')
def ai_engineer_dashboard(request):
return render(request, 'profile.html')
def admin_dashboard(request):
return render(request, 'dashboards/admin_dashboard.html')
def finance_dashboard(request):
return render(request, 'profile.html')
return render(request, 'dashboards/finance_dashboard.html')
def logout_view(request):
logout(request)
......
version: '3.8'
services:
web:
build:
......@@ -33,5 +32,12 @@ services:
timeout: 5s
retries: 5
# working on mlservice external container - idk how.
# mlService:
# image: mlService
volumes:
db-data:
......@@ -34,7 +34,8 @@ urlpatterns = [
path('logout/', views.logout_view, name='logout'),
path('login/', views.login_view, name='login'),
path('register/', views.register_view, name='register'),
path('profile/', views.user_dashboard, name='user_dashboard'),
path('ai_engineer_dashboard/', views.ai_engineer_dashboard, name='ai_engineer_dashboard'),
path('admin_dashboard/', views.admin_dashboard, name="admin_dashboard"),
path('user_dashboard/', views.user_dashboard, name='user_dashboard'),
path('ai_dashboard/', views.ai_dashboard, name='ai_dashboard'),
path('finance_dashboard/', views.finance_dashboard, name='finance_dashboard'),
]
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>User Dashboard</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>User Dashboard</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>User Dashboard</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>{{ user.username }}'s Dashboard</title>
</head>
<body>
<nav>
<ul>
<li><a href="{% url 'logout' %}">Logout</a></li>
</ul>
</nav>
<h1>Welcome, {{ user.username }}!</h1>
<h2>User Dashboard</h2>
<p>Manage your tasks and profile.</p>
<br>
<h2>Upload Files to ML</h2>
{% block content %}
<form method="post">
{% csrf_token %}
{{form.as_p}}
<input type="submit">
</form>
{% endblock %}
</body>
</html>
\ No newline at end of file
......@@ -10,16 +10,49 @@
</ul>
</nav>
<h1>Welcome, {{ user.username }}!</h1>
{% if user.profile.role == 'ai_engineer' %}
{% if user.profile.role == 'ai_engineer' %} <!-- AI Dashboard -->
<h2>AI Engineer Dashboard</h2>
<p>Access AI-related tools and data.</p>
{% elif user.profile.role == 'finance' %}
{% elif user.profile.role == 'finance' %} <!-- Finance Dashboard -->
<h2>Finance Dashboard</h2>
<p>View financial reports and tools.</p>
{% else %}
{% elif user.profile.role == 'admin' %} <!-- Admin Dashboard -->
<h2>Admin Page</h2>
<p>View all Activity</p>
<p>Manage Users</p>
{% else %} <!-- User Dashboard -->
<h2>User Dashboard</h2>
<p>Manage your tasks and profile.</p>
<br>
<h2>Upload Files to ML</h2>
<form method="post">
{% csrf_token %}
{{ form }}
<label for="uploadedFile">File </label>
<input type="file" name="uploadedFile" id="uploadedFile">
<br>
<input type="submit">Submit
</form>
{% endif %}
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment