service.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. from django import forms
  2. from dbsynce.models import ServiceType, Service, Company
  3. from webservice_running.models import Comments, Tasks
  4. from django.contrib.auth import get_user_model
  5. class ServiceTariffUpdateForm(forms.ModelForm):
  6. def __init__(self, *args, **kwargs):
  7. super(ServiceTariffUpdateForm, self).__init__(*args, **kwargs)
  8. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  9. for field in iter(self.fields):
  10. if 'class' not in self.fields[field].widget.attrs:
  11. self.fields[field].widget.attrs.update({'class':'form-control'})
  12. class Meta:
  13. model = Service
  14. fields = ['status','ticket_status','servicetype_id','id_provider',
  15. 'resource_id','requirements','price_alg','price_km','price_min','price_amount','service_status',
  16. 'is_global','is_visible']
  17. widgets = {
  18. 'status': forms.TextInput(attrs={'readonly': True}, ),
  19. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  20. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  21. 'id_provider': forms.Select(attrs={'class': 'form-select'}),
  22. 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  23. }
  24. class ServiceTariffCreateForm(forms.ModelForm):
  25. def __init__(self, *args, **kwargs):
  26. super(ServiceTariffCreateForm, self).__init__(*args, **kwargs)
  27. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  28. for field in iter(self.fields):
  29. if 'class' not in self.fields[field].widget.attrs:
  30. self.fields[field].widget.attrs.update({'class':'form-control'})
  31. class Meta:
  32. model = Service
  33. fields = '__all__'
  34. widgets = {
  35. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  36. 'id_provider': forms.Select(attrs={'class': 'form-select'}),
  37. 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  38. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  39. }
  40. class ServiceTypeUpdateForm(forms.ModelForm):
  41. def __init__(self, *args, **kwargs):
  42. super(ServiceTypeUpdateForm, self).__init__(*args, **kwargs)
  43. class Meta:
  44. model = ServiceType
  45. fields = ['codename','requirements','price_type','description',
  46. 'caption', 'status', 'id_metaservice', 'ticket_status',
  47. 'link_agreement', 'is_global','is_visible']
  48. widgets = {
  49. 'status': forms.TextInput(attrs={'readonly': True}),
  50. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  51. }
  52. PRICE_CHOICES = [
  53. ('one', 'text #1'),
  54. ('two', 'text #2'),
  55. ('three', 'text #3'),
  56. ]
  57. class ServiceTypeCreateForm(forms.ModelForm):
  58. codename = forms.CharField(label="Название услуги")
  59. caption = forms.CharField(label="Полное название")
  60. requirements = forms.CharField(label="Требования")
  61. price_type = forms.ChoiceField(choices=PRICE_CHOICES, label="Ценообразование")
  62. status = forms.CharField(label="Статус")
  63. description = forms.CharField(label="Описание")
  64. id_metaservice = forms.IntegerField(label="ID метасервиса")
  65. link_agreement = forms.CharField(label="Ссылка на договор вики")
  66. is_global = forms.BooleanField(label="Доступно во всех сервисах", required=False)
  67. is_visible = forms.BooleanField(label="Доступно для планирования цепочек во всех сервисах", required=False)
  68. def __init__(self, *args, **kwargs):
  69. super(ServiceTypeCreateForm, self).__init__(*args, **kwargs)
  70. class Meta:
  71. model = ServiceType
  72. fields = ['codename','requirements', 'price_type', 'description',
  73. 'caption', 'status', 'id_metaservice', 'ticket_status',
  74. 'link_agreement', 'is_global','is_visible', ]
  75. widgets = {
  76. }
  77. class CommentsCreateForm(forms.ModelForm):
  78. task_description = forms.CharField(label="Описание задачи")
  79. is_global = forms.BooleanField(label="Доступно во всех сервисах", required=False)
  80. is_visible = forms.BooleanField(label="Доступно для планирования цепочек во всех сервисах", required=False)
  81. def __init__(self, *args, **kwargs):
  82. super(CommentsCreateForm, self).__init__(*args, **kwargs)
  83. class Meta:
  84. model = Comments
  85. fields = ['description','user_id',
  86. 'ticket_status', 'id_metaservice',
  87. 'is_global','is_visible',]
  88. widgets = {
  89. }
  90. class TasksCreateForm(forms.ModelForm):
  91. description = forms.CharField(label="Описание")
  92. is_global = forms.BooleanField(label="Доступно во всех сервисах", required=False)
  93. is_visible = forms.BooleanField(label="Доступно для планирования цепочек во всех сервисах", required=False)
  94. def __init__(self, *args, **kwargs):
  95. super(TasksCreateForm, self).__init__(*args, **kwargs)
  96. class Meta:
  97. model = Tasks
  98. fields = ['task_description','repr_id','user_id','dead_line',
  99. 'ticket_status', 'id_metaservice',
  100. 'is_global','is_visible',]
  101. widgets = {
  102. }
  103. class ServiceInformationUpdateForm(forms.ModelForm):
  104. def __init__(self, *args, **kwargs):
  105. super(ServiceInformationUpdateForm, self).__init__(*args, **kwargs)
  106. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  107. for field in iter(self.fields):
  108. if 'class' not in self.fields[field].widget.attrs:
  109. self.fields[field].widget.attrs.update({'class':'form-control'})
  110. class Meta:
  111. model = Service
  112. fields = ['servicetype_id', 'id_provider']
  113. widgets = {
  114. # 'status': forms.TextInput(attrs={'readonly': True}),
  115. # 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  116. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  117. #'repr_id': forms.Select(attrs={'class': 'form-select'}),
  118. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  119. }
  120. class ServiceInformationCreateForm(forms.ModelForm):
  121. def __init__(self, *args, **kwargs):
  122. super(ServiceInformationCreateForm, self).__init__(*args, **kwargs)
  123. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  124. for field in iter(self.fields):
  125. if 'class' not in self.fields[field].widget.attrs:
  126. self.fields[field].widget.attrs.update({'class':'form-control'})
  127. class Meta:
  128. model = Service
  129. fields = "__all__"
  130. exclude = ["id",
  131. "is_global",
  132. "is_visible",
  133. "ticket_status",
  134. "id_metaservice",
  135. "resource_id"]
  136. widgets = {
  137. #'servicetype_id': forms.CharField(max_length=255)
  138. # 'legal_name': forms.TextInput(label = 'Название')
  139. # 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  140. #'repr_id': forms.Select(attrs={'class': 'form-select'}),
  141. # 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  142. # 'ticket_status': forms.Select(attrs={'class': 'form-select'}),
  143. }
  144. class PartnerInformationUpdateForm(forms.ModelForm):
  145. def __init__(self, *args, **kwargs):
  146. super(PartnerInformationUpdateForm, self).__init__(*args, **kwargs)
  147. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  148. for field in iter(self.fields):
  149. if 'class' not in self.fields[field].widget.attrs:
  150. self.fields[field].widget.attrs.update({'class':'form-control'})
  151. class Meta:
  152. model = Company
  153. fields = "__all__"
  154. exclude = ["id", "ticket_status",
  155. "is_global",
  156. "is_visible",
  157. "id_metaservice",
  158. "status"
  159. ]
  160. widgets = {
  161. 'description': forms.Select(attrs={'class': 'form-select'}),
  162. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  163. }
  164. class PartnerInformationCreateForm(forms.ModelForm):
  165. def __init__(self, *args, **kwargs):
  166. super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)
  167. for field in iter(self.fields):
  168. if 'class' not in self.fields[field].widget.attrs:
  169. self.fields[field].widget.attrs.update({'class':'form-control'})
  170. # legal_name = forms.Fi()
  171. class Meta:
  172. model = Company
  173. fields = "__all__"
  174. exclude = ["id", "ticket_status",
  175. "is_global",
  176. "is_visible",
  177. "id_metaservice",
  178. "status"
  179. ]
  180. widgets = {
  181. 'description': forms.Select(attrs={'class': 'form-select'}),
  182. 'repr_id': forms.Select(attrs={'class': 'form-select'}),
  183. }
  184. # username = forms.CharField(label="Номер телефона",
  185. # widget=forms.TextInput(attrs={'class':'form-control'}))
  186. class UserDataForm(forms.ModelForm):
  187. password1 = forms.CharField(label="Пароль",
  188. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  189. password2 = forms.CharField(label="Подтверждение пароля",
  190. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  191. phone_number = forms.CharField(label="Номер телефона",
  192. widget=forms.TextInput(attrs={'class':'form-control'}))
  193. email = forms.CharField(label="Email",
  194. widget=forms.TextInput(attrs={'class':'form-control'}))
  195. username = forms.CharField(label="Имя пользователя",
  196. widget=forms.TextInput(attrs={'class':'form-control'}))
  197. first_name = forms.CharField(label="Имя",
  198. widget=forms.TextInput(attrs={'class':'form-control'}))
  199. last_name = forms.CharField(label="Фамилия",
  200. widget=forms.TextInput(attrs={'class':'form-control'}))
  201. def __init__(self, *args, **kwargs):
  202. super(UserDataForm, self).__init__(*args, **kwargs)
  203. class Meta:
  204. model = get_user_model()
  205. fields = ['username', 'first_name', 'last_name', 'avatar',
  206. 'phone_number', "email", 'password1', 'password2' ]
  207. widgets = {
  208. }