You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.1 KiB
78 lines
2.1 KiB
# -*- coding: utf-8 -*-
|
|
from django.http import HttpResponse
|
|
from models import Service
|
|
from functions.custom_views import ExpoListView
|
|
from django.views.generic import ListView, FormView, TemplateView
|
|
from haystack.query import EmptySearchQuerySet
|
|
from django.shortcuts import get_object_or_404
|
|
from django.http import Http404
|
|
import json
|
|
from functions.search_forms import CompanySearchForm
|
|
|
|
from order_forms import TranslationForm, CatalogForm, VisitForm, RemoteForm, ParticipationForm, TicketsForm, AdvertiseForm
|
|
|
|
|
|
order_forms = {'translator': TranslationForm, 'catalog': CatalogForm, 'participation': ParticipationForm,
|
|
'remote': RemoteForm, 'tickets': TicketsForm, 'visit': VisitForm}
|
|
|
|
class ServiceView(FormView):
|
|
|
|
def get_form_class(self):
|
|
url = self.kwargs.get('url')
|
|
form = order_forms.get(url)
|
|
if form:
|
|
return form
|
|
else:
|
|
raise Http404
|
|
|
|
|
|
|
|
def get_template_names(self):
|
|
url = self.kwargs.get('url')
|
|
|
|
service = get_object_or_404(Service, url=url)
|
|
|
|
return service.template
|
|
|
|
|
|
def advertise(request):
|
|
if request.POST:
|
|
response = {'success': False}
|
|
form = AdvertiseForm(request.POST)
|
|
if form.is_valid():
|
|
form.save()
|
|
response['success'] = True
|
|
else:
|
|
response['errors'] = form.errors
|
|
|
|
return HttpResponse(json.dumps(response), content_type='application/json')
|
|
|
|
|
|
from service.models import CallBack, Visit, Translation, Advertising, Participation, Remote, Tickets
|
|
|
|
class AbstractOrderListView(ListView):
|
|
template_name = 'admin/service/order_list.html'
|
|
paginate_by = 20
|
|
|
|
class CallBackListView(AbstractOrderListView):
|
|
model = CallBack
|
|
|
|
|
|
class VisitListView(AbstractOrderListView):
|
|
model = Visit
|
|
|
|
|
|
class TranslationListView(AbstractOrderListView):
|
|
model = Translation
|
|
|
|
class AdvertisingListView(AbstractOrderListView):
|
|
model = Advertising
|
|
|
|
class ParticipationListView(AbstractOrderListView):
|
|
model = Participation
|
|
|
|
class RemoteListView(AbstractOrderListView):
|
|
model = Remote
|
|
|
|
class TicketsListView(AbstractOrderListView):
|
|
model = Tickets
|
|
|