Compare commits

...

2 commits

3 changed files with 12 additions and 3 deletions

View file

@ -459,7 +459,8 @@
'id_national_code': customer.national_code, 'id_national_code': customer.national_code,
'id_card_number': customer.card_number, 'id_card_number': customer.card_number,
'id_account_number': customer.account_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 // Loop through fields for easier maintenance
@ -471,6 +472,11 @@
$('#exampleModalLabel').text('ویرایش کاربر'); $('#exampleModalLabel').text('ویرایش کاربر');
$('.data-submit').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 // Open modal
$('#add-new-record').offcanvas('show'); $('#add-new-record').offcanvas('show');
} else { } else {

Binary file not shown.

View file

@ -3,6 +3,7 @@ from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from .models import Well, WaterMeterManufacturer from .models import Well, WaterMeterManufacturer
from locations.models import Affairs, County, Broker from locations.models import Affairs, County, Broker
from common.consts import UserRoles
class WaterMeterManufacturerForm(forms.ModelForm): class WaterMeterManufacturerForm(forms.ModelForm):
@ -118,8 +119,10 @@ class WellForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# تنظیم querysetها # تنظیم querysetها - فقط کاربرانی که نقش مشترک دارند
self.fields['representative'].queryset = get_user_model().objects.all() self.fields['representative'].queryset = get_user_model().objects.filter(
profile__roles__slug=UserRoles.CUSTOMER.value
)
self.fields['water_meter_manufacturer'].queryset = WaterMeterManufacturer.objects.all() self.fields['water_meter_manufacturer'].queryset = WaterMeterManufacturer.objects.all()
# اضافه کردن گزینه خالی # اضافه کردن گزینه خالی