Add bank account number to profile model, admin, and forms
This commit is contained in:
parent
582c5271c7
commit
60332e7b5b
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -23,7 +23,7 @@ class ProfileInline(admin.StackedInline):
|
||||
verbose_name_plural = _('Profiles')
|
||||
fieldsets = (
|
||||
(None, {'fields': ('role', 'is_approved', 'phone_number', 'profile_picture', 'address')}),
|
||||
(_('Driver Info'), {'fields': ('license_front_image', 'license_back_image', 'car_plate_number'), 'classes': ('collapse',)}),
|
||||
(_('Driver Info'), {'fields': ('license_front_image', 'license_back_image', 'car_plate_number', 'bank_account_number'), 'classes': ('collapse',)}),
|
||||
(_('Location'), {'fields': ('country', 'governate', 'city'), 'classes': ('collapse',)}),
|
||||
)
|
||||
|
||||
|
||||
@ -113,6 +113,8 @@ class UserRegistrationForm(forms.ModelForm):
|
||||
profile.license_back_image = self.cleaned_data['license_back_image']
|
||||
if 'car_plate_number' in self.cleaned_data:
|
||||
profile.car_plate_number = self.cleaned_data['car_plate_number']
|
||||
if 'bank_account_number' in self.cleaned_data:
|
||||
profile.bank_account_number = self.cleaned_data['bank_account_number']
|
||||
|
||||
profile.save()
|
||||
return user
|
||||
@ -128,6 +130,7 @@ class DriverRegistrationForm(UserRegistrationForm):
|
||||
license_front_image = forms.ImageField(label=_("License Front Image"), required=True, widget=forms.FileInput(attrs={'class': 'form-control', 'accept': 'image/*'}))
|
||||
license_back_image = forms.ImageField(label=_("License Back Image"), required=True, widget=forms.FileInput(attrs={'class': 'form-control', 'accept': 'image/*'}))
|
||||
car_plate_number = forms.CharField(label=_("Car Plate Number"), max_length=20, required=True, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
||||
bank_account_number = forms.CharField(label=_("Bank Account Number"), max_length=50, required=True, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('Bank Name - Account Number')}))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@ -144,6 +147,7 @@ class UserProfileForm(forms.ModelForm):
|
||||
|
||||
address = forms.CharField(label=_("Address"), required=False, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
||||
profile_picture = forms.ImageField(label=_("Profile Picture"), required=False, widget=forms.FileInput(attrs={'class': 'form-control'}))
|
||||
bank_account_number = forms.CharField(label=_("Bank Account Number"), required=False, max_length=50, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': _('Bank Name - Account Number')}))
|
||||
|
||||
otp_method = forms.ChoiceField(
|
||||
choices=[('email', _('Email')), ('whatsapp', _('WhatsApp'))],
|
||||
@ -154,7 +158,7 @@ class UserProfileForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Profile
|
||||
fields = ['profile_picture', 'phone_number', 'address', 'country', 'governate', 'city']
|
||||
fields = ['profile_picture', 'phone_number', 'address', 'country', 'governate', 'city', 'bank_account_number']
|
||||
widgets = {
|
||||
'country': forms.Select(attrs={'class': 'form-control'}),
|
||||
'governate': forms.Select(attrs={'class': 'form-control'}),
|
||||
|
||||
18
core/migrations/0026_profile_bank_account_number.py
Normal file
18
core/migrations/0026_profile_bank_account_number.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.7 on 2026-01-31 13:10
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0025_platformprofile_admin_panel_logo_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='bank_account_number',
|
||||
field=models.CharField(blank=True, max_length=50, verbose_name='Bank Account Number'),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
@ -78,6 +78,7 @@ class Profile(models.Model):
|
||||
license_front_image = models.ImageField(_('License Front Image'), upload_to='licenses/', blank=True, null=True)
|
||||
license_back_image = models.ImageField(_('License Back Image'), upload_to='licenses/', blank=True, null=True)
|
||||
car_plate_number = models.CharField(_('Car Plate Number'), max_length=20, blank=True)
|
||||
bank_account_number = models.CharField(_('Bank Account Number'), max_length=50, blank=True)
|
||||
|
||||
country = models.ForeignKey(Country, on_delete=models.SET_NULL, null=True, blank=True, verbose_name=_('Country'))
|
||||
governate = models.ForeignKey(Governate, on_delete=models.SET_NULL, null=True, blank=True, verbose_name=_('Governate'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user