service.py 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. from django import forms
  2. from dbsynce.models import ServiceType, Service, Company
  3. class ServiceTariffUpdateForm(forms.ModelForm):
  4. def __init__(self, *args, **kwargs):
  5. super(ServiceTariffUpdateForm, self).__init__(*args, **kwargs)
  6. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  7. for field in iter(self.fields):
  8. if 'class' not in self.fields[field].widget.attrs:
  9. self.fields[field].widget.attrs.update({'class':'form-control'})
  10. class Meta:
  11. model = Service
  12. fields = ['status','ticket_status','servicetype_id','id_provider',
  13. 'resource_id','requirements','price_alg','price_km','price_min','price_amount','service_status',
  14. 'is_global','is_visible']
  15. widgets = {
  16. 'status': forms.TextInput(attrs={'readonly': True}, ),
  17. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  18. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  19. 'id_provider': forms.Select(attrs={'class': 'form-select'}),
  20. 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  21. }
  22. class ServiceTariffCreateForm(forms.ModelForm):
  23. def __init__(self, *args, **kwargs):
  24. super(ServiceTariffCreateForm, self).__init__(*args, **kwargs)
  25. # Добавляет стиль бутстрапа form-control всем полям таблицы если у них нет своих стилей
  26. for field in iter(self.fields):
  27. if 'class' not in self.fields[field].widget.attrs:
  28. self.fields[field].widget.attrs.update({'class':'form-control'})
  29. class Meta:
  30. model = Service
  31. fields = '__all__'
  32. widgets = {
  33. 'servicetype_id': forms.Select(attrs={'class': 'form-select'}),
  34. 'id_provider': forms.Select(attrs={'class': 'form-select'}),
  35. 'resource_id': forms.Select(attrs={'class': 'form-select'}),
  36. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  37. }
  38. class ServiceTypeUpdateForm(forms.ModelForm):
  39. def __init__(self, *args, **kwargs):
  40. super(ServiceTypeUpdateForm, self).__init__(*args, **kwargs)
  41. class Meta:
  42. model = ServiceType
  43. fields = ['status','ticket_status','id_metaservice','codename',
  44. 'description','requirements','price_type','link_agreement',
  45. 'is_global','is_visible']
  46. widgets = {
  47. 'status': forms.TextInput(attrs={'readonly': True}),
  48. 'ticket_status': forms.TextInput(attrs={'readonly': True}),
  49. }
  50. PRICE_CHOICES = [
  51. ('one', 'text #1'),
  52. ('two', 'text #2'),
  53. ('three', 'text #3'),
  54. ]
  55. class ServiceTypeCreateForm(forms.ModelForm):
  56. codename = forms.CharField(label="Название услуги")
  57. requirements = forms.CharField(label="Требования")
  58. price_type = forms.ChoiceField(choices=PRICE_CHOICES, label="Ценообразование")
  59. description = forms.CharField(label="Описание")
  60. is_global = forms.BooleanField(label="Доступно во всех сервисах", required=False)
  61. is_visible = forms.BooleanField(label="Доступно для планирования цепочек во всех сервисах", required=False)
  62. def __init__(self, *args, **kwargs):
  63. super(ServiceTypeCreateForm, self).__init__(*args, **kwargs)
  64. class Meta:
  65. model = ServiceType
  66. fields = ['codename','requirements', 'price_type',
  67. 'description',
  68. 'is_global','is_visible',]
  69. widgets = {
  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'}))