diff --git a/ActualProjectCode/DjangoProject/core/views.py b/ActualProjectCode/DjangoProject/core/views.py index a66c35c9b9d675b48f5f42eb3df45995f6b36302..7ac33eb5bf464ceaeac27231f6b90ab7f5370fa5 100644 --- a/ActualProjectCode/DjangoProject/core/views.py +++ b/ActualProjectCode/DjangoProject/core/views.py @@ -96,11 +96,17 @@ def updateUsers(request, id): return render(request, 'modelForms/updateUsers.html', context) def interactionView(request): - interactions = Record.objects.all().values() + interactions = Record.objects.all() context = {} context = {'interactions': interactions} return render(request, 'modelForms/interactionView.html', context) +def billingsView(request): + billings = Billing.objects.all() + context = {} + context = {'billings': billings} + return render(request, 'modelForms/billingsView.html', context) + ##### DELETION SECTIONS def deleteRecord(request, id): @@ -112,6 +118,13 @@ def deleteRecord(request, id): context = {'record': record} return render(request, 'modelForms/deleteRecord.html', context) +def deleteBillings(request, billingID): + record = Billing.objects.get(billingID=billingID) + if request.method == 'POST': + record.delete() + return redirect('billingsView') + context = {'record': record} + return render(request, 'modelForms/deleteBillings.html', context) def deleteUsers(request, id): user = Profile.objects.get(user_id=id) diff --git a/ActualProjectCode/DjangoProject/docker-compose.yml b/ActualProjectCode/DjangoProject/docker-compose.yml index 9934bbd595daa3b8719d95a7d30f05cac4fb344b..5c89126440a76d46f4c99f934ebad770732313c0 100644 --- a/ActualProjectCode/DjangoProject/docker-compose.yml +++ b/ActualProjectCode/DjangoProject/docker-compose.yml @@ -40,6 +40,9 @@ services: image: mlservice command: > sh -c 'python main.py' + depends_on: + db: + condition: service_healthy volumes: diff --git a/ActualProjectCode/DjangoProject/server/urls.py b/ActualProjectCode/DjangoProject/server/urls.py index bc9a78f2850f0ecb0e86ce9eb3aa8e4c8e9a061e..f79a9058818a40bdfdd9ab3ae2af2cc73bb23d09 100644 --- a/ActualProjectCode/DjangoProject/server/urls.py +++ b/ActualProjectCode/DjangoProject/server/urls.py @@ -43,5 +43,7 @@ urlpatterns = [ path('modelForms/deleteUsers/<str:id>/', views.deleteUsers, name="deleteUsers"), path('modelForms/deleteRecord/<str:id>/', views.deleteRecord, name="deleteRecord"), path('modelForms/interactionView/', views.interactionView, name="interactionView"), + path('modelForms/billingsView/', views.billingsView, name="billingsView"), + path('modelForms/deleteBillings/<str:billingID>', views.deleteBillings, name="deleteBillings"), ] \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/templates/modelForms/billingsView.html b/ActualProjectCode/DjangoProject/templates/modelForms/billingsView.html new file mode 100644 index 0000000000000000000000000000000000000000..24623cb7db0973541020d472af963f013f40f88b --- /dev/null +++ b/ActualProjectCode/DjangoProject/templates/modelForms/billingsView.html @@ -0,0 +1,95 @@ +<!DOCTYPE html> +<html> +<head> + <title>Billings View</title> + <style> + body { + font-family: Arial, sans-serif; + background-color: #f4f4f4; + color: #333; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + } + + .container { + background: white; + padding: 20px; + border-radius: 8px; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); + width: 60%; + max-width: 600px; + text-align: center; + } + + a { + text-decoration: none; + color: #333; + font-weight: bold; + } + + a:hover { + color: #555; + } + + .record { + background: #fff; + padding: 15px; + margin: 15px 0; + border-radius: 5px; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); + text-align: left; + } + + .record p { + margin: 5px 0; + } + + .delete-btn { + display: inline-block; + margin-top: 10px; + padding: 8px 12px; + background: #ff4d4d; + color: white; + border-radius: 5px; + text-decoration: none; + font-weight: bold; + } + + .delete-btn:hover { + background: #cc0000; + } + + hr { + border: 0; + height: 1px; + background: #ccc; + margin: 15px 0; + } + </style> +</head> +<body> + + <div class="container"> + <p><a href="{% url 'profile' %}">Return to Profile</a></p> + + {% for record in billings %} + <div class="record"> + <p><strong>Billing ID:</strong> {{ record.billingID }}</p> + <p><strong>Amount: </strong>£{{ record.amount }}</p> + <p><strong>Generated By: </strong>{{ record.username }}</p> + <p><strong>Company Billed: </strong>{{ record.companyName }}</p> + <a href="{% url 'deleteBillings' record.billingID %}" class="delete-btn">Delete Billing</a> + </div> + <hr> + {% endfor %} + + </div> + +<!-- Display all billings made by specific Finance team member. --> + +</body> +</html> \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/templates/modelForms/deleteBillings.html b/ActualProjectCode/DjangoProject/templates/modelForms/deleteBillings.html new file mode 100644 index 0000000000000000000000000000000000000000..430dac35ea831b6cfe2d2e85ca75065163a2d8f4 --- /dev/null +++ b/ActualProjectCode/DjangoProject/templates/modelForms/deleteBillings.html @@ -0,0 +1,69 @@ +<!DOCTYPE html> +<html> +<head> + <style> + body { + font-family: Arial, sans-serif; + background-color: #f4f4f4; + color: #333; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + } + + .container { + background: white; + padding: 20px; + border-radius: 8px; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); + text-align: center; + width: 300px; + } + + p { + font-size: 16px; + margin-bottom: 20px; + } + + a { + text-decoration: none; + color: #333; + font-weight: bold; + margin-right: 15px; + } + + a:hover { + text-decoration: underline; + } + + input[type="submit"] { + background: #333; + color: white; + border: none; + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + border-radius: 5px; + } + + input[type="submit"]:hover { + background: #555; + } + </style> +</head> +<body> + + <div class="container"> + <p>Are you sure you want to delete this billing?</p> + <form action="{% url 'deleteBillings' record.billingID %}" method="POST"> + {% csrf_token %} + <a href="{% url 'billingsView' %}">Go Back</a> + <input type="submit" name="confirm" value="Delete"> + + </form> + </div> + +</body> +</html> \ No newline at end of file diff --git a/ActualProjectCode/DjangoProject/templates/profile.html b/ActualProjectCode/DjangoProject/templates/profile.html index a315077ab86058e4e652c5f32c74546d6ca3c59f..f30bd27e42884d436ad801e8b630a754dcb476db 100644 --- a/ActualProjectCode/DjangoProject/templates/profile.html +++ b/ActualProjectCode/DjangoProject/templates/profile.html @@ -172,14 +172,21 @@ <h2>Finance Dashboard</h2> <p>View financial reports and tools.</p> <hr> - <h1><a href="{% url 'genBillings' %}">Generate Billings</a></h1> + <h1>Generate Billings</h1> + <h2><a href="{% url 'genBillings' %}">Generate</a></h2> + <hr> + <h1>View Billings</h1> + <h2><a href="{% url 'billingsView' %}">View</a></h2> - {% elif user.profile.role == 'admin' %} <!-- Admin Dashboard --> + {% elif user.profile.role == 'admin' %} + <!-- Admin Dashboard --> <h2>Admin Page</h2> <p>View all Activity</p> - <p><a href="{% url 'manageUsers' %}">Manage Users</a></p> - - <p><a href=""> View all Activity </a></p> + <h1>Manage users page</h1> + <h2><a href="{% url 'manageUsers' %}">Manage Users</a></h2> + <hr> + <h1>View all activity</h1> + <h2><a href=""> Activity </a></h2> {% else %} <!-- User Dashboard -->