Added search form to specialist catalog

remotes/origin/1203
Ivan Kovalkovskyi 11 years ago
parent cca4bff7f8
commit 025e37f912
  1. 2
      company/views.py
  2. 3
      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
  9. 2624
      templates/client/static_client/css/vendor.css
  10. 266
      templates/client/static_client/js/vendor.js

@ -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

@ -61,4 +61,5 @@ class FeedbackForm(forms.ModelForm):
fields = ['company', 'name', 'text', 'logo', 'catalog'] fields = ['company', 'name', 'text', 'logo', 'catalog']
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>

File diff suppressed because it is too large Load Diff

@ -4431,137 +4431,137 @@ $(document).ready(function () {
}); });
var Base64 = { var Base64 = {
// private property // private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding // public method for encoding
encode : function (input) { encode : function (input) {
var output = ""; var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0; var i = 0;
input = Base64._utf8_encode(input); input = Base64._utf8_encode(input);
while (i < input.length) { while (i < input.length) {
chr1 = input.charCodeAt(i++); chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2; enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63; enc4 = chr3 & 63;
if (isNaN(chr2)) { if (isNaN(chr2)) {
enc3 = enc4 = 64; enc3 = enc4 = 64;
} else if (isNaN(chr3)) { } else if (isNaN(chr3)) {
enc4 = 64; enc4 = 64;
} }
output = output + output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
} }
return output; return output;
}, },
// public method for decoding // public method for decoding
decode : function (input) { decode : function (input) {
var output = ""; var output = "";
var chr1, chr2, chr3; var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4; var enc1, enc2, enc3, enc4;
var i = 0; var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) { while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++)); enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4); chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4; chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1); output = output + String.fromCharCode(chr1);
if (enc3 != 64) { if (enc3 != 64) {
output = output + String.fromCharCode(chr2); output = output + String.fromCharCode(chr2);
} }
if (enc4 != 64) { if (enc4 != 64) {
output = output + String.fromCharCode(chr3); output = output + String.fromCharCode(chr3);
} }
} }
output = Base64._utf8_decode(output); output = Base64._utf8_decode(output);
return output; return output;
}, },
// private method for UTF-8 encoding // private method for UTF-8 encoding
_utf8_encode : function (string) { _utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n"); string = string.replace(/\r\n/g,"\n");
var utftext = ""; var utftext = "";
for (var n = 0; n < string.length; n++) { for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n); var c = string.charCodeAt(n);
if (c < 128) { if (c < 128) {
utftext += String.fromCharCode(c); utftext += String.fromCharCode(c);
} }
else if((c > 127) && (c < 2048)) { else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128); utftext += String.fromCharCode((c & 63) | 128);
} }
else { else {
utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128); utftext += String.fromCharCode((c & 63) | 128);
} }
} }
return utftext; return utftext;
}, },
// private method for UTF-8 decoding // private method for UTF-8 decoding
_utf8_decode : function (utftext) { _utf8_decode : function (utftext) {
var string = ""; var string = "";
var i = 0; var i = 0;
var c = c1 = c2 = 0; var c = c1 = c2 = 0;
while ( i < utftext.length ) { while ( i < utftext.length ) {
c = utftext.charCodeAt(i); c = utftext.charCodeAt(i);
if (c < 128) { if (c < 128) {
string += String.fromCharCode(c); string += String.fromCharCode(c);
i++; i++;
} }
else if((c > 191) && (c < 224)) { else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1); c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2; i += 2;
} }
else { else {
c2 = utftext.charCodeAt(i+1); c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2); c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3; i += 3;
} }
} }
return string; return string;
} }
} }
Loading…
Cancel
Save