From 3ba17184a13d8014c366ac18c23cd3f0452dc49a Mon Sep 17 00:00:00 2001 From: James <james2.burt@live.uwe.ac.uk> Date: Thu, 13 Mar 2025 14:06:26 +0000 Subject: [PATCH] actual project updated for pycharm --- .../DjangoProject/.idea/.gitignore | 8 ++ .../inspectionProfiles/Project_Default.xml | 12 ++ .../inspectionProfiles/profiles_settings.xml | 6 + .../DjangoProject/.idea/misc.xml | 6 + .../DjangoProject/.idea/modules.xml | 8 ++ ActualProjectCode/DjangoProject/.idea/vcs.xml | 4 + ActualProjectCode/DjangoProject/Dockerfile | 18 +++ ActualProjectCode/DjangoProject/db.sqlite3 | 0 .../DjangoProject/docker-compose.yml | 18 +++ ActualProjectCode/DjangoProject/manage.py | 22 +++ .../DjangoProject/requirements.txt | Bin 0 -> 130 bytes .../DjangoProject/server/__init__.py | 0 .../DjangoProject/server/asgi.py | 16 +++ .../DjangoProject/server/settings.py | 127 ++++++++++++++++++ .../DjangoProject/server/urls.py | 30 +++++ .../DjangoProject/server/wsgi.py | 16 +++ .../DjangoProject/static/scripts.js | 59 ++++++++ .../DjangoProject/static/styles.css | 127 ++++++++++++++++++ .../DjangoProject/templates/index.html | 33 +++++ 19 files changed, 510 insertions(+) create mode 100644 ActualProjectCode/DjangoProject/.idea/.gitignore create mode 100644 ActualProjectCode/DjangoProject/.idea/inspectionProfiles/Project_Default.xml create mode 100644 ActualProjectCode/DjangoProject/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 ActualProjectCode/DjangoProject/.idea/misc.xml create mode 100644 ActualProjectCode/DjangoProject/.idea/modules.xml create mode 100644 ActualProjectCode/DjangoProject/.idea/vcs.xml create mode 100644 ActualProjectCode/DjangoProject/Dockerfile create mode 100644 ActualProjectCode/DjangoProject/db.sqlite3 create mode 100644 ActualProjectCode/DjangoProject/docker-compose.yml create mode 100644 ActualProjectCode/DjangoProject/manage.py create mode 100644 ActualProjectCode/DjangoProject/requirements.txt create mode 100644 ActualProjectCode/DjangoProject/server/__init__.py create mode 100644 ActualProjectCode/DjangoProject/server/asgi.py create mode 100644 ActualProjectCode/DjangoProject/server/settings.py create mode 100644 ActualProjectCode/DjangoProject/server/urls.py create mode 100644 ActualProjectCode/DjangoProject/server/wsgi.py create mode 100644 ActualProjectCode/DjangoProject/static/scripts.js create mode 100644 ActualProjectCode/DjangoProject/static/styles.css create mode 100644 ActualProjectCode/DjangoProject/templates/index.html diff --git a/ActualProjectCode/DjangoProject/.idea/.gitignore b/ActualProjectCode/DjangoProject/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/ActualProjectCode/DjangoProject/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/ActualProjectCode/DjangoProject/.idea/inspectionProfiles/Project_Default.xml b/ActualProjectCode/DjangoProject/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..06bb0314 --- /dev/null +++ b/ActualProjectCode/DjangoProject/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ +<component name="InspectionProjectProfileManager"> + <profile version="1.0"> + <option name="myName" value="Project Default" /> + <inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true"> + <option name="ignoredErrors"> + <list> + <option value="N802" /> + </list> + </option> + </inspection_tool> + </profile> +</component> \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/.idea/inspectionProfiles/profiles_settings.xml b/ActualProjectCode/DjangoProject/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/ActualProjectCode/DjangoProject/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ +<component name="InspectionProjectProfileManager"> + <settings> + <option name="USE_PROJECT_PROFILE" value="false" /> + <version value="1.0" /> + </settings> +</component> \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/.idea/misc.xml b/ActualProjectCode/DjangoProject/.idea/misc.xml new file mode 100644 index 00000000..a4bacd35 --- /dev/null +++ b/ActualProjectCode/DjangoProject/.idea/misc.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Black"> + <option name="sdkName" value="Python 3.12 (DjangoProject1)" /> + </component> +</project> \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/.idea/modules.xml b/ActualProjectCode/DjangoProject/.idea/modules.xml new file mode 100644 index 00000000..787beab0 --- /dev/null +++ b/ActualProjectCode/DjangoProject/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/DjangoProject1.iml" filepath="$PROJECT_DIR$/.idea/DjangoProject1.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/.idea/vcs.xml b/ActualProjectCode/DjangoProject/.idea/vcs.xml new file mode 100644 index 00000000..d843f340 --- /dev/null +++ b/ActualProjectCode/DjangoProject/.idea/vcs.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings" defaultProject="true" /> +</project> \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/Dockerfile b/ActualProjectCode/DjangoProject/Dockerfile new file mode 100644 index 00000000..483a879c --- /dev/null +++ b/ActualProjectCode/DjangoProject/Dockerfile @@ -0,0 +1,18 @@ +# Use the official Python image +FROM python:3.12 + +# Set the working directory +WORKDIR /app + +# Copy and install dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the project files +COPY . . + +# Expose Django's default port +EXPOSE 8000 + +# Run the Django development server +CMD ["python", "manage.py", "runserver", "0.0.0.0:7000"] \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/db.sqlite3 b/ActualProjectCode/DjangoProject/db.sqlite3 new file mode 100644 index 00000000..e69de29b diff --git a/ActualProjectCode/DjangoProject/docker-compose.yml b/ActualProjectCode/DjangoProject/docker-compose.yml new file mode 100644 index 00000000..0dbf18c1 --- /dev/null +++ b/ActualProjectCode/DjangoProject/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3.8' +services: + web: + build: . + ports: + - "7000:7000" + volumes: + - .:/app + environment: + - DEBUG=True +# depends_on: +# - db +# db: +# image: postgres +# environment: +# POSTGRES_USER: user +# POSTGRES_PASSWORD: password +# POSTGRES_DB: mydb diff --git a/ActualProjectCode/DjangoProject/manage.py b/ActualProjectCode/DjangoProject/manage.py new file mode 100644 index 00000000..8b46ee6c --- /dev/null +++ b/ActualProjectCode/DjangoProject/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/ActualProjectCode/DjangoProject/requirements.txt b/ActualProjectCode/DjangoProject/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..09ed45eca833e4b3c124887702da9690fb4c5ead GIT binary patch literal 130 zcmezWFOi{`A)O(Up@<=sA&tS7!Ir_8L65<LL65<ZftP`c!G$4<A(0`EA)O%~ENcpu z(PJ<N%N8>fGUPB6FeEY*F%&bTf>jtW=rMp)8G}`nFjO(5FeEaRFeHLyjTj6VjKJ~` F^8vW66LtUq literal 0 HcmV?d00001 diff --git a/ActualProjectCode/DjangoProject/server/__init__.py b/ActualProjectCode/DjangoProject/server/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ActualProjectCode/DjangoProject/server/asgi.py b/ActualProjectCode/DjangoProject/server/asgi.py new file mode 100644 index 00000000..c958c8aa --- /dev/null +++ b/ActualProjectCode/DjangoProject/server/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for server project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings') + +application = get_asgi_application() diff --git a/ActualProjectCode/DjangoProject/server/settings.py b/ActualProjectCode/DjangoProject/server/settings.py new file mode 100644 index 00000000..98df23a0 --- /dev/null +++ b/ActualProjectCode/DjangoProject/server/settings.py @@ -0,0 +1,127 @@ +""" +Django settings for server project. + +Generated by 'django-admin startproject' using Django 5.1.7. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path +import os + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-9_1snu(4$hue!emovp5v6bw$54puxg4njpgl_qx0t%%ob*h*w-' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'server.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [BASE_DIR / 'templates'] + , + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'server.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = '/static/' + +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, 'static'), # Static folder at root level +] +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/ActualProjectCode/DjangoProject/server/urls.py b/ActualProjectCode/DjangoProject/server/urls.py new file mode 100644 index 00000000..1f30cc33 --- /dev/null +++ b/ActualProjectCode/DjangoProject/server/urls.py @@ -0,0 +1,30 @@ +""" +URL configuration for server project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +# from django.contrib import admin +from django.urls import path + +from django.contrib import admin +from django.urls import path +from django.shortcuts import render + +def home(request): + return render(request, 'index.html') + +urlpatterns = [ + # path('admin/', admin.site.urls), + path('', home, name='home'), +] \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/server/wsgi.py b/ActualProjectCode/DjangoProject/server/wsgi.py new file mode 100644 index 00000000..9500532b --- /dev/null +++ b/ActualProjectCode/DjangoProject/server/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for server project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings') + +application = get_wsgi_application() diff --git a/ActualProjectCode/DjangoProject/static/scripts.js b/ActualProjectCode/DjangoProject/static/scripts.js new file mode 100644 index 00000000..bfdf5f89 --- /dev/null +++ b/ActualProjectCode/DjangoProject/static/scripts.js @@ -0,0 +1,59 @@ +document.addEventListener('DOMContentLoaded', function () { + document.getElementById('login-btn').addEventListener('click', function() { + // Get the selected role from the dropdown + const selectedRole = document.getElementById('role').value; + + // Hide the login section and show the dashboard section + document.getElementById('login-section').style.display = 'none'; + document.getElementById('dashboard-section').style.display = 'block'; + + // Display the role name + document.getElementById('role-name').textContent = selectedRole.replace('-', ' ').toUpperCase(); + + // Show role-specific dashboard content + let dashboardContent = ''; + switch (selectedRole) { + case 'end-user': + dashboardContent = ` + <h3>End-User Dashboard</h3> + <p>Welcome to your personalized dashboard! Here you can upload files and view predictions.</p> + <button>Upload File</button> + <button>View Predictions</button> + `; + break; + case 'ai-engineer': + dashboardContent = ` + <h3>AI Engineer Dashboard</h3> + <p>Manage ML models and monitor user interactions to improve the model.</p> + <button>Upload New Model</button> + <button>View User Interactions</button> + `; + break; + case 'administrator': + dashboardContent = ` + <h3>Administrator Dashboard</h3> + <p>Monitor system activity, manage users, and control access levels.</p> + <button>View System Logs</button> + <button>Manage Users</button> + `; + break; + case 'finance-team': + dashboardContent = ` + <h3>Finance Team Dashboard</h3> + <p>Generate invoices based on user activity and view billing information.</p> + <button>Generate Invoice</button> + <button>View Billing History</button> + `; + break; + } + + document.getElementById('dashboard-content').innerHTML = dashboardContent; + }); + + // Logout functionality + document.getElementById('logout-btn').addEventListener('click', function() { + // Hide the dashboard section and show the login section + document.getElementById('login-section').style.display = 'block'; + document.getElementById('dashboard-section').style.display = 'none'; + }); +}); diff --git a/ActualProjectCode/DjangoProject/static/styles.css b/ActualProjectCode/DjangoProject/static/styles.css new file mode 100644 index 00000000..4c2e9910 --- /dev/null +++ b/ActualProjectCode/DjangoProject/static/styles.css @@ -0,0 +1,127 @@ +/* Global Styles */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: Arial, sans-serif; +} + +body { + background-color: #f4f7fc; + color: #333; + font-size: 16px; + line-height: 1.6; + font-family: Arial, sans-serif; + margin: 0; + padding: 0; +} + +h1, h2, h3 { + font-weight: bold; +} + +.container { + width: 80%; + margin: 0 auto; + padding: 20px; +} + +header { + text-align: center; + margin-bottom: 40px; +} + +h1 { + color: #3498db; +} + +#login-section, #dashboard-section { + max-width: 500px; + margin: 0 auto; + padding: 20px; + background-color: white; + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); +} + +#login-section h2, #dashboard-section h2 { + color: #2c3e50; + margin-bottom: 20px; +} + +.input-group { + margin-bottom: 15px; +} + +input[type="text"], input[type="password"] { + width: 100%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 16px; +} + +button { + width: 100%; + padding: 12px; + border: none; + background-color: #3498db; + color: white; + font-size: 16px; + border-radius: 4px; + cursor: pointer; + margin-top: 10px; +} + +button:hover { + background-color: #2980b9; +} + +select { + padding: 5px; + font-size: 16px; +} + +.hidden { + display: none; +} + +.user-type-selection button { + margin-top: 10px; + width: 48%; + display: inline-block; + background-color: #2ecc71; +} + +.user-type-selection button:hover { + background-color: #27ae60; +} + +.dashboard { + margin-top: 20px; + text-align: center; +} + +.dashboard button { + background-color: #e67e22; +} +#dashboard-section { + text-align: center; + padding-top: 50px; +} +.dashboard button:hover { + background-color: #d35400; +} +#role-name { + font-weight: bold; +} +#logout-btn { + background-color: red; + color: white; + border: none; + font-size: 16px; + cursor: pointer; +} +#logout-btn:hover { + background-color: darkred; +} diff --git a/ActualProjectCode/DjangoProject/templates/index.html b/ActualProjectCode/DjangoProject/templates/index.html new file mode 100644 index 00000000..3e1cdedd --- /dev/null +++ b/ActualProjectCode/DjangoProject/templates/index.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>MLaaS - Machine Learning as a Service</title> + {% load static %} + <link rel="stylesheet" type="text/css" href="{% static 'styles.css' %}"> +</head> +<body> + <!-- Login Section --> + <div id="login-section"> + <h2>Login</h2> + <label for="role">Select Role:</label> + <select id="role" name="role"> + <option value="end-user">End-User</option> + <option value="ai-engineer">AI Engineer</option> + <option value="administrator">Administrator</option> + <option value="finance-team">Finance Team</option> + </select><br><br> + <button id="login-btn">Login</button> + </div> + + <!-- Dashboard Section --> + <div id="dashboard-section" style="display:none;"> + <h1>Welcome <span id="role-name"></span></h1> + <div id="dashboard-content"></div> + <button id="logout-btn">Logout</button> + </div> + <script src="{% static 'scripts.js' %}"></script> +</body> +</html> + -- GitLab