|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import autocomplete_light
|
|
|
|
|
|
|
|
from models import Skola, Resitel, Problem
|
|
|
|
|
|
|
|
|
|
|
|
class SkolaAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|
|
|
|
|
|
|
model = Skola
|
|
|
|
|
|
|
|
search_fields=['nazev', 'mesto', 'ulice']
|
|
|
|
|
|
|
|
split_words = True
|
|
|
|
|
|
|
|
limit_choices = 15
|
|
|
|
|
|
|
|
attrs={
|
|
|
|
# This will set the input placeholder attribute:
|
|
|
|
'placeholder': u'Škola',
|
|
|
|
# This will set the yourlabs.Autocomplete.minimumCharacters
|
|
|
|
# options, the naming conversion is handled by jQuery
|
|
|
|
'data-autocomplete-minimum-characters': 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
widget_attrs={
|
|
|
|
'data-widget-maximum-values': 15,
|
|
|
|
'class': 'modern-style',
|
|
|
|
}
|
|
|
|
|
|
|
|
autocomplete_light.register(SkolaAutocomplete)
|
|
|
|
|
|
|
|
|
|
|
|
class ResitelAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|
|
|
|
|
|
|
model = Resitel
|
|
|
|
|
|
|
|
search_fields=['jmeno', 'prijmeni']
|
|
|
|
|
|
|
|
split_words = False
|
|
|
|
|
|
|
|
limit_choices = 15
|
|
|
|
|
|
|
|
def choice_label(self, resitel):
|
|
|
|
return u"%s, %s (%s)" % (resitel.plne_jmeno(), resitel.mesto, resitel.rok_maturity)
|
|
|
|
|
|
|
|
attrs={
|
|
|
|
# This will set the input placeholder attribute:
|
|
|
|
'placeholder': u'Řešitel',
|
|
|
|
# This will set the yourlabs.Autocomplete.minimumCharacters
|
|
|
|
# options, the naming conversion is handled by jQuery
|
|
|
|
'data-autocomplete-minimum-characters': 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
widget_attrs={
|
|
|
|
'data-widget-maximum-values': 15,
|
|
|
|
# Enable modern-style widget !
|
|
|
|
'class': 'modern-style',
|
|
|
|
}
|
|
|
|
|
|
|
|
autocomplete_light.register(ResitelAutocomplete)
|
|
|
|
|
|
|
|
|
|
|
|
class ProblemAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|
|
|
|
|
|
|
model = Problem
|
|
|
|
|
|
|
|
search_fields=['nazev']
|
|
|
|
|
|
|
|
split_words = False
|
|
|
|
|
|
|
|
limit_choices = 10
|
|
|
|
|
|
|
|
def choice_label(self, p):
|
|
|
|
if p.stav == Problem.STAV_ZADANY:
|
|
|
|
return u"%s (%s, %s.%s)" % (p.nazev, p.typ, p.cislo_zadani.rocnik.rocnik, p.kod_v_rocniku())
|
|
|
|
else:
|
|
|
|
return u"%s (%s, %s)" % (p.nazev, p.typ, p.stav)
|
|
|
|
|
|
|
|
attrs={
|
|
|
|
# This will set the input placeholder attribute:
|
|
|
|
'placeholder': u'Řešitel',
|
|
|
|
# This will set the yourlabs.Autocomplete.minimumCharacters
|
|
|
|
# options, the naming conversion is handled by jQuery
|
|
|
|
'data-autocomplete-minimum-characters': 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
widget_attrs={
|
|
|
|
'data-widget-maximum-values': 10,
|
|
|
|
# Enable modern-style widget !
|
|
|
|
'class': 'modern-style',
|
|
|
|
}
|
|
|
|
|
|
|
|
autocomplete_light.register(ProblemAutocomplete)
|
|
|
|
|
|
|
|
|