diff --git a/.gitignore b/.gitignore index c3a75be4..b273a9b5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ db.sqlite3 .venv/ venv/ env/ +.env/ # IDE and editor settings .vscode/ .idea/ * @@ -20,4 +21,4 @@ env/ remotes/origin/main #System Files .DS_Store -Thumbs.db \ No newline at end of file +Thumbs.db diff --git a/answers/migrations/0001_initial.py b/answers/migrations/0001_initial.py index 3b189767..fe33b592 100644 --- a/answers/migrations/0001_initial.py +++ b/answers/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-17 10:37 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import django.db.models.deletion from django.db import migrations, models @@ -9,8 +9,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('questions', '0002_alter_epdsquestion_question'), - ('screeningtestscore', '0004_alter_screeningtestscore_total_score'), + ('questions', '0001_initial'), ] operations = [ @@ -20,7 +19,6 @@ class Migration(migrations.Migration): ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('score', models.IntegerField()), ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='questions.epdsquestion')), - ('test', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='screeningtestscore.screeningtestscore')), ], ), ] diff --git a/answers/migrations/0002_initial.py b/answers/migrations/0002_initial.py new file mode 100644 index 00000000..d71a403b --- /dev/null +++ b/answers/migrations/0002_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 5.1.1 on 2024-09-21 05:23 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('answers', '0001_initial'), + ('screeningtestscore', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='answer', + name='test', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='screeningtestscore.screeningtestscore'), + ), + ] diff --git a/api/serializers.py b/api/serializers.py index 5a57de5d..416cd354 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -10,15 +10,18 @@ from users.models import User from careguide.models import Careguide from answers.models import Answer +from rest_framework import serializers +from careguide.models import Careguide -# careguide -class CareguideSerializer(serializers.ModelSerializer): +class CareguideSerializer(serializers.ModelSerializer): + """ + CareguideSerializer: Serializes the Careguide model for API interactions. + Converts Careguide objects to and from JSON. + """ class Meta: - model = Careguide - fields = ['id', 'title', 'content', 'author'] + model = Careguide + fields = '__all__' - def __str__(self): - return self.title #nurse class NurseSerializer(serializers.ModelSerializer): @@ -155,5 +158,18 @@ class Meta: fields = ['id', 'question', 'test', 'score'] +#caregude + +class CareguideSerializer(serializers.ModelSerializer): + """ + CareguideSerializer: Serializes the Careguide model for API interactions. + Converts Careguide objects to and from JSON. + """ + class Meta: + model = Careguide + fields = '__all__' + + + \ No newline at end of file diff --git a/api/urls.py b/api/urls.py index 2b95e3ea..066bcf2f 100644 --- a/api/urls.py +++ b/api/urls.py @@ -12,9 +12,10 @@ from .views import CustomTokenObtainPairView from .views import UserRoleListCreateView from .views import UserProfileView - from .views import NurseListView, NurseDetailView, NurseAdminListView, NurseAdminDetailView -from .views import CareguideListCreateView, ScrapeCareguideView +from .views import ScrapeCareguideView + +from .views import CareguideListView, CareguideDetailView urlpatterns = [ path('nurses/', NurseListView.as_view(), name='nurse_list_view'), @@ -51,10 +52,12 @@ path('nextofkins/', NextOfKinListView.as_view(), name='nextofkins_list'), path('nextofkins//', NextOfKinDetailView.as_view(),name='nextofkin_detail_view'), path('nextofkins/search/', NextOfKinListView.as_view(), name='nextofkin-search'), - path('careguides/', CareguideListCreateView.as_view(), name='careguide-list-create'), path('scrape_careguide/', ScrapeCareguideView.as_view(), name='scrape-careguide'), path('answers/', AnswerListCreateView.as_view(), name='answer_list_create'), path('answers//', AnswerDetailView.as_view(), name='answer_detail'), + + path('careguides/', CareguideListView.as_view(), name='careguide-list'), + path('careguides//', CareguideDetailView.as_view(), name='careguide-detail'), ] diff --git a/api/views.py b/api/views.py index 04427549..07eb9fa1 100644 --- a/api/views.py +++ b/api/views.py @@ -42,11 +42,13 @@ from rest_framework.views import APIView from rest_framework import status from careguide.models import Careguide -from .serializers import CareguideSerializer from rest_framework.response import Response from rest_framework import status from rest_framework.views import APIView from .serializers import ScreeningTestScoreSerializer +from django.http import Http404 +from careguide.models import Careguide +from .serializers import CareguideSerializer class CareguideListCreateView(generics.ListCreateAPIView): queryset = Careguide.objects.all() @@ -73,11 +75,6 @@ def post(self, request): except Exception as e: return Response({"error": str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) -class CareguideListView(APIView): - def get(self, request): - careguides = Careguide.objects.all() - serializer = CareguideSerializer(careguides, many=True) - return Response(serializer.data, status=status.HTTP_200_OK) class NurseListView(APIView): @@ -745,13 +742,12 @@ class UserProfileView(APIView): permission_classes = [IsAuthenticated] def get(self, request): - # Assuming you have a User model and a UserSerializer to handle user data - user = request.user # Get the logged-in user + user = request.user serializer = UserSerializer(user) return Response(serializer.data, status=status.HTTP_200_OK) def put(self, request): - user = request.user # Get the logged-in user + user = request.user serializer = UserSerializer(user, data=request.data, partial=True) if serializer.is_valid(): serializer.save() @@ -763,4 +759,84 @@ def put(self, request): "message": "Invalid data", "errors": serializer.errors }, status=status.HTTP_400_BAD_REQUEST) - + + +#careguide + +class CareguideListView(APIView): + + def post(self, request): + """ + Create a new careguide entry. + """ + serializer = CareguideSerializer(data=request.data) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data, status=status.HTTP_201_CREATED) + else: + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + """ + API View for getting a list of careguides and creating a new careguide. + """ + + def get(self, request): + """ + Get a list of careguides. + """ + careguides = self.get_queryset() + serializer = CareguideSerializer(careguides, many=True) + return Response(serializer.data) + + + def get_queryset(self): + """ + Retrieve a queryset of careguides. Optionally filter by category. + """ + queryset = Careguide.objects.filter(is_active=True) + category = self.request.query_params.get('category', None) + if category: + queryset = queryset.filter(category=category) + return queryset + +class CareguideDetailView(APIView): + """ + API View for retrieving, updating, and soft-deleting a specific careguide. + """ + + def get_object(self, pk): + """ + Helper method to get a careguide object by primary key. + """ + try: + return Careguide.objects.get(pk=pk) + except Careguide.DoesNotExist: + raise Http404 + + def get(self, request, pk): + """ + Retrieve a specific careguide by its primary key. + """ + careguide = self.get_object(pk) + serializer = CareguideSerializer(careguide) + return Response(serializer.data) + + def patch(self, request, pk): + """ + Partially update a specific careguide. + """ + careguide = self.get_object(pk) + serializer = CareguideSerializer(careguide, data=request.data, partial=True) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + + def delete(self, request, pk): + """ + Soft-delete a specific careguide by marking it inactive instead of deleting it from the database. + """ + careguide = self.get_object(pk) + careguide.is_active = False + careguide.save() + return Response({"message": "Article deleted successfully."}, status=status.HTTP_204_NO_CONTENT) + \ No newline at end of file diff --git a/authentication/migrations/0001_initial.py b/authentication/migrations/0001_initial.py index 6691e524..6f7819e4 100644 --- a/authentication/migrations/0001_initial.py +++ b/authentication/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import django.contrib.auth.models import django.contrib.auth.validators diff --git a/careguide/admin.py b/careguide/admin.py index 4ad744d2..0919ad1d 100644 --- a/careguide/admin.py +++ b/careguide/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin -from .models import Careguide; admin.site.register(Careguide) +from .models import Careguide +admin.site.register(Careguide) diff --git a/careguide/migrations/0001_initial.py b/careguide/migrations/0001_initial.py index 1da124c5..2f2c9223 100644 --- a/careguide/migrations/0001_initial.py +++ b/careguide/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 5.1.1 on 2024-09-16 07:36 +# Generated by Django 5.1.1 on 2024-09-21 05:23 +import tinymce.models from django.db import migrations, models @@ -12,12 +13,17 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Resources', + name='Careguide', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), + ('careguide_id', models.AutoField(primary_key=True, serialize=False)), + ('category', models.CharField(max_length=200)), ('title', models.CharField(max_length=255)), - ('content', models.TextField()), + ('image', models.ImageField(blank=True, null=True, upload_to='caregude_images/')), + ('subtitle', models.CharField(blank=True, max_length=255, null=True)), + ('content', tinymce.models.HTMLField()), ('author', models.CharField(blank=True, max_length=100, null=True)), + ('last_updated', models.DateTimeField(auto_now=True)), + ('is_active', models.BooleanField(default=True)), ], ), ] diff --git a/careguide/migrations/0002_alter_careguide_image.py b/careguide/migrations/0002_alter_careguide_image.py new file mode 100644 index 00000000..dd08d161 --- /dev/null +++ b/careguide/migrations/0002_alter_careguide_image.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.1 on 2024-09-21 05:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('careguide', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='careguide', + name='image', + field=models.URLField(blank=True, max_length=255, null=True), + ), + ] diff --git a/careguide/migrations/0002_rename_resources_careguide.py b/careguide/migrations/0002_rename_resources_careguide.py deleted file mode 100644 index 515f28b4..00000000 --- a/careguide/migrations/0002_rename_resources_careguide.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-16 08:02 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('careguide', '0001_initial'), - ] - - operations = [ - migrations.RenameModel( - old_name='Resources', - new_name='Careguide', - ), - ] diff --git a/careguide/migrations/0003_careguide_last_updated.py b/careguide/migrations/0003_careguide_last_updated.py deleted file mode 100644 index 5fd03d08..00000000 --- a/careguide/migrations/0003_careguide_last_updated.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-16 12:26 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('careguide', '0002_rename_resources_careguide'), - ] - - operations = [ - migrations.AddField( - model_name='careguide', - name='last_updated', - field=models.DateTimeField(auto_now=True), - ), - ] diff --git a/careguide/models.py b/careguide/models.py index 2ecdcc41..5f27aa47 100644 --- a/careguide/models.py +++ b/careguide/models.py @@ -1,21 +1,26 @@ -from django.core.exceptions import ValidationError from django.db import models +from django.core.exceptions import ValidationError +from tinymce.models import HTMLField class Careguide(models.Model): - id = models.AutoField(primary_key=True) + careguide_id = models.AutoField(primary_key=True) + category = models.CharField(max_length=200) title = models.CharField(max_length=255) - content = models.TextField() + image = models.URLField(max_length=255, blank=True, null=True) + subtitle = models.CharField(max_length=255, blank=True, null=True) + content = HTMLField() author = models.CharField(max_length=100, blank=True, null=True) - last_updated = models.DateTimeField(auto_now=True) + last_updated = models.DateTimeField(auto_now=True) + is_active = models.BooleanField(default=True) + def clean(self): - if not self.title: raise ValidationError('Title cannot be empty.') - + def save(self, *args, **kwargs): - self.clean() - super().save(*args, **kwargs) - + self.clean() + super().save(*args, **kwargs) + def __str__(self): return self.title diff --git a/careguide/tests.py b/careguide/tests.py index 6cdc00a8..bf803e91 100644 --- a/careguide/tests.py +++ b/careguide/tests.py @@ -1,68 +1,110 @@ -from django.core.exceptions import ValidationError from django.test import TestCase from careguide.models import Careguide +from django.core.exceptions import ValidationError + class CareguideModelTest(TestCase): + + def setUp(self): + # Create a Careguide instance for testing + self.careguide = Careguide.objects.create( + category="Mental Health", + title="Postpartum Care", + image="http://example.com/image.jpg", + subtitle="A guide for postpartum care", + content="

Postpartum Care

Content here

", + author="Dr. Jane Doe" + ) def test_careguide_creation(self): + # Test if the Careguide instance was created successfully + self.assertEqual(self.careguide.category, "Mental Health") + self.assertEqual(self.careguide.title, "Postpartum Care") + self.assertEqual(self.careguide.image, "http://example.com/image.jpg") + self.assertEqual(self.careguide.subtitle, "A guide for postpartum care") + self.assertEqual(self.careguide.author, "Dr. Jane Doe") + + def test_careguide_str(self): + # Test the __str__ method of the Careguide model + self.assertEqual(str(self.careguide), "Postpartum Care") + + +class CareguideModelUnhappyTest(TestCase): + + def test_missing_title(self): """ - Happy path: Test if the Careguide object is created successfully with valid data. + Test creating a Careguide instance with a missing title should raise a ValidationError. """ - careguide = Careguide.objects.create( - title="Sample Title", - content="Sample content for Careguide.", - author="Author" + careguide = Careguide( + category="Mental Health", + image="http://example.com/image.jpg", + subtitle="A guide for postpartum care", + content="

Postpartum Care

Content here

", + author="Dr. Jane Doe" ) - self.assertEqual(careguide.title, "Sample Title") - self.assertEqual(careguide.content, "Sample content for Careguide.") - self.assertEqual(careguide.author, "Author") + with self.assertRaises(ValidationError): + careguide.full_clean() - def test_careguide_blank_author(self): + def test_invalid_image_url(self): """ - Happy path: Test if a Careguide object can be created with a blank author field. + Test creating a Careguide instance with an invalid URL for the image should raise a ValidationError. """ - careguide = Careguide.objects.create( - title="Sample Title", - content="Sample content for Careguide.", - author="" + careguide = Careguide( + category="Mental Health", + title="Postpartum Care", + image="invalid_url", # Invalid URL format + subtitle="A guide for postpartum care", + content="

Postpartum Care

Content here

", + author="Dr. Jane Doe" ) - self.assertEqual(careguide.title, "Sample Title") - self.assertEqual(careguide.content, "Sample content for Careguide.") - self.assertEqual(careguide.author, "") + with self.assertRaises(ValidationError): + careguide.full_clean() - def test_careguide_creation_without_title(self): + def test_missing_category(self): """ - Unhappy path: Test if a Careguide object raises a ValidationError when created without a title. + Test creating a Careguide instance with a missing category should raise a ValidationError. """ careguide = Careguide( - title="", - content="Content", - author="Author" + category="", + title="Postpartum Care", + image="http://example.com/image.jpg", + subtitle="A guide for postpartum care", + content="

Postpartum Care

Content here

", + author="Dr. Jane Doe" ) - with self.assertRaises(ValidationError) as cm: + with self.assertRaises(ValidationError): careguide.full_clean() - self.assertIn('Title cannot be empty.', str(cm.exception)) - def test_careguide_title_max_length(self): + def test_missing_content(self): """ - Unhappy path: Test if Careguide object raises a ValidationError for exceeding title max length. + Test creating a Careguide instance with missing content should raise a ValidationError. """ careguide = Careguide( - title="A" * 256, - content="Content", - author="Author" + category="Mental Health", + title="Postpartum Care", + image="http://example.com/image.jpg", + subtitle="A guide for postpartum care", + content="", # Missing content + author="Dr. Jane Doe" ) - with self.assertRaises(ValidationError) as cm: + with self.assertRaises(ValidationError): careguide.full_clean() - self.assertIn('Ensure this value has at most 255 characters (it has 256).', str(cm.exception)) - def test_careguide_creation_without_content(self): + def test_missing_author(self): """ - Unhappy path: Test if a Careguide object can be created with empty content. + Test creating a Careguide instance without an author (optional field). + Since the author field is optional, this should pass. """ - careguide = Careguide.objects.create( - title="Sample Title", - content="", - author="Author" + careguide = Careguide( + category="Mental Health", + title="Postpartum Care", + image="http://example.com/image.jpg", + subtitle="A guide for postpartum care", + content="

Postpartum Care

Content here

" + # No author provided ) - self.assertEqual(careguide.content, "") + try: + careguide.full_clean() # Should pass without raising an error + except ValidationError: + self.fail("Careguide.full_clean() raised ValidationError unexpectedly!") + diff --git a/community_health_promoter/migrations/0001_initial.py b/community_health_promoter/migrations/0001_initial.py index c545c39f..cd1b46a1 100644 --- a/community_health_promoter/migrations/0001_initial.py +++ b/community_health_promoter/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 +import django.core.validators from django.db import migrations, models @@ -14,10 +15,10 @@ class Migration(migrations.Migration): migrations.CreateModel( name='CHP', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('registered_date', models.DateField()), ('reg_no', models.CharField(max_length=255)), - ('phone_number', models.CharField(max_length=15)), + ('phone_number', models.CharField(max_length=15, validators=[django.core.validators.RegexValidator(message='Phone number must be exactly 10 digits.', regex='^\\d{10}$')])), ('location', models.TextField()), ('sub_location', models.CharField(max_length=255)), ('village', models.CharField(max_length=255)), diff --git a/community_health_promoter/migrations/0002_initial.py b/community_health_promoter/migrations/0002_initial.py index f73aeb1f..6c0f00a2 100644 --- a/community_health_promoter/migrations/0002_initial.py +++ b/community_health_promoter/migrations/0002_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import django.db.models.deletion from django.conf import settings @@ -17,7 +17,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name='chp', - name='user_id', + name='user', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), ), ] diff --git a/community_health_promoter/migrations/0003_remove_chp_user_id.py b/community_health_promoter/migrations/0003_remove_chp_user_id.py deleted file mode 100644 index 0077b0e1..00000000 --- a/community_health_promoter/migrations/0003_remove_chp_user_id.py +++ /dev/null @@ -1,16 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-14 11:46 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("community_health_promoter", "0002_initial"), - ] - - operations = [ - migrations.RemoveField( - model_name="chp", - name="user_id", - ), - ] diff --git a/community_health_promoter/migrations/0004_chp_user_id.py b/community_health_promoter/migrations/0004_chp_user_id.py deleted file mode 100644 index 1d165a6e..00000000 --- a/community_health_promoter/migrations/0004_chp_user_id.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-14 12:22 - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("community_health_promoter", "0003_remove_chp_user_id"), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.AddField( - model_name="chp", - name="user_id", - field=models.ForeignKey( - default=1, - on_delete=django.db.models.deletion.CASCADE, - to=settings.AUTH_USER_MODEL, - ), - preserve_default=False, - ), - ] diff --git a/community_health_promoter/migrations/0005_alter_chp_id.py b/community_health_promoter/migrations/0005_alter_chp_id.py deleted file mode 100644 index 6d0097e2..00000000 --- a/community_health_promoter/migrations/0005_alter_chp_id.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 12:32 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("community_health_promoter", "0004_chp_user_id"), - ] - - operations = [ - migrations.AlterField( - model_name="chp", - name="id", - field=models.BigAutoField( - auto_created=True, primary_key=True, serialize=False, verbose_name="ID" - ), - ), - ] diff --git a/community_health_promoter/migrations/0006_rename_user_id_chp_user.py b/community_health_promoter/migrations/0006_rename_user_id_chp_user.py deleted file mode 100644 index d29a67b5..00000000 --- a/community_health_promoter/migrations/0006_rename_user_id_chp_user.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 12:40 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("community_health_promoter", "0005_alter_chp_id"), - ] - - operations = [ - migrations.RenameField( - model_name="chp", - old_name="user_id", - new_name="user", - ), - ] diff --git a/community_health_promoter/migrations/0007_alter_chp_phone_number.py b/community_health_promoter/migrations/0007_alter_chp_phone_number.py deleted file mode 100644 index 64ac8b04..00000000 --- a/community_health_promoter/migrations/0007_alter_chp_phone_number.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 20:55 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("community_health_promoter", "0006_rename_user_id_chp_user"), - ] - - operations = [ - migrations.AlterField( - model_name="chp", - name="phone_number", - field=models.CharField( - max_length=15, - validators=[ - django.core.validators.RegexValidator( - message="Phone number must be exactly 10 digits.", - regex="^\\d{10}$", - ) - ], - ), - ), - ] diff --git a/hospital/migrations/0001_initial.py b/hospital/migrations/0001_initial.py index 2e0d5273..2631e079 100644 --- a/hospital/migrations/0001_initial.py +++ b/hospital/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 from django.db import migrations, models diff --git a/mamamind/settings.py b/mamamind/settings.py index ea599236..d0383692 100644 --- a/mamamind/settings.py +++ b/mamamind/settings.py @@ -70,6 +70,7 @@ 'careguide', 'django_crontab', 'answers', + 'tinymce', ] diff --git a/mother/migrations/0001_initial.py b/mother/migrations/0001_initial.py index 556d46fc..fe93a469 100644 --- a/mother/migrations/0001_initial.py +++ b/mother/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 from django.db import migrations, models @@ -18,8 +18,8 @@ class Migration(migrations.Migration): ('first_name', models.CharField(max_length=100)), ('last_name', models.CharField(max_length=100)), ('date_of_birth', models.DateField()), - ('no_of_children', models.IntegerField()), - ('date_of_reg', models.DateField()), + ('no_of_children', models.PositiveIntegerField()), + ('date_of_reg', models.DateField(blank=True, null=True)), ('tel_no', models.CharField(max_length=15)), ('marital_status', models.CharField(max_length=20)), ('sub_location', models.CharField(max_length=100)), diff --git a/mother/migrations/0002_alter_mother_no_of_children.py b/mother/migrations/0002_alter_mother_no_of_children.py deleted file mode 100644 index 04528be3..00000000 --- a/mother/migrations/0002_alter_mother_no_of_children.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 20:55 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("mother", "0001_initial"), - ] - - operations = [ - migrations.AlterField( - model_name="mother", - name="no_of_children", - field=models.PositiveIntegerField(), - ), - ] diff --git a/mother/migrations/0003_alter_mother_date_of_reg.py b/mother/migrations/0003_alter_mother_date_of_reg.py deleted file mode 100644 index 529bdf6e..00000000 --- a/mother/migrations/0003_alter_mother_date_of_reg.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-16 07:38 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('mother', '0002_alter_mother_no_of_children'), - ] - - operations = [ - migrations.AlterField( - model_name='mother', - name='date_of_reg', - field=models.DateField(blank=True, null=True), - ), - ] diff --git a/mother/models.py b/mother/models.py index 738ca565..82d278b2 100644 --- a/mother/models.py +++ b/mother/models.py @@ -10,7 +10,6 @@ class Mother(models.Model): no_of_children = models.PositiveIntegerField() # Only allows non-negative integers date_of_reg = models.DateField(null=True, blank=True) tel_no = models.CharField(max_length=15) - marital_status = models.CharField(max_length=20) sub_location = models.CharField(max_length=100) village = models.CharField(max_length=100) diff --git a/next_of_kin/migrations/0001_initial.py b/next_of_kin/migrations/0001_initial.py index 31d37e4a..b6a88954 100644 --- a/next_of_kin/migrations/0001_initial.py +++ b/next_of_kin/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import django.db.models.deletion from django.db import migrations, models diff --git a/nurse/migrations/0001_initial.py b/nurse/migrations/0001_initial.py index 03effcba..9f914953 100644 --- a/nurse/migrations/0001_initial.py +++ b/nurse/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 +import django.core.validators import django.db.models.deletion from django.db import migrations, models @@ -18,7 +19,7 @@ class Migration(migrations.Migration): fields=[ ('nurse_id', models.AutoField(primary_key=True, serialize=False)), ('gender', models.CharField(choices=[('Male', 'Male'), ('Female', 'Female')], max_length=6)), - ('tel_no', models.CharField(max_length=15)), + ('tel_no', models.CharField(max_length=15, validators=[django.core.validators.RegexValidator(message="Phone number must be between 10 and 15 digits and start with '+' if international.", regex='^\\+?\\d{10,15}$')])), ('reg_no', models.CharField(max_length=50)), ('sub_location', models.CharField(max_length=255)), ('hospital_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hospital.hospital')), diff --git a/nurse/migrations/0002_initial.py b/nurse/migrations/0002_initial.py index a68f53c5..085e1a17 100644 --- a/nurse/migrations/0002_initial.py +++ b/nurse/migrations/0002_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import django.db.models.deletion from django.conf import settings diff --git a/nurse/migrations/0003_rename_user_nurse_user_id.py b/nurse/migrations/0003_rename_user_nurse_user_id.py deleted file mode 100644 index e519baad..00000000 --- a/nurse/migrations/0003_rename_user_nurse_user_id.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-14 07:52 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("nurse", "0002_initial"), - ] - - operations = [ - migrations.RenameField( - model_name="nurse", - old_name="user", - new_name="user_id", - ), - ] diff --git a/nurse/migrations/0004_rename_user_id_nurse_user.py b/nurse/migrations/0004_rename_user_id_nurse_user.py deleted file mode 100644 index 4795d069..00000000 --- a/nurse/migrations/0004_rename_user_id_nurse_user.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 11:34 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("nurse", "0003_rename_user_nurse_user_id"), - ] - - operations = [ - migrations.RenameField( - model_name="nurse", - old_name="user_id", - new_name="user", - ), - ] diff --git a/nurse/migrations/0005_alter_nurse_tel_no.py b/nurse/migrations/0005_alter_nurse_tel_no.py deleted file mode 100644 index e4072a9c..00000000 --- a/nurse/migrations/0005_alter_nurse_tel_no.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 20:55 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("nurse", "0004_rename_user_id_nurse_user"), - ] - - operations = [ - migrations.AlterField( - model_name="nurse", - name="tel_no", - field=models.CharField( - max_length=15, - validators=[ - django.core.validators.RegexValidator( - message="Phone number must be between 10 and 15 digits and start with '+' if international.", - regex="^\\+?\\d{10,15}$", - ) - ], - ), - ), - ] diff --git a/nurse_admin/migrations/0001_initial.py b/nurse_admin/migrations/0001_initial.py index cfdf7eb5..14143cff 100644 --- a/nurse_admin/migrations/0001_initial.py +++ b/nurse_admin/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 +import django.core.validators import django.db.models.deletion from django.db import migrations, models @@ -19,7 +20,7 @@ class Migration(migrations.Migration): ('admin_id', models.AutoField(primary_key=True, serialize=False)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), - ('tel_no', models.CharField(max_length=15)), + ('tel_no', models.CharField(max_length=15, validators=[django.core.validators.RegexValidator(message="Phone number must be between 10 and 15 digits and start with '+'", regex='^\\+?\\d{10,15}$')])), ('location', models.CharField(max_length=255)), ('sub_location', models.CharField(max_length=255)), ('hospital_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hospital.hospital')), diff --git a/nurse_admin/migrations/0002_initial.py b/nurse_admin/migrations/0002_initial.py index e4dc7466..70a84a77 100644 --- a/nurse_admin/migrations/0002_initial.py +++ b/nurse_admin/migrations/0002_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import django.db.models.deletion from django.conf import settings diff --git a/nurse_admin/migrations/0003_rename_user_nurseadmin_user_id.py b/nurse_admin/migrations/0003_rename_user_nurseadmin_user_id.py deleted file mode 100644 index deec585c..00000000 --- a/nurse_admin/migrations/0003_rename_user_nurseadmin_user_id.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-14 07:52 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("nurse_admin", "0002_initial"), - ] - - operations = [ - migrations.RenameField( - model_name="nurseadmin", - old_name="user", - new_name="user_id", - ), - ] diff --git a/nurse_admin/migrations/0004_rename_user_id_nurseadmin_user.py b/nurse_admin/migrations/0004_rename_user_id_nurseadmin_user.py deleted file mode 100644 index c4163da0..00000000 --- a/nurse_admin/migrations/0004_rename_user_id_nurseadmin_user.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 11:39 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("nurse_admin", "0003_rename_user_nurseadmin_user_id"), - ] - - operations = [ - migrations.RenameField( - model_name="nurseadmin", - old_name="user_id", - new_name="user", - ), - ] diff --git a/nurse_admin/migrations/0005_alter_nurseadmin_tel_no.py b/nurse_admin/migrations/0005_alter_nurseadmin_tel_no.py deleted file mode 100644 index 4d90d569..00000000 --- a/nurse_admin/migrations/0005_alter_nurseadmin_tel_no.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 20:55 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("nurse_admin", "0004_rename_user_id_nurseadmin_user"), - ] - - operations = [ - migrations.AlterField( - model_name="nurseadmin", - name="tel_no", - field=models.CharField( - max_length=15, - validators=[ - django.core.validators.RegexValidator( - message="Phone number must be between 10 and 15 digits and start with '+'", - regex="^\\+?\\d{10,15}$", - ) - ], - ), - ), - ] diff --git a/questions/migrations/0001_initial.py b/questions/migrations/0001_initial.py index 076b2db4..6081c6fe 100644 --- a/questions/migrations/0001_initial.py +++ b/questions/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 from django.db import migrations, models @@ -15,7 +15,7 @@ class Migration(migrations.Migration): name='EPDSQuestion', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('question', models.TextField()), + ('question', models.TextField(unique=True)), ('option_1', models.TextField()), ('first_score', models.IntegerField()), ('option_2', models.TextField()), diff --git a/questions/migrations/0002_alter_epdsquestion_question.py b/questions/migrations/0002_alter_epdsquestion_question.py deleted file mode 100644 index c600c1dd..00000000 --- a/questions/migrations/0002_alter_epdsquestion_question.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 17:20 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("questions", "0001_initial"), - ] - - operations = [ - migrations.AlterField( - model_name="epdsquestion", - name="question", - field=models.TextField(unique=True), - ), - ] diff --git a/screeningtestscore/migrations/0001_initial.py b/screeningtestscore/migrations/0001_initial.py index 67a813ea..5bff6d2c 100644 --- a/screeningtestscore/migrations/0001_initial.py +++ b/screeningtestscore/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import django.db.models.deletion from django.db import migrations, models diff --git a/screeningtestscore/migrations/0002_rename_chp_id_screeningtestscore_chp_and_more.py b/screeningtestscore/migrations/0002_rename_chp_id_screeningtestscore_chp_and_more.py deleted file mode 100644 index ea5cc5e6..00000000 --- a/screeningtestscore/migrations/0002_rename_chp_id_screeningtestscore_chp_and_more.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 18:21 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("screeningtestscore", "0001_initial"), - ] - - operations = [ - migrations.RenameField( - model_name="screeningtestscore", - old_name="chp_id", - new_name="chp", - ), - migrations.RenameField( - model_name="screeningtestscore", - old_name="mother_id", - new_name="mother", - ), - ] diff --git a/screeningtestscore/migrations/0003_alter_screeningtestscore_total_score.py b/screeningtestscore/migrations/0003_alter_screeningtestscore_total_score.py deleted file mode 100644 index 459d01ec..00000000 --- a/screeningtestscore/migrations/0003_alter_screeningtestscore_total_score.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 20:06 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("screeningtestscore", "0002_rename_chp_id_screeningtestscore_chp_and_more"), - ] - - operations = [ - migrations.AlterField( - model_name="screeningtestscore", - name="total_score", - field=models.IntegerField(), - ), - ] diff --git a/screeningtestscore/migrations/0004_alter_screeningtestscore_total_score.py b/screeningtestscore/migrations/0004_alter_screeningtestscore_total_score.py deleted file mode 100644 index 9c40d786..00000000 --- a/screeningtestscore/migrations/0004_alter_screeningtestscore_total_score.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-15 20:55 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("screeningtestscore", "0003_alter_screeningtestscore_total_score"), - ] - - operations = [ - migrations.AlterField( - model_name="screeningtestscore", - name="total_score", - field=models.PositiveSmallIntegerField(), - ), - ] diff --git a/screeningtestscore/migrations/0005_rename_chp_screeningtestscore_chp_id_and_more.py b/screeningtestscore/migrations/0005_rename_chp_screeningtestscore_chp_id_and_more.py deleted file mode 100644 index ce5d3a61..00000000 --- a/screeningtestscore/migrations/0005_rename_chp_screeningtestscore_chp_id_and_more.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-17 13:52 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('screeningtestscore', '0004_alter_screeningtestscore_total_score'), - ] - - operations = [ - migrations.RenameField( - model_name='screeningtestscore', - old_name='chp', - new_name='chp_id', - ), - migrations.RenameField( - model_name='screeningtestscore', - old_name='mother', - new_name='mothe_id', - ), - ] diff --git a/screeningtestscore/migrations/0006_rename_mothe_id_screeningtestscore_mother_id.py b/screeningtestscore/migrations/0006_rename_mothe_id_screeningtestscore_mother_id.py deleted file mode 100644 index ae7e7878..00000000 --- a/screeningtestscore/migrations/0006_rename_mothe_id_screeningtestscore_mother_id.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.1.1 on 2024-09-17 13:53 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('screeningtestscore', '0005_rename_chp_screeningtestscore_chp_id_and_more'), - ] - - operations = [ - migrations.RenameField( - model_name='screeningtestscore', - old_name='mothe_id', - new_name='mother_id', - ), - ] diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py index f282b9ac..b16c204b 100644 --- a/users/migrations/0001_initial.py +++ b/users/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.1 on 2024-09-13 10:57 +# Generated by Django 5.1.1 on 2024-09-21 05:23 import datetime from django.db import migrations, models