forms.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from django.contrib.auth.forms import AuthenticationForm
  2. from metaservicesynced.models import *
  3. from .models import SharixUser
  4. from django import forms
  5. class LoginUserForm(AuthenticationForm):
  6. password = forms.CharField(label="Пароль",
  7. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  8. username = forms.CharField(label="Номер телефона",
  9. widget=forms.TextInput(attrs={'class':'form-control'}))
  10. class Meta:
  11. model = SharixUser
  12. fields = ['username', 'password']
  13. class PartnerInformationUpdateForm(forms.ModelForm):
  14. def __init__(self, *args, **kwargs):
  15. super(PartnerInformationUpdateForm, self).__init__(*args, **kwargs)
  16. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  17. for field in iter(self.fields):
  18. if 'class' not in self.fields[field].widget.attrs:
  19. self.fields[field].widget.attrs.update({'class':'form-control'})
  20. class Meta:
  21. model = Company
  22. fields = ['legal_name', 'address', 'repr_id' ]
  23. widgets = {
  24. 'description': forms.Select(attrs={'class': 'form-select'}),
  25. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  26. }
  27. class PartnerInformationCreateForm(forms.ModelForm):
  28. def __init__(self, *args, **kwargs):
  29. super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)
  30. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  31. for field in iter(self.fields):
  32. if 'class' not in self.fields[field].widget.attrs:
  33. self.fields[field].widget.attrs.update({'class':'form-control'})
  34. class Meta:
  35. model = Company
  36. fields = ['legal_name', 'address', 'repr_id']
  37. widgets = {
  38. 'description': forms.Select(attrs={'class': 'form-select'}),
  39. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  40. }