forms.py 7.7 KB

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