fix - add purchase_policy to org

This commit is contained in:
2025-12-30 14:08:44 +03:30
parent 641461396a
commit 9a02ad4622
3 changed files with 32 additions and 14 deletions

View File

@@ -261,16 +261,16 @@ class OrganizationSerializer(serializers.ModelSerializer):
'company_code',
'field_of_activity',
'free_visibility_by_scope',
'purchase_policy',
'service_area', # noqa
# 'purchase_policy'
]
extra_kwargs = {
'service_area': { # noqa
'required': False
},
# 'purchase_policy': {
# 'purchase_policy': False
# }
'purchase_policy': {
'required': False
}
}
def validate(self, attrs):

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2025-12-30 10:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('authentication', '0056_remove_organization_purchase_policy'),
]
operations = [
migrations.AddField(
model_name='organization',
name='purchase_policy',
field=models.CharField(choices=[('INTERNAL_ONLY', 'Internal Only'), ('CROSS_COOP', 'Cross Cooperative Allowed')], default='INTERNAL_ONLY', help_text='defines where ranchers can purchase from', max_length=20),
),
]

View File

@@ -148,16 +148,16 @@ class Organization(BaseModel):
additional_data = models.JSONField(default=dict)
service_area = models.ManyToManyField(City, related_name='service_area')
# PURCHASE_POLICIES = (
# ('INTERNAL_ONLY', 'Internal Only'),
# ('CROSS_COOP', 'Cross Cooperative Allowed'),
# )
# purchase_policy = models.CharField(
# max_length=20,
# choices=PURCHASE_POLICIES,
# default='INTERNAL_ONLY',
# help_text='defines where ranchers can purchase from'
# )
PURCHASE_POLICIES = (
('INTERNAL_ONLY', 'Internal Only'),
('CROSS_COOP', 'Cross Cooperative Allowed'),
)
purchase_policy = models.CharField(
max_length=20,
choices=PURCHASE_POLICIES,
default='INTERNAL_ONLY',
help_text='defines where ranchers can purchase from'
)
def __str__(self):
return f'{self.name}-{self.type}'