diff --git a/accounts/templates/accounts/customer_list.html b/accounts/templates/accounts/customer_list.html index 1b7e103..38f2fcc 100644 --- a/accounts/templates/accounts/customer_list.html +++ b/accounts/templates/accounts/customer_list.html @@ -459,7 +459,8 @@ 'id_national_code': customer.national_code, 'id_card_number': customer.card_number, 'id_account_number': customer.account_number, - 'id_address': customer.address + 'id_address': customer.address, + 'id_bank_name': customer.bank_name }; // Loop through fields for easier maintenance @@ -471,6 +472,11 @@ $('#exampleModalLabel').text('ویرایش کاربر'); $('.data-submit').text('ویرایش'); + // Ensure select value is applied (for some browsers/plugins) + if (customer.bank_name !== undefined && customer.bank_name !== null) { + $('#id_bank_name').val(customer.bank_name); + } + // Open modal $('#add-new-record').offcanvas('show'); } else { diff --git a/db.sqlite3 b/db.sqlite3 index a9d6a51..0bbaaf8 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/wells/forms.py b/wells/forms.py index 5f39178..e04ecc5 100644 --- a/wells/forms.py +++ b/wells/forms.py @@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model from django.core.exceptions import ValidationError from .models import Well, WaterMeterManufacturer from locations.models import Affairs, County, Broker +from common.consts import UserRoles class WaterMeterManufacturerForm(forms.ModelForm): @@ -118,8 +119,10 @@ class WellForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - # تنظیم queryset‌ها - self.fields['representative'].queryset = get_user_model().objects.all() + # تنظیم queryset‌ها - فقط کاربرانی که نقش مشترک دارند + self.fields['representative'].queryset = get_user_model().objects.filter( + profile__roles__slug=UserRoles.CUSTOMER.value + ) self.fields['water_meter_manufacturer'].queryset = WaterMeterManufacturer.objects.all() # اضافه کردن گزینه خالی