service_info.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from SharixAdmin.forms import ServiceInformationCreateForm, ServiceInformationUpdateForm
  2. from django.views.generic.edit import CreateView, UpdateView
  3. from metaservicesynced.models import Service
  4. from SharixAdmin.views.context import get_context
  5. from django.urls import reverse
  6. class ServiceInformationCreate(CreateView):
  7. model = Service
  8. form_class = ServiceInformationCreateForm
  9. template_name = "SharixAdmin/service_information_form.html"
  10. def get_context_data(self, **kwargs):
  11. context = super().get_context_data(**kwargs)
  12. context.update(get_context(self.request, {
  13. 'title': 'Информация о сервисе',
  14. 'object': self.object,
  15. }))
  16. return context
  17. def get_success_url(self):
  18. return reverse('test-page')
  19. class ServiceInformationUpdateView(UpdateView):
  20. model = Service
  21. form_class = ServiceInformationUpdateForm
  22. template_name = "SharixAdmin/service_information_form.html"
  23. def get_context_data(self, **kwargs):
  24. context = super().get_context_data(**kwargs)
  25. context.update(get_context(self.request, {
  26. 'title': 'Информация о сервисе',
  27. 'object': self.object,
  28. }))
  29. return context
  30. def get_success_url(self):
  31. return reverse('test-page')