|
|
|
|
@ -61,20 +61,9 @@ class WorkForm(forms.ModelForm): |
|
|
|
|
position = forms.CharField(label=_(u'Укажите вашу должность'), |
|
|
|
|
required=False, widget=forms.TextInput()) |
|
|
|
|
|
|
|
|
|
company = forms.CharField(label=_(u'Место работы'), widget=forms.HiddenInput(attrs={'class': 'select2'})) |
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
|
super(WorkForm, self).__init__(*args, **kwargs) |
|
|
|
|
if self.instance.company: |
|
|
|
|
self.fields['company'].widget = forms.HiddenInput(attrs={'class': 'select2', 'data-init-text': self.instance.company.name}) |
|
|
|
|
class Meta: |
|
|
|
|
model = User |
|
|
|
|
fields = ('position', 'company') |
|
|
|
|
|
|
|
|
|
def clean_company(self): |
|
|
|
|
try: |
|
|
|
|
return Company.objects.get(id=self.cleaned_data['company']) |
|
|
|
|
except Company.DoesNotExist: |
|
|
|
|
return None |
|
|
|
|
fields = ('position',) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AboutCompanyForm(forms.ModelForm): |
|
|
|
|
@ -91,6 +80,21 @@ class PhoneForm(forms.ModelForm): |
|
|
|
|
model = Profile |
|
|
|
|
fields = ('phone',) |
|
|
|
|
|
|
|
|
|
def clean_phone(self): |
|
|
|
|
phone = self.cleaned_data['phone'] |
|
|
|
|
if not phone: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
deduct = ('-','(',')','.',' ', '+') |
|
|
|
|
for elem in deduct: |
|
|
|
|
phone = phone.replace(elem, '') |
|
|
|
|
if phone.isdigit(): |
|
|
|
|
return phone |
|
|
|
|
else: |
|
|
|
|
raise forms.ValidationError(_(u'Введите правильный телефон')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EmailForm(forms.ModelForm): |
|
|
|
|
email = forms.EmailField(label=_(u'Ваш e-mail'), required=False) |
|
|
|
|
|
|
|
|
|
|