forms.py 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 = "__all__"
  99. exclude = ["id",
  100. "is_global",
  101. "is_visible",
  102. "ticket_status",
  103. "id_metaservice",
  104. "resource_id"]
  105. widgets = {
  106. #'servicetype_id': forms.CharField(max_length=255)
  107. # 'legal_name': forms.TextInput(label = 'Название')
  108. # 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  109. #'repr_id': forms.Select(attrs={'class': 'form-select'}),
  110. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  111. # 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  112. }
  113. class PartnerInformationUpdateForm(forms.ModelForm):
  114. def __init__(self, *args, **kwargs):
  115. super(PartnerInformationUpdateForm, self).__init__(*args, **kwargs)
  116. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  117. for field in iter(self.fields):
  118. if 'class' not in self.fields[field].widget.attrs:
  119. self.fields[field].widget.attrs.update({'class':'form-control'})
  120. class Meta:
  121. model = Company
  122. fields = "__all__"
  123. exclude = ["id", "ticket_status",
  124. "is_global",
  125. "is_visible",
  126. "id_metaservice",
  127. "status"
  128. ]
  129. widgets = {
  130. 'description': forms.Select(attrs={'class': 'form-select'}),
  131. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  132. }
  133. class PartnerInformationCreateForm(forms.ModelForm):
  134. def __init__(self, *args, **kwargs):
  135. super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)
  136. for field in iter(self.fields):
  137. if 'class' not in self.fields[field].widget.attrs:
  138. self.fields[field].widget.attrs.update({'class':'form-control'})
  139. # legal_name = forms.Fi()
  140. class Meta:
  141. model = Company
  142. fields = "__all__"
  143. exclude = ["id", "ticket_status",
  144. "is_global",
  145. "is_visible",
  146. "id_metaservice",
  147. "status"
  148. ]
  149. widgets = {
  150. 'description': forms.Select(attrs={'class': 'form-select'}),
  151. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  152. }
  153. # username = forms.CharField(label="Номер телефона",
  154. # widget=forms.TextInput(attrs={'class':'form-control'}))