forms.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. from django.contrib.auth.forms import AuthenticationForm
  2. from metaservicesynced.models import *
  3. from .models import SharixUser
  4. from django import forms
  5. from metaservicesynced.models import ServiceType, Service
  6. from .models import SharixUser
  7. from django import forms
  8. class LoginUserForm(AuthenticationForm):
  9. password = forms.CharField(label="Пароль",
  10. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  11. username = forms.CharField(label="Номер телефона",
  12. widget=forms.TextInput(attrs={'class':'form-control'}))
  13. class Meta:
  14. model = SharixUser
  15. fields = ['username', 'password']
  16. class ServiceTariffUpdateForm(forms.ModelForm):
  17. def __init__(self, *args, **kwargs):
  18. super(ServiceTariffUpdateForm, self).__init__(*args, **kwargs)
  19. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  20. for field in iter(self.fields):
  21. if 'class' not in self.fields[field].widget.attrs:
  22. self.fields[field].widget.attrs.update({'class':'form-control'})
  23. class Meta:
  24. model = Service
  25. fields = ['status','ticket_status','servicetype_id','id_provider',
  26. 'resource_id','requirements','price_alg','price_km','price_min','price_amount','service_status',
  27. 'is_global','is_visible']
  28. widgets = {
  29. 'status': forms.TextInput(attrs={'readonly': True}, ),
  30. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  31. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  32. 'id_provider': forms.Select(attrs={'class': 'form-select'}),
  33. 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  34. }
  35. class ServiceTariffCreateForm(forms.ModelForm):
  36. def __init__(self, *args, **kwargs):
  37. super(ServiceTariffCreateForm, self).__init__(*args, **kwargs)
  38. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  39. for field in iter(self.fields):
  40. if 'class' not in self.fields[field].widget.attrs:
  41. self.fields[field].widget.attrs.update({'class':'form-control'})
  42. class Meta:
  43. model = Service
  44. fields = '__all__'
  45. widgets = {
  46. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  47. 'id_provider': forms.Select(attrs={'class': 'form-select'}),
  48. 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  49. 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  50. }
  51. class ServiceTypeUpdateForm(forms.ModelForm):
  52. def __init__(self, *args, **kwargs):
  53. super(ServiceTypeUpdateForm, self).__init__(*args, **kwargs)
  54. model = ServiceType
  55. fields = ['status','ticket_status','id_metaservice','codename',
  56. 'description','requirements','price_type','link_agreement',
  57. 'is_global','is_visible']
  58. widgets = {
  59. 'status': forms.TextInput(attrs={'readonly': True}),
  60. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  61. }
  62. class ServiceTypeCreateForm(forms.ModelForm):
  63. def __init__(self, *args, **kwargs):
  64. super(ServiceTypeCreateForm, self).__init__(*args, **kwargs)
  65. model = ServiceType
  66. fields = '__all__'
  67. widgets = {
  68. 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  69. }
  70. class ServiceInformationUpdateForm(forms.ModelForm):
  71. def __init__(self, *args, **kwargs):
  72. super(ServiceInformationUpdateForm, self).__init__(*args, **kwargs)
  73. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  74. for field in iter(self.fields):
  75. if 'class' not in self.fields[field].widget.attrs:
  76. self.fields[field].widget.attrs.update({'class':'form-control'})
  77. class Meta:
  78. model = Service
  79. fields = ['servicetype_id', 'id_provider']
  80. widgets = {
  81. # 'status': forms.TextInput(attrs={'readonly': True}),
  82. # 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  83. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  84. #'repr_id': forms.Select(attrs={'class': 'form-select'}),
  85. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  86. }
  87. class ServiceInformationCreateForm(forms.ModelForm):
  88. def __init__(self, *args, **kwargs):
  89. super(ServiceInformationCreateForm, self).__init__(*args, **kwargs)
  90. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  91. for field in iter(self.fields):
  92. if 'class' not in self.fields[field].widget.attrs:
  93. self.fields[field].widget.attrs.update({'class':'form-control'})
  94. class Meta:
  95. model = Service
  96. fields = ["servicetype_id", "id_provider"]
  97. exclude = ["resource_id"]
  98. widgets = {
  99. #'servicetype_id': forms.CharField(max_length=255)
  100. # 'legal_name': forms.TextInput(label = 'Название')
  101. # 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  102. #'repr_id': forms.Select(attrs={'class': 'form-select'}),
  103. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  104. # 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  105. }
  106. class PartnerInformationUpdateForm(forms.ModelForm):
  107. def __init__(self, *args, **kwargs):
  108. super(PartnerInformationUpdateForm, self).__init__(*args, **kwargs)
  109. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  110. for field in iter(self.fields):
  111. if 'class' not in self.fields[field].widget.attrs:
  112. self.fields[field].widget.attrs.update({'class':'form-control'})
  113. class Meta:
  114. model = Company
  115. fields = ['legal_name', 'address', 'repr_id' ]
  116. widgets = {
  117. 'description': forms.Select(attrs={'class': 'form-select'}),
  118. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  119. }
  120. class PartnerInformationCreateForm(forms.ModelForm):
  121. def __init__(self, *args, **kwargs):
  122. super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)
  123. class Meta:
  124. model = Company
  125. fields = ['legal_name', 'address', 'repr_id']
  126. widgets = {
  127. 'description': forms.Select(attrs={'class': 'form-select'}),
  128. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  129. }