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.
101 lines
3.2 KiB
101 lines
3.2 KiB
# -*- coding: utf-8 -*-
|
|
from django.views.generic import CreateView, UpdateView, DeleteView, ListView, DetailView
|
|
from .forms import *
|
|
from django.core.urlresolvers import reverse_lazy
|
|
from django.conf import settings
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
|
|
class SpecialistCreateView(CreateView):
|
|
form_class = SpecialistForm
|
|
model = Specialist
|
|
template_name = 'admin/specialist/specialist_new.html'
|
|
success_url = reverse_lazy("specialist_all")
|
|
|
|
|
|
class SpecialistListView(ListView):
|
|
model = Specialist
|
|
template_name = 'admin/specialist/specialist_all.html'
|
|
paginate_by = settings.ADMIN_PAGINATION
|
|
|
|
|
|
class SpecialistUpdateView(UpdateView):
|
|
form_class = SpecialistForm
|
|
model = Specialist
|
|
template_name = 'admin/specialist/specialist_new.html'
|
|
success_url = reverse_lazy("specialist_all")
|
|
|
|
def get_form(self, form_class):
|
|
form = super(SpecialistUpdateView, self).get_form(form_class)
|
|
form.fields['city'].widget.attrs['data-init-text'] = self.object.city.name
|
|
return form
|
|
|
|
|
|
class SpecialistDeleteView(DeleteView):
|
|
model = Specialist
|
|
template_name = 'admin/specialist/specialist_confirm_delete.html'
|
|
success_url = reverse_lazy("specialist_all")
|
|
|
|
|
|
class CatalogCreateView(CreateView):
|
|
form_class = SpecialistCatalogForm
|
|
model = SpecialistCatalog
|
|
template_name = 'admin/specialist/catalog_new.html'
|
|
success_url = reverse_lazy("catalog_all")
|
|
|
|
|
|
class CatalogListView(ListView):
|
|
model = SpecialistCatalog
|
|
template_name = 'admin/specialist/catalog_all.html'
|
|
paginate_by = settings.ADMIN_PAGINATION
|
|
|
|
|
|
class CatalogUpdateView(UpdateView):
|
|
form_class = SpecialistCatalogForm
|
|
model = SpecialistCatalog
|
|
template_name = 'admin/specialist/catalog_new.html'
|
|
success_url = reverse_lazy("catalog_all")
|
|
|
|
def get_form(self, form_class):
|
|
form = super(CatalogUpdateView, self).get_form(form_class)
|
|
if self.object.type is 2: # city
|
|
form.fields['city'].widget.attrs['data-init-text'] = self.object.city.name
|
|
return form
|
|
|
|
|
|
class CatalogDeleteView(DeleteView):
|
|
model = SpecialistCatalog
|
|
template_name = 'admin/specialist/catalog_confirm_delete.html'
|
|
success_url = reverse_lazy("catalog_all")
|
|
|
|
|
|
class FeedbackCreateView(CreateView):
|
|
form_class = FeedbackForm
|
|
model = Feedback
|
|
template_name = 'admin/specialist/feedback_new.html'
|
|
success_url = reverse_lazy("catalog_all")
|
|
|
|
def get_initial(self):
|
|
catalog = get_object_or_404(SpecialistCatalog, pk=self.kwargs.get('pk'))
|
|
return {'catalog': catalog}
|
|
|
|
# class FeedbackListView(ListView):
|
|
# model = Feedback
|
|
# template_name = 'admin/specialist/feedback_all.html'
|
|
# paginate_by = settings.ADMIN_PAGINATION
|
|
|
|
|
|
class FeedbackUpdateView(UpdateView):
|
|
form_class = FeedbackForm
|
|
model = Feedback
|
|
template_name = 'admin/specialist/feedback_new.html'
|
|
success_url = reverse_lazy("catalog_all")
|
|
|
|
def get_initial(self):
|
|
catalog = get_object_or_404(SpecialistCatalog, pk=self.kwargs.get('id'))
|
|
return {'catalog': catalog}
|
|
|
|
class FeedbackDeleteView(DeleteView):
|
|
model = Feedback
|
|
template_name = 'admin/specialist/feedback_confirm_delete.html'
|
|
success_url = reverse_lazy("catalog_all")
|
|
|