diff --git a/config/__pycache__/__init__.cpython-311.pyc b/config/__pycache__/__init__.cpython-311.pyc index 423a636..abb9e5e 100644 Binary files a/config/__pycache__/__init__.cpython-311.pyc and b/config/__pycache__/__init__.cpython-311.pyc differ diff --git a/config/__pycache__/settings.cpython-311.pyc b/config/__pycache__/settings.cpython-311.pyc index 96bce55..c051bcf 100644 Binary files a/config/__pycache__/settings.cpython-311.pyc and b/config/__pycache__/settings.cpython-311.pyc differ diff --git a/config/__pycache__/urls.cpython-311.pyc b/config/__pycache__/urls.cpython-311.pyc index 0b85e94..01d0673 100644 Binary files a/config/__pycache__/urls.cpython-311.pyc and b/config/__pycache__/urls.cpython-311.pyc differ diff --git a/config/__pycache__/wsgi.cpython-311.pyc b/config/__pycache__/wsgi.cpython-311.pyc index 9c49e09..dc8fc90 100644 Binary files a/config/__pycache__/wsgi.cpython-311.pyc and b/config/__pycache__/wsgi.cpython-311.pyc differ diff --git a/core/__pycache__/__init__.cpython-311.pyc b/core/__pycache__/__init__.cpython-311.pyc index 74b1112..8e9fc3d 100644 Binary files a/core/__pycache__/__init__.cpython-311.pyc and b/core/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index a5ed392..c16c351 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/apps.cpython-311.pyc b/core/__pycache__/apps.cpython-311.pyc index 6f131d4..1c28907 100644 Binary files a/core/__pycache__/apps.cpython-311.pyc and b/core/__pycache__/apps.cpython-311.pyc differ diff --git a/core/__pycache__/context_processors.cpython-311.pyc b/core/__pycache__/context_processors.cpython-311.pyc index 75bf223..10556ae 100644 Binary files a/core/__pycache__/context_processors.cpython-311.pyc and b/core/__pycache__/context_processors.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index e061640..33dad94 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 5a69659..bd06905 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 2a36fd6..bbc52d0 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 8c38f3f..d255c1f 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,3 +1,18 @@ from django.contrib import admin +from .models import Donor, BloodRequest, BloodBank -# Register your models here. +@admin.register(Donor) +class DonorAdmin(admin.ModelAdmin): + list_display = ('name', 'blood_group', 'location', 'is_available') + list_filter = ('blood_group', 'is_available') + search_fields = ('name', 'location') + +@admin.register(BloodRequest) +class BloodRequestAdmin(admin.ModelAdmin): + list_display = ('patient_name', 'blood_group', 'urgency', 'status', 'created_at') + list_filter = ('blood_group', 'urgency', 'status') + search_fields = ('patient_name', 'hospital') + +@admin.register(BloodBank) +class BloodBankAdmin(admin.ModelAdmin): + list_display = ('name', 'location') diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..2555f26 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,61 @@ +# Generated by Django 5.2.7 on 2026-02-17 13:38 + +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='BloodBank', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('location', models.CharField(max_length=255)), + ('stock_a_plus', models.IntegerField(default=0)), + ('stock_a_minus', models.IntegerField(default=0)), + ('stock_b_plus', models.IntegerField(default=0)), + ('stock_b_minus', models.IntegerField(default=0)), + ('stock_o_plus', models.IntegerField(default=0)), + ('stock_o_minus', models.IntegerField(default=0)), + ('stock_ab_plus', models.IntegerField(default=0)), + ('stock_ab_minus', models.IntegerField(default=0)), + ], + ), + migrations.CreateModel( + name='BloodRequest', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('patient_name', models.CharField(max_length=100)), + ('blood_group', models.CharField(choices=[('A+', 'A+'), ('A-', 'A-'), ('B+', 'B+'), ('B-', 'B-'), ('O+', 'O+'), ('O-', 'O-'), ('AB+', 'AB+'), ('AB-', 'AB-')], max_length=5)), + ('location', models.CharField(max_length=255)), + ('urgency', models.CharField(choices=[('CRITICAL', 'Critical'), ('URGENT', 'Urgent'), ('NORMAL', 'Normal')], default='NORMAL', max_length=10)), + ('hospital', models.CharField(max_length=255)), + ('contact_number', models.CharField(max_length=20)), + ('required_date', models.DateField(default=django.utils.timezone.now)), + ('status', models.CharField(default='Active', max_length=20)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + ), + migrations.CreateModel( + name='Donor', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('blood_group', models.CharField(choices=[('A+', 'A+'), ('A-', 'A-'), ('B+', 'B+'), ('B-', 'B-'), ('O+', 'O+'), ('O-', 'O-'), ('AB+', 'AB+'), ('AB-', 'AB-')], max_length=5)), + ('location', models.CharField(max_length=255)), + ('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)), + ('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)), + ('phone', models.CharField(max_length=20)), + ('is_available', models.BooleanField(default=True)), + ('last_donation_date', models.DateField(blank=True, null=True)), + ('vaccination_status', models.CharField(default='Unknown', max_length=100)), + ], + ), + ] diff --git a/core/migrations/0002_bloodbank_contact_number_bloodbank_is_24_7_and_more.py b/core/migrations/0002_bloodbank_contact_number_bloodbank_is_24_7_and_more.py new file mode 100644 index 0000000..8ce3046 --- /dev/null +++ b/core/migrations/0002_bloodbank_contact_number_bloodbank_is_24_7_and_more.py @@ -0,0 +1,38 @@ +# Generated by Django 5.2.7 on 2026-02-17 13:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='bloodbank', + name='contact_number', + field=models.CharField(blank=True, max_length=20, null=True), + ), + migrations.AddField( + model_name='bloodbank', + name='is_24_7', + field=models.BooleanField(default=True), + ), + migrations.AddField( + model_name='donor', + name='avatar_url', + field=models.URLField(blank=True, null=True), + ), + migrations.AddField( + model_name='donor', + name='email', + field=models.EmailField(blank=True, max_length=254, null=True), + ), + migrations.AddField( + model_name='donor', + name='last_vaccination_date', + field=models.DateField(blank=True, null=True), + ), + ] diff --git a/core/migrations/0003_donor_citizenship_no_donor_district_and_more.py b/core/migrations/0003_donor_citizenship_no_donor_district_and_more.py new file mode 100644 index 0000000..7d91b5a --- /dev/null +++ b/core/migrations/0003_donor_citizenship_no_donor_district_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.2.7 on 2026-02-17 13:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0002_bloodbank_contact_number_bloodbank_is_24_7_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='donor', + name='citizenship_no', + field=models.CharField(blank=True, max_length=50, null=True), + ), + migrations.AddField( + model_name='donor', + name='district', + field=models.CharField(default='Kathmandu', max_length=100), + ), + migrations.AddField( + model_name='donor', + name='is_verified', + field=models.BooleanField(default=False), + ), + ] diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..c162e57 Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/0002_bloodbank_contact_number_bloodbank_is_24_7_and_more.cpython-311.pyc b/core/migrations/__pycache__/0002_bloodbank_contact_number_bloodbank_is_24_7_and_more.cpython-311.pyc new file mode 100644 index 0000000..b20e5ab Binary files /dev/null and b/core/migrations/__pycache__/0002_bloodbank_contact_number_bloodbank_is_24_7_and_more.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/0003_donor_citizenship_no_donor_district_and_more.cpython-311.pyc b/core/migrations/__pycache__/0003_donor_citizenship_no_donor_district_and_more.cpython-311.pyc new file mode 100644 index 0000000..05ff597 Binary files /dev/null and b/core/migrations/__pycache__/0003_donor_citizenship_no_donor_district_and_more.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/__init__.cpython-311.pyc b/core/migrations/__pycache__/__init__.cpython-311.pyc index 9c833c8..c33b24d 100644 Binary files a/core/migrations/__pycache__/__init__.cpython-311.pyc and b/core/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..b7d3d8f 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,64 @@ from django.db import models +from django.utils import timezone -# Create your models here. +class Donor(models.Model): + BLOOD_GROUPS = [ + ('A+', 'A+'), ('A-', 'A-'), + ('B+', 'B+'), ('B-', 'B-'), + ('O+', 'O+'), ('O-', 'O-'), + ('AB+', 'AB+'), ('AB-', 'AB-'), + ] + name = models.CharField(max_length=100) + blood_group = models.CharField(max_length=5, choices=BLOOD_GROUPS) + district = models.CharField(max_length=100, default='Kathmandu') + location = models.CharField(max_length=255) + latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True, blank=True) + phone = models.CharField(max_length=20) + email = models.EmailField(null=True, blank=True) + is_available = models.BooleanField(default=True) + is_verified = models.BooleanField(default=False) + citizenship_no = models.CharField(max_length=50, null=True, blank=True) + last_donation_date = models.DateField(null=True, blank=True) + vaccination_status = models.CharField(max_length=100, default='Unknown') + last_vaccination_date = models.DateField(null=True, blank=True) + avatar_url = models.URLField(null=True, blank=True) + + def __str__(self): + return f"{self.name} ({self.blood_group}) - {'Verified' if self.is_verified else 'Unverified'}" + +class BloodRequest(models.Model): + URGENCY_LEVELS = [ + ('CRITICAL', 'Critical'), + ('URGENT', 'Urgent'), + ('NORMAL', 'Normal'), + ] + patient_name = models.CharField(max_length=100) + blood_group = models.CharField(max_length=5, choices=Donor.BLOOD_GROUPS) + location = models.CharField(max_length=255) + urgency = models.CharField(max_length=10, choices=URGENCY_LEVELS, default='NORMAL') + hospital = models.CharField(max_length=255) + contact_number = models.CharField(max_length=20) + required_date = models.DateField(default=timezone.now) + status = models.CharField(max_length=20, default='Active') + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"{self.blood_group} for {self.patient_name}" + +class BloodBank(models.Model): + name = models.CharField(max_length=100) + location = models.CharField(max_length=255) + contact_number = models.CharField(max_length=20, null=True, blank=True) + is_24_7 = models.BooleanField(default=True) + stock_a_plus = models.IntegerField(default=0) + stock_a_minus = models.IntegerField(default=0) + stock_b_plus = models.IntegerField(default=0) + stock_b_minus = models.IntegerField(default=0) + stock_o_plus = models.IntegerField(default=0) + stock_o_minus = models.IntegerField(default=0) + stock_ab_plus = models.IntegerField(default=0) + stock_ab_minus = models.IntegerField(default=0) + + def __str__(self): + return self.name diff --git a/core/templates/base.html b/core/templates/base.html index 1e7e5fb..73ae1ea 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -1,25 +1,272 @@ -
- -