add 2 new fields city & province in device - fix bug of filter_by_region

This commit is contained in:
2025-10-27 14:42:51 +03:30
parent bb9f8a645e
commit 5d6529cb36
7 changed files with 72 additions and 15 deletions

View File

@@ -0,0 +1,17 @@
# Generated by Django 5.0 on 2025-10-27 10:38
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('authentication', '0038_organizationtype_region_scope'),
]
operations = [
migrations.RemoveField(
model_name='organizationtype',
name='region_scope',
),
]

View File

@@ -26,7 +26,7 @@ class RegionFilterMixin:
if hasattr(queryset.model, 'province_id'):
queryset = queryset.filter(province_id=id(province_id))
elif hasattr(queryset.model, 'user'):
queryset = queryset.filter(user__province=organization.city)
queryset = queryset.filter(user__province=id(province_id))
# filter by organization type region
if org:
@@ -42,7 +42,7 @@ class RegionFilterMixin:
if hasattr(queryset.model, 'province_id'):
queryset = queryset.filter(province=organization.province)
elif hasattr(queryset.model, 'user'):
queryset = queryset.filter(user__province=organization.city)
queryset = queryset.filter(user__province=organization.province)
# if organization is admin of system
elif scope == 'CO':