12345678910111213141516171819202122232425262728293031 |
- from django.views.generic.edit import CreateView
- from django.urls import reverse_lazy
- from SharixAdmin.models import Metaservice
- from tickets.models import Task
- from core.config import API_URL
- from ..forms.service_create import Service_Create__form
- from ..apps import api
- import requests
- class Service_Create__view(CreateView):
- form_class = Service_Create__form
- template_name = 'service_create.html'
- success_url = reverse_lazy('platformrunning:home')
- def form_valid(self, form):
- form.instance.representative_id = self.request.user
- response = super().form_valid(form)
-
- new_ticket = {
- "task_list": 1,
- "created_by": self.request.user.pk,
- "type": 1,
- "title": "service_create",
- "note": str(form.data),
- }
- requests.post(f"{API_URL}/tickets/api/tickets/", data=new_ticket, headers=api.headers)
- return response
|