forms.py 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. class Meta:
  55. model = ServiceType
  56. fields = ['status','ticket_status','id_metaservice','codename',
  57. 'description','requirements','price_type','link_agreement',
  58. 'is_global','is_visible']
  59. widgets = {
  60. 'status': forms.TextInput(attrs={'readonly': True}),
  61. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  62. }
  63. class ServiceTypeCreateForm(forms.ModelForm):
  64. def __init__(self, *args, **kwargs):
  65. super(ServiceTypeCreateForm, self).__init__(*args, **kwargs)
  66. class Meta:
  67. model = ServiceType
  68. fields = '__all__'
  69. widgets = {
  70. 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  71. }
  72. class ServiceInformationUpdateForm(forms.ModelForm):
  73. def __init__(self, *args, **kwargs):
  74. super(ServiceInformationUpdateForm, self).__init__(*args, **kwargs)
  75. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  76. for field in iter(self.fields):
  77. if 'class' not in self.fields[field].widget.attrs:
  78. self.fields[field].widget.attrs.update({'class':'form-control'})
  79. class Meta:
  80. model = Service
  81. fields = ['servicetype_id', 'id_provider']
  82. widgets = {
  83. # 'status': forms.TextInput(attrs={'readonly': True}),
  84. # 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  85. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  86. #'repr_id': forms.Select(attrs={'class': 'form-select'}),
  87. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  88. }
  89. class ServiceInformationCreateForm(forms.ModelForm):
  90. def __init__(self, *args, **kwargs):
  91. super(ServiceInformationCreateForm, self).__init__(*args, **kwargs)
  92. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  93. for field in iter(self.fields):
  94. if 'class' not in self.fields[field].widget.attrs:
  95. self.fields[field].widget.attrs.update({'class':'form-control'})
  96. class Meta:
  97. model = Service
  98. fields = ["servicetype_id", "id_provider"]
  99. exclude = ["resource_id"]
  100. widgets = {
  101. #'servicetype_id': forms.CharField(max_length=255)
  102. # 'legal_name': forms.TextInput(label = 'Название')
  103. # 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  104. #'repr_id': forms.Select(attrs={'class': 'form-select'}),
  105. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  106. # 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  107. }
  108. class PartnerInformationUpdateForm(forms.ModelForm):
  109. def __init__(self, *args, **kwargs):
  110. super(PartnerInformationUpdateForm, self).__init__(*args, **kwargs)
  111. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  112. for field in iter(self.fields):
  113. if 'class' not in self.fields[field].widget.attrs:
  114. self.fields[field].widget.attrs.update({'class':'form-control'})
  115. class Meta:
  116. model = Company
  117. fields = ['legal_name', 'address', 'repr_id' ]
  118. widgets = {
  119. 'description': forms.Select(attrs={'class': 'form-select'}),
  120. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  121. }
  122. class PartnerInformationCreateForm(forms.ModelForm):
  123. def __init__(self, *args, **kwargs):
  124. super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)
  125. for field in iter(self.fields):
  126. if 'class' not in self.fields[field].widget.attrs:
  127. self.fields[field].widget.attrs.update({'class':'form-control'})
  128. # legal_name = forms.Fi()
  129. class Meta:
  130. model = Company
  131. fields = ['legal_name', 'address', 'repr_id']
  132. widgets = {
  133. 'description': forms.Select(attrs={'class': 'form-select'}),
  134. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  135. }
  136. class BecomePartnerUpdateForm(forms.ModelForm):
  137. def __init__(self, *args, **kwargs):
  138. super(BecomePartnerUpdateForm, self).__init__(*args, **kwargs)
  139. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  140. for field in iter(self.fields):
  141. if 'class' not in self.fields[field].widget.attrs:
  142. self.fields[field].widget.attrs.update({'class':'form-control'})
  143. class Meta:
  144. model = Company
  145. fields = ['repr_id', 'ticket_status', 'status', 'id_metaservice', 'requirements' ]
  146. widgets = {
  147. 'description': forms.Select(attrs={'class': 'form-select'}),
  148. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  149. }
  150. class BecomePartnerCreateForm(forms.ModelForm):
  151. def __init__(self, *args, **kwargs):
  152. super(BecomePartnerCreateForm, self).__init__(*args, **kwargs)
  153. for field in iter(self.fields):
  154. if 'class' not in self.fields[field].widget.attrs:
  155. self.fields[field].widget.attrs.update({'class':'form-control'})
  156. # legal_name = forms.Fi()
  157. class Meta:
  158. model = Company
  159. fields = ['repr_id', 'ticket_status', 'status', 'id_metaservice', 'requirements' ]
  160. widgets = {
  161. 'description': forms.Select(attrs={'class': 'form-select'}),
  162. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  163. }
  164. # username = forms.CharField(label="Номер телефона",
  165. # widget=forms.TextInput(attrs={'class':'form-control'}))