quota, distribution, inventory entry, quota sale transaction, product informations, signals ,....
This commit is contained in:
@@ -98,9 +98,9 @@ class UserViewSet(ModelViewSet):
|
||||
Customizing update user & bank account info with
|
||||
permission levels
|
||||
"""
|
||||
serializer = self.serializer_class(data=request.data)
|
||||
serializer = self.serializer_class(data=request.data, instance=self.get_object(), partial=True)
|
||||
if serializer.is_valid():
|
||||
user = serializer.update(self.queryset.get(id=pk), validated_data=request.data)
|
||||
user = serializer.save()
|
||||
|
||||
if 'organization' in request.data.keys(): # noqa
|
||||
organization = CustomOperations().custom_update( # update organization for user
|
||||
|
||||
@@ -138,8 +138,8 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
instance.ownership = validated_data.get('ownership')
|
||||
instance.address = validated_data.get('address')
|
||||
instance.photo = validated_data.get('photo')
|
||||
instance.province = Province.objects.get(id=validated_data.get('province'))
|
||||
instance.city = City.objects.get(id=validated_data.get('city'))
|
||||
instance.province = validated_data.get('province', instance.province)
|
||||
instance.city = validated_data.get('province', instance.province)
|
||||
instance.otp_status = validated_data.get('otp_status')
|
||||
instance.save()
|
||||
|
||||
@@ -213,14 +213,10 @@ class OrganizationSerializer(serializers.ModelSerializer):
|
||||
def update(self, instance, validated_data):
|
||||
""" update user organization information """ # noqa
|
||||
instance.name = validated_data.get('name', instance.name)
|
||||
if validated_data.get('type'):
|
||||
instance.type = validated_data['type']
|
||||
if validated_data.get('province'):
|
||||
instance.province = validated_data['province']
|
||||
if validated_data.get('city'):
|
||||
instance.city = validated_data['city']
|
||||
if validated_data.get('parent_organization'):
|
||||
instance.parent_organization = validated_data['parent_organization']
|
||||
instance.type = validated_data.get('type', instance.type)
|
||||
instance.province = validated_data.get('province', instance.province)
|
||||
instance.city = validated_data.get('city', instance.city)
|
||||
instance.parent_organization = validated_data.get('parent_organization', instance.parent_organization)
|
||||
instance.national_unique_id = validated_data.get('national_unique_id', instance.national_unique_id)
|
||||
instance.save()
|
||||
return instance
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.0 on 2025-06-28 11:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('authentication', '0022_alter_user_mobile_alter_user_national_code'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='organization',
|
||||
name='company_code',
|
||||
field=models.CharField(default='', max_length=30),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='organization',
|
||||
name='field_of_activity',
|
||||
field=models.CharField(choices=[('CO', 'Country'), ('PR', 'Province'), ('CI', 'City')], default='', max_length=2),
|
||||
),
|
||||
]
|
||||
@@ -105,8 +105,8 @@ class Organization(BaseModel):
|
||||
('PR', 'Province'),
|
||||
('CI', 'City')
|
||||
)
|
||||
field_of_activity = models.CharField(max_length=2, choices=activity_fields, default='EM')
|
||||
company_code = models.CharField(max_length=30, default="empty")
|
||||
field_of_activity = models.CharField(max_length=2, choices=activity_fields, default="")
|
||||
company_code = models.CharField(max_length=30, default="")
|
||||
province = models.ForeignKey(
|
||||
Province,
|
||||
on_delete=models.CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user