add product
This commit is contained in:
1 parent
423d4cf40e
commit
c8d45dd07c
58 files changed
+8309
-674
No files matched your search
@@ -0,0 +1,30 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from apps.cuser.cuser_model import CUser
|
||||
from utils.validations.mobile import normalize_mobile
|
||||
|
||||
|
||||
class MobileFormMixin:
|
||||
def clean_mobile(self):
|
||||
try:
|
||||
return normalize_mobile(self.cleaned_data['mobile'])
|
||||
except ValidationError as error:
|
||||
raise forms.ValidationError(error.messages)
|
||||
|
||||
|
||||
class CUserCreationForm(MobileFormMixin, UserCreationForm):
|
||||
mobile = forms.CharField(label='شماره موبایل')
|
||||
|
||||
class Meta(UserCreationForm.Meta):
|
||||
model = CUser
|
||||
fields = ('username', 'name_family', 'mobile', 'is_active', 'is_staff')
|
||||
|
||||
|
||||
class CUserChangeForm(MobileFormMixin, UserChangeForm):
|
||||
mobile = forms.CharField(label='شماره موبایل')
|
||||
|
||||
class Meta(UserChangeForm.Meta):
|
||||
model = CUser
|
||||
fields = '__all__'
|
||||
Reference in new issue
Block a user