partner_info.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from django.shortcuts import render
  2. from SharixAdmin.forms import PartnerInformationCreateForm, PartnerInformationUpdateForm
  3. from metaservicesynced.models import Company
  4. from django.views.generic.edit import UpdateView, CreateView
  5. from SharixAdmin.views.context import get_context
  6. from django.urls import reverse
  7. class PartnerInformationCreate(CreateView):
  8. model = Company
  9. form_class = PartnerInformationCreateForm
  10. template_name = "SharixAdmin/partner_information_form.html"
  11. def get_context_data(self, **kwargs):
  12. context = super().get_context_data(**kwargs)
  13. context.update(get_context(self.request, {
  14. 'title': 'Информация о партнере',
  15. 'object': self.object,
  16. }))
  17. return context
  18. def get_success_url(self):
  19. return reverse('test-page')
  20. class PartnerInformationUpdateView(UpdateView):
  21. model = Company
  22. form_class = PartnerInformationUpdateForm
  23. template_name = "SharixAdmin/partner_information_form.html"
  24. def get_context_data(self, **kwargs):
  25. context = super().get_context_data(**kwargs)
  26. context.update(get_context(self.request, {
  27. 'title': 'Информация о партнере',
  28. 'object': self.object,
  29. }))
  30. return context
  31. def get_success_url(self):
  32. return reverse('test-page')
  33. def partner_information(request):
  34. context = get_context(request, {
  35. 'title':'Информация о партнере',
  36. })
  37. return render(request, 'SharixAdmin/partner_information.html', context)