change keys of organization type, import search field to users
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
]
|
||||
@@ -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),
|
||||
),
|
||||
]
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user