Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django import forms
- from django.contrib.auth.forms import AuthenticationForm
- from django.contrib.auth.forms import UserCreationForm
- from django.contrib.auth.models import AbstractUser
- from django.contrib.auth.models import User
- from django.utils.translation import ugettext_lazy as _
- # from django.forms import ModelForm
- # from django.contrib.auth.forms import UserCreationForm
- # from django.contrib.auth.forms import UserChangeForm
- from .models import AuthUser
- from .models import OrgRequest
- class LoginForm(AuthenticationForm):
- username = forms.CharField(label='Логин', max_length=30, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','id':'username','placeholder':'Логин'}))
- password = forms.CharField(label='Пароль', max_length=30, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'password','id':'password','placeholder':'Пароль'}))
- class Meta:
- model = User
- fields = ('username', 'password')
- class OrgRequestForm(forms.Form):
- way_to_treat = forms.CharField(label='ФИО, имя или псевдоним', max_length=120,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder':'ФИО, имя или псевдоним и т.д.'}))
- org_name = forms.CharField(label='Организация', max_length=120,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder':'Наименование организации'}))
- org_address = forms.CharField(label='Организация', max_length=120,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder':'Адрес организации'}))
- email = forms.EmailField(label='Электронная почта', max_length=254, required=False,
- widget=forms.TextInput(attrs={'class':'form-control','type':'email','placeholder':'example@example.ru'}))
- phone_number = forms.CharField(label='Телефонный номер', max_length=15, required=False,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder':'8-XXX-XX-XX-XXX'}))
- inn_id = forms.CharField(label='ИНН', max_length=12, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder':'ИНН организации'}))
- employees = forms.CharField(label='Сотрудники', max_length=50, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Кол-во заинтересованных сотрудников'}))
- description = forms.CharField(label='Доп. информация', max_length=500, required=False,
- widget=forms.Textarea(attrs={'class':'form-control','type':'text','placeholder':'Дополнительная информация (500 символов)'}))
- date = forms.CharField(label='Дата заполнения', max_length=10, required=True,
- widget=forms.DateInput(format=('%d.%m.%Y'), attrs={'class': 'input-group date','type':'date'}))
- class Meta:
- model = OrgRequest
- class SignUpForm(UserCreationForm):
- lastname = forms.CharField(label='Фамилия', max_length=30, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Фамилия'}))
- firstname = forms.CharField(label='Имя', max_length=30, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Имя'}))
- patronymic = forms.CharField(label='Отчество', max_length=30, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Отчество'}))
- username = forms.EmailField(label='Логин', max_length=254, required=False,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Логин'}))
- email = forms.EmailField(label='Электронная почта', max_length=254, required=False,
- widget=forms.TextInput(attrs={'class':'form-control','type':'email', 'placeholder': 'Электронная почта'}))
- org_name = forms.CharField(label='Наименование организации', max_length=30, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder':'Наименование организации'}))
- org_address = forms.CharField(label='Адрес организации', max_length=30, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Адрес организации'}))
- phone_number = forms.CharField(label='Номер телефона!', max_length=11, required=False,
- widget=forms.TextInput(attrs={'class':'form-control','placeholder':'Номер телефона'}))
- birth_day = forms.CharField(label='Дата рождения', max_length=10, required=True,
- widget=forms.DateInput(attrs={'class': 'form-control','type': 'date'}))
- inn_id = forms.CharField(label='ИНН', max_length=12, required=True,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'ИНН'}))
- passport_s = forms.CharField(label='Серия паспорта', max_length=4, required=False,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Серия паспорта'}))
- passport_n = forms.CharField(label='Номер паспорта', max_length=8, required=False,
- widget=forms.TextInput(attrs={'class':'form-control','type':'text','placeholder': 'Номер паспорта'}))
- password1 = forms.CharField(label='Пароль',
- widget=forms.PasswordInput(attrs={'class':'form-control','type':'password','placeholder': 'Пароль'}))
- password2 = forms.CharField(label='Пароль',
- widget=forms.PasswordInput(attrs={'class':'form-control','type':'password','placeholder': 'Пароль ещё раз'}))
- def save(self, commit=True):
- # Save the provided password in hashed format
- user = super(SignUpForm, self).save(commit=False)
- user.set_password(self.cleaned_data["password"])
- if commit:
- user.save()
- return user
- class Meta:
- model = AuthUser
- fields = ('username', 'email', 'phone_number', 'lastname', 'firstname', 'patronymic', 'birth_day', 'inn_id', 'passport_s', 'passport_n')
- label = {
- 'username': 'Логин',
- 'password1': 'Пароль',
- 'password2': 'Пароль (ещё раз)',
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement