|
@@ -14,41 +14,41 @@ from SharixAdmin.utils import create_ticket_partner_activation
|
|
from .base import BaseView
|
|
from .base import BaseView
|
|
|
|
|
|
|
|
|
|
-class PartnerDetailView(UserPassesTestMixin, BaseView, DetailView):
|
|
|
|
- model = Company
|
|
|
|
- template_name = 'SharixAdmin/partner.html'
|
|
|
|
- context_object_name = 'company'
|
|
|
|
-
|
|
|
|
- page_title = _('О партнере')
|
|
|
|
|
|
+class PartnerBaseView(UserPassesTestMixin, BaseView):
|
|
page_name = 'partner'
|
|
page_name = 'partner'
|
|
|
|
|
|
# Проверяем состояит ли текущий пользователь в группе PARTNER-ADMIN
|
|
# Проверяем состояит ли текущий пользователь в группе PARTNER-ADMIN
|
|
def test_func(self):
|
|
def test_func(self):
|
|
return self.request.user.groups.filter(name='PARTNER-ADMIN').exists()
|
|
return self.request.user.groups.filter(name='PARTNER-ADMIN').exists()
|
|
|
|
|
|
|
|
+
|
|
|
|
+class PartnerDetailView(PartnerBaseView, DetailView):
|
|
|
|
+ model = Company
|
|
|
|
+ template_name = 'SharixAdmin/partner.html'
|
|
|
|
+ context_object_name = 'company'
|
|
|
|
+ page_title = _('О партнере')
|
|
|
|
+
|
|
|
|
+
|
|
def get_object(self, queryset=None):
|
|
def get_object(self, queryset=None):
|
|
return get_object_or_404(Company, repr_id=self.request.user)
|
|
return get_object_or_404(Company, repr_id=self.request.user)
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
+
|
|
context.update({
|
|
context.update({
|
|
- "company_documents": Documents.parse_requirements(self.object.requirements)
|
|
|
|
|
|
+ "doc_codes": Documents.parse_requirements(self.object.requirements),
|
|
|
|
+ "doc_dict": Documents.DOC_TYPES_DICT
|
|
})
|
|
})
|
|
|
|
+
|
|
return context
|
|
return context
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
-class PartnerEditView(UserPassesTestMixin, BaseView, FormView):
|
|
|
|
|
|
+class PartnerEditView(PartnerBaseView, FormView):
|
|
template_name = 'SharixAdmin/partner_edit.html'
|
|
template_name = 'SharixAdmin/partner_edit.html'
|
|
form_class = CompanyForm
|
|
form_class = CompanyForm
|
|
success_url = reverse_lazy('partner_detail')
|
|
success_url = reverse_lazy('partner_detail')
|
|
-
|
|
|
|
page_title = _('Изменение данных партнера')
|
|
page_title = _('Изменение данных партнера')
|
|
- page_name = 'partner'
|
|
|
|
|
|
|
|
- # Проверяем состояит ли текущий пользователь в группе PARTNER-ADMIN
|
|
|
|
- def test_func(self):
|
|
|
|
- return self.request.user.groups.filter(name='PARTNER-ADMIN').exists()
|
|
|
|
|
|
|
|
def get_form_kwargs(self):
|
|
def get_form_kwargs(self):
|
|
kwargs = super().get_form_kwargs()
|
|
kwargs = super().get_form_kwargs()
|
|
@@ -70,4 +70,20 @@ class PartnerEditView(UserPassesTestMixin, BaseView, FormView):
|
|
|
|
|
|
# Отправляем пользователю уведомление на страницу о успехе операции
|
|
# Отправляем пользователю уведомление на страницу о успехе операции
|
|
messages.success(self.request, 'Данные успешно изменены и теперь проходят проверку!')
|
|
messages.success(self.request, 'Данные успешно изменены и теперь проходят проверку!')
|
|
- return super().form_valid(form)
|
|
|
|
|
|
+ return super().form_valid(form)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class PartnerDocDetailView(PartnerBaseView, DetailView):
|
|
|
|
+ template_name = 'SharixAdmin/partner_doc.html'
|
|
|
|
+
|
|
|
|
+ def get_object(self, queryset=None):
|
|
|
|
+ doc_code = self.kwargs.get("doc_code")
|
|
|
|
+ self.page_title = _("Изменение документа партнера: ") + Documents.DOC_TYPES_DICT[doc_code]
|
|
|
|
+
|
|
|
|
+ doc = Documents.objects.filter().first()
|
|
|
|
+ return doc
|
|
|
|
+
|
|
|
|
+ def get_context_data(self, **kwargs):
|
|
|
|
+ context = super().get_context_data(**kwargs)
|
|
|
|
+
|
|
|
|
+ return context
|