From b5884793c45a3556141c408926d2cd3999d5a628 Mon Sep 17 00:00:00 2001 From: a272-jones <Aaron8.jones@live.uwe.ac.uk> Date: Mon, 5 May 2025 19:34:55 +0100 Subject: [PATCH] Updated Profile --- ActualProjectCode/DjangoProject/core/forms.py | 15 ++++ ActualProjectCode/DjangoProject/core/views.py | 4 +- .../DjangoProject/templates/profile.html | 89 +++++++++++++------ 3 files changed, 79 insertions(+), 29 deletions(-) diff --git a/ActualProjectCode/DjangoProject/core/forms.py b/ActualProjectCode/DjangoProject/core/forms.py index 8479d6b..c95ed11 100644 --- a/ActualProjectCode/DjangoProject/core/forms.py +++ b/ActualProjectCode/DjangoProject/core/forms.py @@ -1,8 +1,23 @@ from django import forms from django.forms import ModelForm from django.contrib.auth.models import User +from django.contrib.auth.forms import UserCreationForm from . import models +class CustomUserCreationForm(UserCreationForm): + email = forms.EmailField(required=True) + + class Meta: + model = User + fields = ['username', 'email', 'password1', 'password2'] + + def save(self, commit=True): + user = super().save(commit=False) + user.email = self.cleaned_data['email'] + if commit: + user.save() + return user + class UserLoginForm(forms.Form): username = forms.CharField(max_length=100) password = forms.CharField(widget=forms.PasswordInput) diff --git a/ActualProjectCode/DjangoProject/core/views.py b/ActualProjectCode/DjangoProject/core/views.py index d7fc82f..da64530 100644 --- a/ActualProjectCode/DjangoProject/core/views.py +++ b/ActualProjectCode/DjangoProject/core/views.py @@ -8,13 +8,13 @@ from django.http import HttpResponse import subprocess import sys from .models import Profile, mlModel, Billing, Record -from .forms import UserLoginForm, UserUploadForm, UploadModelForm, GenerateBillingsForm, UpdateUser, UpdateModel +from .forms import UserLoginForm, UserUploadForm, UploadModelForm, GenerateBillingsForm, UpdateUser, UpdateModel, CustomUserCreationForm # Registration view def register_view(request): if request.method == 'POST': - form = UserCreationForm(request.POST) + form = CustomUserCreationForm(request.POST) if form.is_valid(): user = form.save() # Create a profile for the user diff --git a/ActualProjectCode/DjangoProject/templates/profile.html b/ActualProjectCode/DjangoProject/templates/profile.html index 3c6be37..7db0d7f 100644 --- a/ActualProjectCode/DjangoProject/templates/profile.html +++ b/ActualProjectCode/DjangoProject/templates/profile.html @@ -14,6 +14,14 @@ color: #333; } + h1.sectionTitle { + margin-left: 35px; + } + + h1.title { + text-align: center; + } + header { background-color: #004085; color: #ffffff; @@ -24,7 +32,6 @@ header h1 { margin: 0; } - /* Main Layout */ .container { display: flex; @@ -152,58 +159,86 @@ <!-- Content Section --> <div class="content"> <!-- Display the dynamic dashboard content --> - <h1>Welcome, {{ user.username }}!</h1> + <h1 class="title">Welcome, {{ user.username }}</h1> {% if user.profile.role == 'ai_engineer' %} <!-- AI Engineer Dashboard --> - <h2>AI Engineer Dashboard</h2> + <h1>AI Engineer Dashboard</h1> <p>Access AI-related tools and data.</p> <hr> - <h1>Upload Dataset</h1> + <h1 class="sectionTitle">AI Engineer Section</h1> + <!-- AI Section --> + <h2>Upload Dataset</h2> <h2><a href="{% url 'userUpload' %}">Upload</a></h2> - <h1>Upload new ML Model</h1> - <h2><a href="{% url 'mlUpload' %}">Upload</a></h2> - <hr> - <h2>View your uploads</h2> - <h1><a href="{% url 'viewUploads' %}">Here</a></h1> - <hr> - <h1>Access ML Interactions</h1> + <h2>Access ML Interactions</h2> <h2><a href="{% url 'interactionView' %}">All Interactions</a></h2> - <hr> - <h1>Manage Models</h1> + <h2>Manage Models</h2> <h2><a href="{% url 'manageModels' %}">Manage</a></h2> + <!-- End of AI Section --> + <hr> + <h1 class="sectionTitle">User Section</h1> + <!-- User Section --> + <h2>Upload Files to ML</h2> + <h2><a href="{% url 'userUpload' %}">Upload CSV</a></h2> + <h2>View your uploads</h2> + <h2><a href="{% url 'viewUploads' %}">Here</a></h2> + <!-- End of User Section --> + {% elif user.profile.role == 'finance' %} <!-- Finance Dashboard --> - <h2>Finance Dashboard</h2> + <h1>Finance Dashboard</h1> <p>View financial reports and tools.</p> <hr> - <h1>Generate Billings</h1> + <h1 class="sectionTitle">Finance Section</h1> + <!-- Finance Section --> + <h2>Generate Billings</h2> <h2><a href="{% url 'genBillings' %}">Generate</a></h2> - <hr> - <h1>View Billings</h1> + <h2>View Billings</h2> <h2><a href="{% url 'billingsView' %}">View</a></h2> + <!-- End of Finance Section --> {% elif user.profile.role == 'admin' %} - <!-- Admin Dashboard --> - <h2>Admin Page</h2> - <p>View all Activity</p> - <h1>Manage users page</h1> - <h2><a href="{% url 'manageUsers' %}">Manage Users</a></h2> + <!-- Admin Dashboard --> + <h1>Admin Dashboard</h1> + <p>View Activity, approve billings and upload to system.</p> + <hr> + <h1 class="sectionTitle">User Section</h1> + <!-- User Section --> + <h2>Upload Files to ML</h2> + <h2><a href="{% url 'userUpload' %}">Upload CSV</a></h2> + <h2>View your uploads</h2> + <h2><a href="{% url 'viewUploads' %}">Here</a></h2> + <!-- End of User Section --> <hr> - <h1>View all activity</h1> + <h1 class="sectionTitle">Admin Section</h1> + <!-- Admin Section --> + <h2>Manage users page</h2> + <h2><a href="{% url 'manageUsers' %}">Manage Users</a></h2> + <h2>View all activity</h2> <h2><a href=""> Activity </a></h2> + <!-- End of Admin Section --> + <hr> + <h1 class="sectionTitle">Finance Section</h1> + <!-- Finance Section --> + <h2>Generate Billings</h2> + <h2><a href="{% url 'genBillings' %}">Generate</a></h2> + <h2>View Billings</h2> + <h2><a href="{% url 'billingsView' %}">View</a></h2> + <!-- End of Finance Section --> {% else %} <!-- User Dashboard --> - <h2>User Dashboard</h2> + <h1>User Dashboard</h1> <p>Manage your tasks and profile.</p> <hr> + <h1 class="sectionTitle">User Section</h1> + <!-- User Section --> <h2>Upload Files to ML</h2> - <h1><a href="{% url 'userUpload' %}">Upload CSV</a></h1> - <hr> + <h2><a href="{% url 'userUpload' %}">Upload CSV</a></h2> <h2>View your uploads</h2> - <h1><a href="{% url 'viewUploads' %}">Here</a></h1> + <h2><a href="{% url 'viewUploads' %}">Here</a></h2> + <!-- End of User Section --> {% endif %} -- GitLab