Added search form to specialist catalog

remotes/origin/1203
Ivan Kovalkovskyi 11 years ago
parent cca4bff7f8
commit 025e37f912
  1. 2
      company/views.py
  2. 1
      specialist_catalog/forms.py
  3. 1
      specialist_catalog/models.py
  4. 27
      specialist_catalog/views.py
  5. 1
      static/client
  6. 1
      static/client
  7. 13
      templates/admin/specialist/catalog_all.html
  8. 14
      templates/admin/specialist/specialist_all.html

@ -21,7 +21,7 @@ from meta.views import MetadataMixin
class CompanySearchView(ListView): class CompanySearchView(ListView):
paginate_by = 10 paginate_by = 10
template_name = 'company/search.html' template_name = 'client/company/search.html'
search_form = CompanySearchForm search_form = CompanySearchForm
model = Company model = Company

@ -62,3 +62,4 @@ class FeedbackForm(forms.ModelForm):
widgets = { widgets = {
'text':CKEditorWidget 'text':CKEditorWidget
} }

@ -20,6 +20,7 @@ class Specialist(models.Model):
country = models.ForeignKey(Country, on_delete=models.PROTECT, verbose_name=u"Страна") country = models.ForeignKey(Country, on_delete=models.PROTECT, verbose_name=u"Страна")
photo = models.ImageField(verbose_name=u"Фото", upload_to="specialist_catalog/specialist_photo/", blank=True) photo = models.ImageField(verbose_name=u"Фото", upload_to="specialist_catalog/specialist_photo/", blank=True)
def __unicode__(self): def __unicode__(self):
return u"%s" % self.name return u"%s" % self.name

@ -21,11 +21,24 @@ class SpecialistCreateView(CreateView):
success_url = reverse_lazy("specialist_all") success_url = reverse_lazy("specialist_all")
from hvad.utils import get_translation_aware_manager
class SpecialistListView(ListView): class SpecialistListView(ListView):
model = Specialist model = Specialist
template_name = 'admin/specialist/specialist_all.html' template_name = 'admin/specialist/specialist_all.html'
paginate_by = settings.ADMIN_PAGINATION paginate_by = settings.ADMIN_PAGINATION
def get_queryset(self):
name = self.request.GET.get('name', None)
city = self.request.GET.get('city', None)
qs = get_translation_aware_manager(Specialist).all()
if name:
qs = qs.filter(name__icontains=name)
if city:
qs = qs.filter(city__name__icontains=city)
return qs
class SpecialistUpdateView(UpdateView): class SpecialistUpdateView(UpdateView):
form_class = SpecialistForm form_class = SpecialistForm
@ -67,8 +80,11 @@ class CatalogCityView(ListView):
paginate_by = settings.ADMIN_PAGINATION paginate_by = settings.ADMIN_PAGINATION
def get_queryset(self): def get_queryset(self):
qs = super(CatalogCityView, self).get_queryset() query = self.request.GET.get('query', None)
return qs.filter(type=2) qs = self.model.objects.language().filter(type=2)
if query:
qs = qs.filter(title__icontains=query)
return qs
class CatalogCountryView(ListView): class CatalogCountryView(ListView):
@ -77,8 +93,11 @@ class CatalogCountryView(ListView):
paginate_by = settings.ADMIN_PAGINATION paginate_by = settings.ADMIN_PAGINATION
def get_queryset(self): def get_queryset(self):
qs = super(CatalogCountryView, self).get_queryset() query = self.request.GET.get('query', None)
return qs.filter(type=1) qs = self.model.objects.language().filter(type=1)
if query:
qs = qs.filter(title__icontains=query)
return qs
class CatalogUpdateView(UpdateView): class CatalogUpdateView(UpdateView):

@ -1 +0,0 @@
/home/www/proj/templates/client/static_client

@ -0,0 +1 @@
/home/www/proj/templates/client/static_client

@ -1,6 +1,19 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load thumbnail %} {% load thumbnail %}
{% block body %} {% block body %}
<div class="box span8">
<div class="box-header well">
<h2><i class="icon-arrow-down"></i>Поиск</h2>
</div>
<div class="box-content">
<form method="get">
<input id="find" type ='text' name = 'query' placeholder="Введите запрос">
<button type="submit" class="btn">Найти</button>
</form>
</div>
</div>
<div class="box span8"> <div class="box span8">
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-arrow-down"></i>Все каталоги специалистов</h2> <h2><i class="icon-arrow-down"></i>Все каталоги специалистов</h2>

@ -1,6 +1,20 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load thumbnail %} {% load thumbnail %}
{% block body %} {% block body %}
<div class="box span8">
<div class="box-header well">
<h2><i class="icon-arrow-down"></i>Поиск</h2>
</div>
<div class="box-content">
<form method="get">
<input id="find" type ='text' name = 'name' placeholder="Введите имя">
<input id="find1" type ='text' name = 'city' placeholder="Город">
<button type="submit" class="btn">Найти</button>
</form>
</div>
</div>
<div class="box span8"> <div class="box span8">
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-arrow-down"></i>Список специалистов(переводчиков)</h2> <h2><i class="icon-arrow-down"></i>Список специалистов(переводчиков)</h2>

Loading…
Cancel
Save