add org_type_field to oragnization type serializer
This commit is contained in:
@@ -203,6 +203,7 @@ class OrganizationTypeSerializer(serializers.ModelSerializer):
|
||||
'id',
|
||||
'key',
|
||||
'name',
|
||||
'org_type_field',
|
||||
]
|
||||
|
||||
|
||||
@@ -225,6 +226,10 @@ class OrganizationSerializer(serializers.ModelSerializer):
|
||||
extra_kwargs = {}
|
||||
|
||||
def validate(self, attrs):
|
||||
"""
|
||||
@ validate national_unique_code to be unique
|
||||
@ validate to organization type field
|
||||
"""
|
||||
national_unique_id = self.context['request'].data['organization']['national_unique_id']
|
||||
|
||||
if not self.instance:
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0 on 2025-10-28 12:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('authentication', '0039_remove_organizationtype_region_scope'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='organizationtype',
|
||||
name='org_type_field',
|
||||
field=models.CharField(choices=[('CI', 'city'), ('CO', 'country'), ('PR', 'province')], max_length=25, null=True),
|
||||
),
|
||||
]
|
||||
@@ -85,6 +85,11 @@ class OrganizationType(BaseModel):
|
||||
key = models.CharField(choices=organization_keys, default='EMP', max_length=3)
|
||||
name = models.CharField(max_length=50, unique=True, null=True)
|
||||
code = models.IntegerField(default=0)
|
||||
org_type_field = models.CharField(choices=[
|
||||
('CI', 'city'),
|
||||
('CO', 'country'),
|
||||
('PR', 'province'),
|
||||
], max_length=25, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.key}-{self.name}'
|
||||
|
||||
@@ -323,3 +323,10 @@ django.core.exceptions.FieldError: Unsupported lookup 'name' for ForeignKey or j
|
||||
[2025-10-28 14:35:00,268] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\core\api.py changed, reloading.
|
||||
[2025-10-28 14:35:02,391] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
[2025-10-28 14:55:17,922] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\api.py changed, reloading.
|
||||
[2025-10-28 14:55:20,845] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
[2025-10-28 15:54:52,304] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\models.py changed, reloading.
|
||||
[2025-10-28 15:54:54,375] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
[2025-10-28 16:04:05,601] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading.
|
||||
[2025-10-28 16:04:07,708] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
[2025-10-28 16:46:52,938] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading.
|
||||
[2025-10-28 16:46:57,388] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
|
||||
|
||||
Reference in New Issue
Block a user