+
-
+
-
-
-
+
diff --git a/core/templates/core/index.html b/core/templates/core/index.html
index 1e0e15d..e0da796 100644
--- a/core/templates/core/index.html
+++ b/core/templates/core/index.html
@@ -133,8 +133,8 @@
-
+
diff --git a/core/templates/core/blood_bank_list.html b/core/templates/core/blood_bank_list.html
index d133653..646ce28 100644
--- a/core/templates/core/blood_bank_list.html
+++ b/core/templates/core/blood_bank_list.html
@@ -48,54 +48,78 @@
-
+
Detect Location
-
- {{ current_time|date:"D, M d, Y" }}
+
+ {{ current_time|date:"M d" }}
{% if user.is_authenticated %}
{% else %}
{% endif %}
Inventory Levels (Units)
+Inventory Levels (Max {{ bank.total_capacity }} units/type)
A+
{{ bank.stock_a_plus }}
+
+
+
A-
{{ bank.stock_a_minus }}
+
+
+
B+
{{ bank.stock_b_plus }}
+
+
+
B-
{{ bank.stock_b_minus }}
+
+
+
O+
{{ bank.stock_o_plus }}
+
+
+
O-
{{ bank.stock_o_minus }}
+
+
+
AB+
{{ bank.stock_ab_plus }}
+
+
+
AB-
{{ bank.stock_ab_minus }}
+
+
+
{{ stats.total_stock }} Units
- Bank Inventory
+ {{ stats.total_stock }} / {{ stats.total_capacity }}
+ Inventory vs Capacity
diff --git a/core/templates/core/profile.html b/core/templates/core/profile.html
new file mode 100644
index 0000000..4ecf840
--- /dev/null
+++ b/core/templates/core/profile.html
@@ -0,0 +1,74 @@
+{% extends 'base.html' %}
+{% load static %}
+
+{% block title %}User Profile - RaktaPulse{% endblock %}
+
+{% block content %}
+
+
+{% endblock %}
diff --git a/core/urls.py b/core/urls.py
index f117f9c..5a87ab4 100644
--- a/core/urls.py
+++ b/core/urls.py
@@ -1,12 +1,13 @@
from django.urls import path
-from .views import home, login_view, logout_view, register_view, donor_list, blood_request_list, blood_bank_list, vaccination_info, vaccination_dashboard, add_vaccination, live_map
+from .views import home, login_view, logout_view, register_view, donor_list, blood_request_list, blood_bank_list, vaccination_info, vaccination_dashboard, add_vaccination, live_map, request_blood, profile
urlpatterns = [
path("", home, name="home"),
path("login/", login_view, name="login"),
path("logout/", logout_view, name="logout"),
path("register/", register_view, name="register"),
+ path("profile/", profile, name="profile"),
path("donors/", donor_list, name="donor_list"),
path("requests/", blood_request_list, name="blood_request_list"),
path("banks/", blood_bank_list, name="blood_bank_list"),
diff --git a/core/views.py b/core/views.py
index 0711e80..ea196c1 100644
--- a/core/views.py
+++ b/core/views.py
@@ -6,9 +6,34 @@ from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.utils import timezone
-from .models import Donor, BloodRequest, BloodBank, VaccineRecord
+from .models import Donor, BloodRequest, BloodBank, VaccineRecord, UserProfile, BLOOD_GROUPS
+from .forms import UserUpdateForm, ProfileUpdateForm
import math
+@login_required
+def profile(request):
+ # Ensure user has a profile
+ profile, created = UserProfile.objects.get_or_create(user=request.user)
+
+ if request.method == 'POST':
+ u_form = UserUpdateForm(request.POST, instance=request.user)
+ p_form = ProfileUpdateForm(request.POST, instance=profile)
+ if u_form.is_valid() and p_form.is_valid():
+ u_form.save()
+ p_form.save()
+ messages.success(request, f'Your account has been updated!')
+ return redirect('profile')
+ else:
+ u_form = UserUpdateForm(instance=request.user)
+ p_form = ProfileUpdateForm(instance=profile)
+
+ context = {
+ 'u_form': u_form,
+ 'p_form': p_form
+ }
+
+ return render(request, 'core/profile.html', context)
+
def haversine(lat1, lon1, lat2, lon2):
# Radius of the Earth in km
R = 6371.0
@@ -92,6 +117,7 @@ def home(request):
bb.stock_o_plus + bb.stock_o_minus + bb.stock_ab_plus + bb.stock_ab_minus
for bb in blood_banks
]),
+ "total_capacity": sum([bb.total_capacity * 8 for bb in blood_banks]), # 8 blood types
"vaccinated_percentage": 0
}
@@ -104,7 +130,7 @@ def home(request):
"donors": donor_list_data[:8],
"blood_requests": blood_requests[:6],
"blood_banks": blood_banks,
- "blood_groups": [g[0] for g in Donor.BLOOD_GROUPS],
+ "blood_groups": [g[0] for g in BLOOD_GROUPS],
"stats": stats,
"project_name": "RaktaPulse",
"current_time": timezone.now(),
@@ -142,7 +168,7 @@ def donor_list(request):
context = {
'donors': donor_list_data,
- 'blood_groups': [g[0] for g in Donor.BLOOD_GROUPS],
+ 'blood_groups': [g[0] for g in BLOOD_GROUPS],
}
return render(request, 'core/donor_list.html', context)
@@ -231,7 +257,7 @@ def request_blood(request):
messages.error(request, "Please fill in all required fields.")
context = {
- 'blood_groups': [g[0] for g in Donor.BLOOD_GROUPS],
+ 'blood_groups': [g[0] for g in BLOOD_GROUPS],
'urgency_levels': BloodRequest.URGENCY_LEVELS,
}
return render(request, 'core/request_blood.html', context)
diff --git a/reduce_capacity.py b/reduce_capacity.py
new file mode 100644
index 0000000..1dbdde6
--- /dev/null
+++ b/reduce_capacity.py
@@ -0,0 +1,17 @@
+import os
+import django
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
+django.setup()
+
+from core.models import BloodBank
+
+def run():
+ banks = BloodBank.objects.all()
+ for bank in banks:
+ bank.total_capacity = 200 # Reduced from 1000
+ bank.save()
+ print("Capacity reduced for all blood banks.")
+
+if __name__ == "__main__":
+ run()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ user.username }}
+Member since {{ user.date_joined|date:"M d, Y" }}
+