diff --git a/apps/authentication/api/v1/api.py b/apps/authentication/api/v1/api.py index 3d1f9da..f23845a 100644 --- a/apps/authentication/api/v1/api.py +++ b/apps/authentication/api/v1/api.py @@ -30,6 +30,7 @@ from rest_framework.response import Response from common.tools import CustomOperations from rest_framework.views import APIView from django.core.cache import cache +from rest_framework import filters from rest_framework import status from django.db import transaction from common.sms import send_sms @@ -45,6 +46,8 @@ class UserViewSet(ModelViewSet): """ Crud operations for user model """ queryset = User.objects.all() serializer_class = UserSerializer + filter_backends = [filters.SearchFilter] + search_fields = ['name', 'mobile', 'national_code'] @transaction.atomic def create(self, request, *args, **kwargs): diff --git a/apps/authentication/migrations/0024_alter_organizationtype_key.py b/apps/authentication/migrations/0024_alter_organizationtype_key.py new file mode 100644 index 0000000..567f0b8 --- /dev/null +++ b/apps/authentication/migrations/0024_alter_organizationtype_key.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0 on 2025-07-07 05:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentication', '0023_alter_organization_company_code_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='organizationtype', + name='key', + field=models.CharField(choices=[('EMP', 'empty'), ('J', 'Jihad'), ('U', 'Union'), ('CO', 'Cooperative'), ('CMP', 'Companies')], default='EMP', max_length=3), + ), + ] diff --git a/apps/authentication/migrations/0025_alter_organizationtype_name.py b/apps/authentication/migrations/0025_alter_organizationtype_name.py new file mode 100644 index 0000000..b7feb2b --- /dev/null +++ b/apps/authentication/migrations/0025_alter_organizationtype_name.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0 on 2025-07-07 05:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentication', '0024_alter_organizationtype_key'), + ] + + operations = [ + migrations.AlterField( + model_name='organizationtype', + name='name', + field=models.CharField(max_length=50, null=True, unique=True), + ), + ] diff --git a/apps/authentication/models.py b/apps/authentication/models.py index ee58c35..207cfc8 100644 --- a/apps/authentication/models.py +++ b/apps/authentication/models.py @@ -75,13 +75,14 @@ class City(BaseModel): class OrganizationType(BaseModel): organization_keys = ( + ('EMP', 'empty'), ('J', 'Jihad'), ('U', 'Union'), ('CO', 'Cooperative'), ('CMP', 'Companies') ) - key = models.CharField(choices=organization_keys, max_length=3) - name = models.CharField(max_length=50, null=True) + 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) def __str__(self):