diff --git a/project/accounts/migrations/0005_alter_doctor_experience_years_and_more.py b/project/accounts/migrations/0005_alter_doctor_experience_years_and_more.py new file mode 100644 index 0000000..ea92564 --- /dev/null +++ b/project/accounts/migrations/0005_alter_doctor_experience_years_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.3 on 2024-05-09 08:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0004_remove_patient_code"), + ] + + operations = [ + migrations.AlterField( + model_name="doctor", + name="experience_years", + field=models.PositiveIntegerField(blank=True, null=True), + ), + migrations.AlterField( + model_name="doctor", + name="license_number", + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AlterField( + model_name="doctor", + name="work_days", + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/project/accounts/models/doctor.py b/project/accounts/models/doctor.py index 2132114..6a047b2 100644 --- a/project/accounts/models/doctor.py +++ b/project/accounts/models/doctor.py @@ -1,9 +1,9 @@ from .models import * class Doctor(Profile): speciality = models.CharField(max_length=255) - license_number = models.CharField(max_length=255) - experience_years = models.PositiveIntegerField() - work_days= models.CharField(max_length=255) + license_number = models.CharField(max_length=255,blank=True,null=True) + experience_years = models.PositiveIntegerField( blank=True, null=True) + work_days= models.CharField(max_length=255,blank=True,null=True) def __str__(self): return self.first_name \ No newline at end of file diff --git a/project/accounts/tests/test_settings.py b/project/accounts/tests/test_settings.py new file mode 100644 index 0000000..5839e30 --- /dev/null +++ b/project/accounts/tests/test_settings.py @@ -0,0 +1,32 @@ +from accounts.tests.test_setup import * +from accounts.models import * + +from accounts.tests.test_setup import * +from accounts.models import * + + + +class PatientTest(TestSetup): + def setUp(self) -> None: + super().setUp() + self.staff, self.staff_token = self.create_staff() + + def test_create_doctor(self): + data = { + + + 'national_id': '012345678901234', + 'full_name': 'test', + + + + } + + # self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + self.staff_token) + response = self.client.post('/accounts/doctor/', data, + format='json', HTTP_AUTHORIZATION='Bearer ' + self.staff_token) + self.assertEqual(response.status_code, 400) + self.assertEqual(Doctor.objects.count(), 0) + self.assertEqual(User.objects.count(), 1) + + diff --git a/project/project/settings/base.py b/project/project/settings/base.py index 1385fd0..09c482f 100644 --- a/project/project/settings/base.py +++ b/project/project/settings/base.py @@ -179,7 +179,7 @@ "REFRESH_TOKEN_LIFETIME": timedelta(days=30), # Adjust based on requirements } -ATOMIC_REQUESTS = True +# ATOMIC_REQUESTS = True INTERNAL_IPS = [ # ... diff --git a/project/project/settings/local.py b/project/project/settings/local.py index b986288..86a38a4 100644 --- a/project/project/settings/local.py +++ b/project/project/settings/local.py @@ -15,5 +15,6 @@ 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', + 'ATOMIC_REQUESTS': True } } diff --git a/project/project/settings/production.py b/project/project/settings/production.py index fa8ad5f..f2d97da 100644 --- a/project/project/settings/production.py +++ b/project/project/settings/production.py @@ -9,7 +9,7 @@ db_config = dj_database_url.config(default=config("DATABASE_URL")) -# db_config['ATOMIC_REQUESTS'] = True +db_config['ATOMIC_REQUESTS'] = True DATABASES = { 'default': db_config,