forms.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # 'status': forms.TextInput(attrs={'readonly': True}),
  25. # 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  26. # 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  27. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  28. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  29. }
  30. class PartnerInformationCreateForm(forms.ModelForm):
  31. def __init__(self, *args, **kwargs):
  32. super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)
  33. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  34. for field in iter(self.fields):
  35. if 'class' not in self.fields[field].widget.attrs:
  36. self.fields[field].widget.attrs.update({'class':'form-control'})
  37. # legal_name = forms.CharField(label = "Название",
  38. # widget=forms.TextInput(attrs={'class':'form-control'}))
  39. class Meta:
  40. model = Company
  41. fields = ['legal_name', 'address', 'repr_id']
  42. widgets = {
  43. # 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  44. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  45. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  46. # 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  47. }