change permissions name unique
This commit is contained in:
@@ -40,6 +40,8 @@ class PermissionViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = Permissions.objects.all()
|
queryset = Permissions.objects.all()
|
||||||
serializer_class = PermissionSerializer
|
serializer_class = PermissionSerializer
|
||||||
|
filter_backends = [filters.SearchFilter]
|
||||||
|
search_fields = ['page__name', ]
|
||||||
|
|
||||||
|
|
||||||
class UserRelationViewSet(viewsets.ModelViewSet):
|
class UserRelationViewSet(viewsets.ModelViewSet):
|
||||||
|
|||||||
18
apps/authorization/migrations/0016_alter_permissions_name.py
Normal file
18
apps/authorization/migrations/0016_alter_permissions_name.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-06-08 04:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('authorization', '0015_permissions_category_permissions_meta_page_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='permissions',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=50, unique=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -21,7 +21,7 @@ class Page(BaseModel):
|
|||||||
class Permissions(BaseModel):
|
class Permissions(BaseModel):
|
||||||
""" permission level of users """
|
""" permission level of users """
|
||||||
|
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50, unique=True)
|
||||||
description = models.TextField(max_length=500)
|
description = models.TextField(max_length=500)
|
||||||
category_choices = (
|
category_choices = (
|
||||||
('api', 'Api'),
|
('api', 'Api'),
|
||||||
|
|||||||
36
apps/product/migrations/0003_saleunit.py
Normal file
36
apps/product/migrations/0003_saleunit.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Generated by Django 5.0 on 2025-06-08 04:52
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('product', '0002_attribute_attributevalue'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SaleUnit',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('create_date', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modify_date', models.DateTimeField(auto_now=True)),
|
||||||
|
('creator_info', models.CharField(max_length=100, null=True)),
|
||||||
|
('modifier_info', models.CharField(max_length=100, null=True)),
|
||||||
|
('trash', models.BooleanField(default=False)),
|
||||||
|
('unit', models.CharField(max_length=255, null=True)),
|
||||||
|
('variation_coefficient', models.CharField(max_length=255, null=True)),
|
||||||
|
('required', models.BooleanField(default=False)),
|
||||||
|
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_createddby', to=settings.AUTH_USER_MODEL)),
|
||||||
|
('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_modifiedby', to=settings.AUTH_USER_MODEL)),
|
||||||
|
('product', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sale_unit', to='product.referenceproduct')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -92,3 +92,18 @@ class AttributeValue(BaseModel):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
return super(AttributeValue, self).save(*args, **kwargs)
|
return super(AttributeValue, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class SaleUnit(BaseModel):
|
||||||
|
product = models.ForeignKey(
|
||||||
|
ReferenceProduct,
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name='sale_unit',
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
unit = models.CharField(max_length=255, null=True)
|
||||||
|
variation_coefficient = models.CharField(max_length=255, null=True)
|
||||||
|
required = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f'{self.product} - {self.unit} - {self.variation_coefficient}'
|
||||||
|
|||||||
@@ -24,11 +24,8 @@ class PaginatedElasticSearchApiView(APIView, LimitOffsetPagination):
|
|||||||
def get(self, request, query):
|
def get(self, request, query):
|
||||||
try:
|
try:
|
||||||
q = self.generate_q_expression(query)
|
q = self.generate_q_expression(query)
|
||||||
print(q)
|
|
||||||
search = self.document_class.search().query(q)
|
search = self.document_class.search().query(q)
|
||||||
print(search)
|
|
||||||
response = search.execute()
|
response = search.execute()
|
||||||
print(response)
|
|
||||||
|
|
||||||
print(f"Found {response.hits.total.value} hit(s) for query: '{query}'")
|
print(f"Found {response.hits.total.value} hit(s) for query: '{query}'")
|
||||||
|
|
||||||
@@ -62,12 +59,3 @@ class SearchUserDocumentApiView(PaginatedElasticSearchApiView):
|
|||||||
],
|
],
|
||||||
minimum_should_match=1,
|
minimum_should_match=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
# return Q(
|
|
||||||
# "multi_match",
|
|
||||||
# query=query,
|
|
||||||
# fields=[
|
|
||||||
# "user__username"
|
|
||||||
# ],
|
|
||||||
# fuzziness='auto'
|
|
||||||
# )
|
|
||||||
|
|||||||
Reference in New Issue
Block a user