From e701f9af925f26c6e72c4e776653c348d9363947 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Wed, 2 Aug 2023 09:41:02 +0530 Subject: [PATCH 1/3] Add weekly working hours field for users --- care/users/api/serializers/user.py | 2 ++ .../0006_user_weekly_working_hours.py | 24 +++++++++++++++++++ care/users/models.py | 3 +++ 3 files changed, 29 insertions(+) create mode 100644 care/users/migrations/0006_user_weekly_working_hours.py diff --git a/care/users/api/serializers/user.py b/care/users/api/serializers/user.py index b845d3bdc4..c7f5c75056 100644 --- a/care/users/api/serializers/user.py +++ b/care/users/api/serializers/user.py @@ -284,6 +284,7 @@ class Meta: "doctor_medical_council_registration", "created_by", "home_facility", + "weekly_working_hours", "local_body", "district", "state", @@ -398,6 +399,7 @@ class Meta: "doctor_qualification", "doctor_experience_commenced_on", "doctor_medical_council_registration", + "weekly_working_hours", "created_by", "last_login", "home_facility_object", diff --git a/care/users/migrations/0006_user_weekly_working_hours.py b/care/users/migrations/0006_user_weekly_working_hours.py new file mode 100644 index 0000000000..3e5ccf960e --- /dev/null +++ b/care/users/migrations/0006_user_weekly_working_hours.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.2 on 2023-08-01 19:32 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("users", "0005_alter_user_alt_phone_number_alter_user_phone_number"), + ] + + operations = [ + migrations.AddField( + model_name="user", + name="weekly_working_hours", + field=models.IntegerField( + default=168, + validators=[ + django.core.validators.MinValueValidator(0), + django.core.validators.MaxValueValidator(168), + ], + ), + ), + ] diff --git a/care/users/models.py b/care/users/models.py index e5578e340d..2cfb5192a4 100644 --- a/care/users/models.py +++ b/care/users/models.py @@ -243,6 +243,9 @@ class User(AbstractUser): home_facility = models.ForeignKey( "facility.Facility", on_delete=models.PROTECT, null=True, blank=True ) + weekly_working_hours = models.IntegerField( + default=168, validators=[MinValueValidator(0), MaxValueValidator(168)] + ) doctor_qualification = models.TextField( blank=False, From 19ef1ffdfa7f56dcdeef0538f9d131402dc8f8b2 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:04:45 +0530 Subject: [PATCH 2/3] Fix tests --- care/users/tests/test_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/care/users/tests/test_api.py b/care/users/tests/test_api.py index fb3ba702c7..be8c502ce8 100644 --- a/care/users/tests/test_api.py +++ b/care/users/tests/test_api.py @@ -34,6 +34,7 @@ def get_detail_representation(self, obj=None) -> dict: "doctor_experience_commenced_on": obj.doctor_experience_commenced_on, "doctor_medical_council_registration": obj.doctor_medical_council_registration, "doctor_qualification": obj.doctor_qualification, + "weekly_working_hours": obj.weekly_working_hours, **self.get_local_body_district_state_representation(obj), } From 6288c3a20817f7b7317067a4b35fd098fc76c51a Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:15:49 +0530 Subject: [PATCH 3/3] remove default value --- care/users/migrations/0006_user_weekly_working_hours.py | 5 +++-- care/users/models.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/care/users/migrations/0006_user_weekly_working_hours.py b/care/users/migrations/0006_user_weekly_working_hours.py index 3e5ccf960e..39b1cc43c8 100644 --- a/care/users/migrations/0006_user_weekly_working_hours.py +++ b/care/users/migrations/0006_user_weekly_working_hours.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-08-01 19:32 +# Generated by Django 4.2.2 on 2023-08-02 04:39 import django.core.validators from django.db import migrations, models @@ -14,7 +14,8 @@ class Migration(migrations.Migration): model_name="user", name="weekly_working_hours", field=models.IntegerField( - default=168, + blank=True, + null=True, validators=[ django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(168), diff --git a/care/users/models.py b/care/users/models.py index 2cfb5192a4..615019485b 100644 --- a/care/users/models.py +++ b/care/users/models.py @@ -244,7 +244,7 @@ class User(AbstractUser): "facility.Facility", on_delete=models.PROTECT, null=True, blank=True ) weekly_working_hours = models.IntegerField( - default=168, validators=[MinValueValidator(0), MaxValueValidator(168)] + validators=[MinValueValidator(0), MaxValueValidator(168)], null=True, blank=True ) doctor_qualification = models.TextField(