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}'
|
||||
|
||||
Reference in New Issue
Block a user