diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 84a28fd..2779367 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 34e9e1c..c8dbd0d 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index d8c8071..29ae6da 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/migrations/0020_vaccinerecord_photo.py b/core/migrations/0020_vaccinerecord_photo.py new file mode 100644 index 0000000..4a27b87 --- /dev/null +++ b/core/migrations/0020_vaccinerecord_photo.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.7 on 2026-02-19 05:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0019_healthreport'), + ] + + operations = [ + migrations.AddField( + model_name='vaccinerecord', + name='photo', + field=models.ImageField(blank=True, null=True, upload_to='vaccine_photos/'), + ), + ] diff --git a/core/migrations/__pycache__/0020_vaccinerecord_photo.cpython-311.pyc b/core/migrations/__pycache__/0020_vaccinerecord_photo.cpython-311.pyc new file mode 100644 index 0000000..4080729 Binary files /dev/null and b/core/migrations/__pycache__/0020_vaccinerecord_photo.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index e6f9f77..895cb77 100644 --- a/core/models.py +++ b/core/models.py @@ -65,6 +65,7 @@ class VaccineRecord(models.Model): location = models.CharField(max_length=255) center_name = models.CharField(max_length=255, null=True, blank=True) notes = models.TextField(blank=True, null=True) + photo = models.ImageField(upload_to='vaccine_photos/', null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): diff --git a/core/templates/base.html b/core/templates/base.html index b485bca..43113d2 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -281,9 +281,10 @@
  • {% trans "Vaccination" %}
  • {% if user.is_authenticated %}
  • {% trans "My Records" %}
  • -
  • {% trans "Health Reports" %}
  • {% endif %} + {% if user.is_superuser %}
  • {% trans "Settings" %}
  • + {% endif %} @@ -295,10 +296,12 @@ - +
    diff --git a/core/templates/core/add_vaccination.html b/core/templates/core/add_vaccination.html index 502a9cb..36d0a77 100644 --- a/core/templates/core/add_vaccination.html +++ b/core/templates/core/add_vaccination.html @@ -16,7 +16,7 @@

    Keep your immunization data accurate and up to date.

    -
    + {% csrf_token %}
    @@ -57,6 +57,11 @@
    +
    + + +
    +
    diff --git a/core/templates/core/blood_request_list.html b/core/templates/core/blood_request_list.html index 5c0aaaa..a128447 100644 --- a/core/templates/core/blood_request_list.html +++ b/core/templates/core/blood_request_list.html @@ -49,6 +49,17 @@
    {{ req.patient_name }}

    {{ req.hospital }}

    + {% with acceptance=req.donations.first %} + {% if acceptance %} +
    +

    + + Accepted by: {{ acceptance.donor.name }} +

    +
    + {% endif %} + {% endwith %} + {% if req.image %}
    Patient/Prescription @@ -64,7 +75,9 @@ {% endif %} + {% if user.is_authenticated and user.donor_profile and req.user != user %} Volunteer + {% endif %} Call
    diff --git a/core/templates/core/donor_list.html b/core/templates/core/donor_list.html index 738a14d..a8c4345 100644 --- a/core/templates/core/donor_list.html +++ b/core/templates/core/donor_list.html @@ -15,6 +15,10 @@
    + +
    +
    -
    +
    + placeholder="District..." value="{{ request.GET.district }}">
    @@ -34,8 +38,8 @@ Nearest
    -
    - Reset +
    + Reset
    diff --git a/core/templates/core/health_report_list.html b/core/templates/core/health_report_list.html deleted file mode 100644 index c18949c..0000000 --- a/core/templates/core/health_report_list.html +++ /dev/null @@ -1,80 +0,0 @@ -{% extends "base.html" %} -{% load static %} - -{% block title %}My Health Records - RaktaPulse{% endblock %} - -{% block content %} -
    -
    -
    -

    My Health Records

    -

    Manage your hospital reports and medical history.

    -
    - - Add New Report - -
    - - {% if reports %} -
    - {% for report in reports %} -
    -
    -
    -
    -
    - -
    - {% if report.allow_notifications %} - - Notifications On - - {% endif %} -
    - -
    {{ report.title }}
    -

    - {{ report.hospital_name|default:"Not Specified" }} -

    - -
    -
    - Test Date: - {{ report.report_date }} -
    - {% if report.next_test_date %} -
    - Next Test: - {{ report.next_test_date }} -
    - {% endif %} -
    - - {% if report.description %} -

    {{ report.description|truncatechars:80 }}

    - {% endif %} - - -
    -
    -
    - {% endfor %} -
    - {% else %} -
    -
    - -
    -

    No health records found

    -

    Start by uploading your first medical report today.

    - - Upload Now - -
    - {% endif %} -
    -{% endblock %} diff --git a/core/templates/core/index.html b/core/templates/core/index.html index e04044f..81ed0ce 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -121,7 +121,7 @@
    {% for badge in user_badges %} -
    +
    {{ badge.name }}
    @@ -344,6 +344,17 @@
    {{ req.patient_name }}

    {{ req.hospital }}

    + + {% with acceptance=req.donations.first %} + {% if acceptance %} +
    +

    + + Accepted by: {{ acceptance.donor.name }} +

    +
    + {% endif %} + {% endwith %}
    {{ req.created_at|timesince }} ago
    diff --git a/core/templates/core/live_map.html b/core/templates/core/live_map.html index cc885ac..4dd3863 100644 --- a/core/templates/core/live_map.html +++ b/core/templates/core/live_map.html @@ -30,6 +30,7 @@ Blood Group Hospital Urgency + Status / Accepted By Action @@ -48,6 +49,17 @@ NORMAL {% endif %} + + {% with acceptance=req.donations.first %} + {% if acceptance %} + + {{ acceptance.donor.name }} + + {% else %} + Awaiting Help + {% endif %} + {% endwith %} + - Cancel + Cancel
    diff --git a/core/templates/core/vaccination_dashboard.html b/core/templates/core/vaccination_dashboard.html index 20289ae..eaea071 100644 --- a/core/templates/core/vaccination_dashboard.html +++ b/core/templates/core/vaccination_dashboard.html @@ -1,11 +1,11 @@ {% extends "base.html" %} {% load static %} -{% block title %}My Vaccination Records - {{ project_name }}{% endblock %} +{% block title %}My Records - {{ project_name }}{% endblock %} {% block head %} {% endblock %} @@ -42,12 +63,17 @@
    -

    Vaccination Journey

    -

    Track and manage your immunization history safely.

    +

    Health & Records

    +

    Manage your vaccinations and hospital reports in one place.

    +
    + - - Add New Record -
    {% if messages %} @@ -62,42 +88,141 @@
    {% endif %} -
    - {% for record in records %} -
    -
    -
    -
    {{ record.vaccine_name }}
    - Dose {{ record.dose_number }} -
    - -
    - {{ record.date_taken|date:"M d, Y" }} - {{ record.center_name|default:record.location }} -
    + -
    -

    - Location: {{ record.location }} -

    - {% if record.notes %} -

    - {{ record.notes|truncatechars:100 }} -

    - {% endif %} +
    + +
    +
    + {% for record in records %} +
    +
    +
    +
    {{ record.vaccine_name }}
    + Dose {{ record.dose_number }} +
    + +
    + {{ record.date_taken|date:"M d, Y" }} + {{ record.center_name|default:record.location }} +
    + + {% if record.photo %} + + {% endif %} + +
    +

    + Location: {{ record.location }} +

    + {% if record.notes %} +

    + {{ record.notes|truncatechars:100 }} +

    + {% endif %} +
    +
    + {% empty %} +
    +
    + +

    No vaccination records

    +

    Keep track of your immunizations.

    + Add Record +
    +
    + {% endfor %}
    - {% empty %} -
    -
    - -

    No records found

    -

    Start tracking your vaccinations today to keep your community safe.

    - Add Your First Record + + +
    +
    + {% for report in reports %} +
    +
    +
    +
    {{ report.title }}
    + + + +
    + +

    {{ report.hospital_name }}

    + +
    + {{ report.report_date|date:"M d, Y" }} + {% if report.next_test_date %} + Next: {{ report.next_test_date|date:"M d, Y" }} + {% endif %} +
    + + {% if report.description %} +

    {{ report.description|truncatechars:120 }}

    + {% endif %} + +
    + + + {% if report.allow_notifications %}Notifications On{% else %}Notifications Off{% endif %} + + {{ report.created_at|timesince }} ago +
    +
    +
    + {% empty %} +
    +
    + +

    No hospital reports

    +

    Upload your medical reports for safekeeping and reminders.

    + Upload First Report +
    +
    + {% endfor %}
    - {% endfor %}
    + + {% endblock %} diff --git a/core/urls.py b/core/urls.py index 59ae69d..9d8807e 100644 --- a/core/urls.py +++ b/core/urls.py @@ -8,7 +8,7 @@ from .views import ( complete_donation, notifications_view, register_donor, hospital_list, public_profile, inbox, chat, update_location, emergency_sms, delete_personal_info, - health_report_list, upload_health_report + upload_health_report ) urlpatterns = [ @@ -27,7 +27,6 @@ urlpatterns = [ path("vaccination/", vaccination_info, name="vaccination_info"), path("vaccination/dashboard/", vaccination_dashboard, name="vaccination_dashboard"), path("vaccination/add/", add_vaccination, name="add_vaccination"), - path("reports/", health_report_list, name="health_report_list"), path("reports/upload/", upload_health_report, name="upload_health_report"), path("live-map/", live_map, name="live_map"), path("request-blood/", request_blood, name="request_blood"), diff --git a/core/views.py b/core/views.py index ca9fb1c..5af37d1 100644 --- a/core/views.py +++ b/core/views.py @@ -314,12 +314,15 @@ def home(request): return render(request, "core/index.html", context) def donor_list(request): + query = request.GET.get('q', '') blood_group = request.GET.get('blood_group', '') district = request.GET.get('district', '') user_lat = request.GET.get('lat') user_lng = request.GET.get('lng') donors = Donor.objects.all() + if query: + donors = donors.filter(Q(name__icontains=query) | Q(location__icontains=query)) if blood_group: donors = donors.filter(blood_group=blood_group) if district: @@ -448,11 +451,14 @@ def request_blood(request): } return render(request, 'core/request_blood.html', context) +@login_required @login_required def vaccination_dashboard(request): records = VaccineRecord.objects.filter(user=request.user).order_by('-date_taken') + reports = HealthReport.objects.filter(user=request.user).order_by('-report_date') context = { 'records': records, + 'reports': reports, 'project_name': "RaktaPulse", } return render(request, 'core/vaccination_dashboard.html', context) @@ -466,6 +472,7 @@ def add_vaccination(request): location = request.POST.get('location') center_name = request.POST.get('center_name') notes = request.POST.get('notes') + photo = request.FILES.get('photo') if vaccine_name and dose_number and date_taken: VaccineRecord.objects.create( @@ -475,7 +482,8 @@ def add_vaccination(request): date_taken=date_taken, location=location, center_name=center_name, - notes=notes + notes=notes, + photo=photo ) messages.success(request, "Vaccination record added successfully!") return redirect('vaccination_dashboard') @@ -493,6 +501,11 @@ def volunteer_for_request(request, request_id): messages.error(request, "You need to be registered as a donor to volunteer.") return redirect('donor_list') + # Prevent requester from volunteering for their own request + if blood_request.user == request.user: + messages.error(request, "You cannot volunteer for your own blood request.") + return redirect('blood_request_list') + # Check if already volunteered if DonationEvent.objects.filter(donor=donor_profile, request=blood_request).exists(): messages.warning(request, "You have already volunteered for this request.") @@ -669,11 +682,6 @@ def chat(request, username): return render(request, 'core/chat.html', {'other_user': other_user, 'chat_messages': messages}) -@login_required -def health_report_list(request): - reports = HealthReport.objects.filter(user=request.user).order_by('-report_date') - return render(request, 'core/health_report_list.html', {'reports': reports}) - @login_required def upload_health_report(request): if request.method == "POST": @@ -697,7 +705,7 @@ def upload_health_report(request): allow_notifications=allow_notifications ) messages.success(request, "Health report uploaded successfully!") - return redirect('health_report_list') + return redirect('vaccination_dashboard') else: messages.error(request, "Please fill in all required fields.") diff --git a/media/blood_requests/Garden_City.jpg b/media/blood_requests/Garden_City.jpg new file mode 100644 index 0000000..b709e7b Binary files /dev/null and b/media/blood_requests/Garden_City.jpg differ