2015-05-17 14:39:57 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-01-09 17:03:40 +01:00
|
|
|
from autocomplete_light import shortcuts as autocomplete_light
|
2015-05-17 07:28:55 +02:00
|
|
|
|
2019-04-16 22:18:49 +02:00
|
|
|
from .models import Skola, Resitel, Problem, Organizator
|
2015-05-21 22:17:46 +02:00
|
|
|
from taggit.models import Tag
|
|
|
|
|
|
|
|
|
|
|
|
autocomplete_light.register(Tag)
|
2015-05-17 14:39:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SkolaAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|
|
|
|
|
|
|
model = Skola
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
search_fields = ['nazev', 'mesto', 'ulice']
|
2015-05-17 14:39:57 +02:00
|
|
|
|
|
|
|
split_words = True
|
|
|
|
|
|
|
|
limit_choices = 15
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
attrs = {
|
2015-05-17 14:39:57 +02:00
|
|
|
# This will set the input placeholder attribute:
|
2019-04-23 21:46:29 +02:00
|
|
|
'placeholder': 'Škola',
|
2015-05-17 14:39:57 +02:00
|
|
|
# This will set the yourlabs.Autocomplete.minimumCharacters
|
|
|
|
# options, the naming conversion is handled by jQuery
|
|
|
|
'data-autocomplete-minimum-characters': 1,
|
|
|
|
}
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
widget_attrs = {
|
2015-05-17 14:39:57 +02:00
|
|
|
'data-widget-maximum-values': 15,
|
|
|
|
'class': 'modern-style',
|
|
|
|
}
|
|
|
|
|
|
|
|
autocomplete_light.register(SkolaAutocomplete)
|
|
|
|
|
|
|
|
|
|
|
|
class ResitelAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|
|
|
|
|
|
|
model = Resitel
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
search_fields = ['jmeno', 'prijmeni']
|
2015-05-17 14:39:57 +02:00
|
|
|
|
|
|
|
split_words = False
|
|
|
|
|
|
|
|
limit_choices = 15
|
|
|
|
|
|
|
|
def choice_label(self, resitel):
|
2019-04-23 21:46:29 +02:00
|
|
|
return "%s, %s (%s)" % (resitel.plne_jmeno(), resitel.mesto, resitel.rok_maturity)
|
2015-05-17 14:39:57 +02:00
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
attrs= {
|
2015-05-17 07:28:55 +02:00
|
|
|
# This will set the input placeholder attribute:
|
2019-04-23 21:46:29 +02:00
|
|
|
'placeholder': 'Řešitel',
|
2015-05-17 07:28:55 +02:00
|
|
|
# This will set the yourlabs.Autocomplete.minimumCharacters
|
|
|
|
# options, the naming conversion is handled by jQuery
|
|
|
|
'data-autocomplete-minimum-characters': 1,
|
2015-05-17 14:39:57 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
widget_attrs = {
|
2015-05-17 07:28:55 +02:00
|
|
|
'data-widget-maximum-values': 15,
|
|
|
|
# Enable modern-style widget !
|
|
|
|
'class': 'modern-style',
|
2015-05-17 14:39:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
autocomplete_light.register(ResitelAutocomplete)
|
|
|
|
|
2015-12-22 15:22:40 +01:00
|
|
|
class OrganizatorAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|
|
|
|
|
|
|
model = Organizator
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
search_fields = ['user__first_name', 'user__last_name', 'prezdivka']
|
2015-12-22 15:22:40 +01:00
|
|
|
|
|
|
|
split_words = False
|
|
|
|
|
|
|
|
limit_choices = 15
|
|
|
|
|
|
|
|
def choice_label(self, organizator):
|
2019-04-23 21:46:29 +02:00
|
|
|
return "%s '%s' %s" % (organizator.user.first_name,
|
2015-12-22 15:22:40 +01:00
|
|
|
organizator.prezdivka,
|
|
|
|
organizator.user.last_name)
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
attrs = {
|
2015-12-22 15:22:40 +01:00
|
|
|
# This will set the input placeholder attribute:
|
2019-04-23 21:46:29 +02:00
|
|
|
'placeholder': 'Organizátor',
|
2015-12-22 15:22:40 +01:00
|
|
|
# This will set the yourlabs.Autocomplete.minimumCharacters
|
|
|
|
# options, the naming conversion is handled by jQuery
|
|
|
|
'data-autocomplete-minimum-characters': 1,
|
|
|
|
}
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
widget_attrs = {
|
2015-12-22 15:22:40 +01:00
|
|
|
'data-widget-maximum-values': 15,
|
|
|
|
# Enable modern-style widget !
|
|
|
|
'class': 'modern-style',
|
|
|
|
}
|
|
|
|
|
|
|
|
autocomplete_light.register(OrganizatorAutocomplete)
|
|
|
|
|
|
|
|
|
2015-05-17 14:39:57 +02:00
|
|
|
|
|
|
|
class ProblemAutocomplete(autocomplete_light.AutocompleteModelBase):
|
|
|
|
|
|
|
|
model = Problem
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
search_fields = ['nazev']
|
2015-05-17 14:39:57 +02:00
|
|
|
|
|
|
|
split_words = False
|
|
|
|
|
|
|
|
limit_choices = 10
|
|
|
|
|
|
|
|
def choice_label(self, p):
|
|
|
|
if p.stav == Problem.STAV_ZADANY:
|
2015-09-19 21:08:41 +02:00
|
|
|
popisek = ""
|
|
|
|
try:
|
2019-04-23 21:46:29 +02:00
|
|
|
popisek = "%s (%s, %s.%s)".format(p.nazev, p.typ, p.cislo_zadani.rocnik.rocnik, p.kod_v_rocniku())
|
2015-09-19 21:08:41 +02:00
|
|
|
except:
|
2019-04-23 21:46:29 +02:00
|
|
|
#popisek = "%s (%s, %s.%s)".format(p.nazev, p.typ, p.stav)
|
2015-10-07 17:49:33 +02:00
|
|
|
popisek = "CHYBA"
|
2015-09-19 21:08:41 +02:00
|
|
|
return popisek
|
2015-05-17 14:39:57 +02:00
|
|
|
else:
|
2019-04-23 21:46:29 +02:00
|
|
|
return "%s (%s, %s)".format(p.nazev, p.typ, p.stav)
|
2015-05-17 14:39:57 +02:00
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
attrs = {
|
2015-05-17 14:39:57 +02:00
|
|
|
# This will set the input placeholder attribute:
|
2019-04-23 21:46:29 +02:00
|
|
|
'placeholder': 'Problém',
|
2015-05-17 14:39:57 +02:00
|
|
|
# This will set the yourlabs.Autocomplete.minimumCharacters
|
|
|
|
# options, the naming conversion is handled by jQuery
|
|
|
|
'data-autocomplete-minimum-characters': 1,
|
|
|
|
}
|
|
|
|
|
2019-04-23 21:46:29 +02:00
|
|
|
widget_attrs = {
|
2015-05-17 14:39:57 +02:00
|
|
|
'data-widget-maximum-values': 10,
|
|
|
|
# Enable modern-style widget !
|
|
|
|
'class': 'modern-style',
|
|
|
|
}
|
|
|
|
|
2019-04-23 22:25:18 +02:00
|
|
|
#FIXME Nefunguje, nevime proc
|
2019-04-23 22:27:20 +02:00
|
|
|
#autocomplete_light.register(ProblemAutocomplete)
|
2015-05-17 14:39:57 +02:00
|
|
|
|
|
|
|
|