Odstranen autocomplete v2, pridan v3.
Autocomplete light v galerii nahrazen nativnim admin autocompletem. Pridan autocomplete light v3 pro vyber skoly v prihlasce.
This commit is contained in:
parent
c57b99c015
commit
9b78920dd4
12 changed files with 40 additions and 9 deletions
|
@ -5,7 +5,6 @@ from django.contrib import admin
|
|||
from django.http import HttpResponseRedirect
|
||||
from django import forms
|
||||
from django.db import models
|
||||
from autocomplete_light import shortcuts as autocomplete_light
|
||||
|
||||
# akction
|
||||
|
||||
|
@ -39,11 +38,12 @@ class GalerieInline(admin.TabularInline):
|
|||
|
||||
class ObrazekAdmin(admin.ModelAdmin):
|
||||
list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag')
|
||||
search_fields = ['nazev','popis']
|
||||
|
||||
class GalerieAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(Galerie, autocomplete_fields=['titulni_obrazek'], fields=['titulni_obrazek'])
|
||||
model = Galerie
|
||||
fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi')
|
||||
autocomplete_fields = ['titulni_obrazek']
|
||||
list_display = ('nazev', 'soustredeni', 'galerie_up', 'poradi', 'zobrazit', 'datum_zmeny')
|
||||
inlines = [GalerieInline]
|
||||
actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu]
|
||||
|
|
|
@ -103,7 +103,8 @@ INSTALLED_APPS = (
|
|||
'ckeditor',
|
||||
'ckeditor_uploader',
|
||||
'taggit',
|
||||
'autocomplete_light',
|
||||
'dal',
|
||||
'dal_select2',
|
||||
|
||||
'fluent_comments',
|
||||
'crispy_forms',
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
{% block extrahead %}
|
||||
<link rel="shortcut icon" href="{% static 'favicon.ico' %}" type="image/x-icon">
|
||||
<script src="{% static 'js/jquery-1.11.1.js' %}"></script>
|
||||
{% include 'autocomplete_light/static.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block branding %}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<link href="{% static 'css/mamweb.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'css/prettyPhoto.css' %}" rel="stylesheet" type="text/css" media="screen" charset="utf-8" />
|
||||
<script src="{% static 'js/jquery-1.11.1.js' %}"></script>
|
||||
{% include 'autocomplete_light/static.html' %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'fluent_comments/css/ajaxcomments.css' %}" />
|
||||
<script type="text/javascript" src="{% static 'fluent_comments/js/ajaxcomments.js' %}"></script>
|
||||
|
|
|
@ -11,7 +11,6 @@ urlpatterns = [
|
|||
# Admin a nastroje
|
||||
path('admin/', admin.site.urls), # NOQA
|
||||
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||
path('autocomplete/', include('autocomplete_light.urls')),
|
||||
|
||||
# Seminarova aplikace (ma vlastni podadresare)
|
||||
path('', include('seminar.urls')),
|
||||
|
|
|
@ -22,7 +22,7 @@ django-solo
|
|||
django-ckeditor
|
||||
django-flat-theme
|
||||
django-taggit
|
||||
django-autocomplete-light==2.3.6
|
||||
django-autocomplete-light
|
||||
django-crispy-forms
|
||||
django-imagekit
|
||||
django-polymorphic
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
from django import forms
|
||||
from dal import autocomplete
|
||||
from .models import Skola
|
||||
|
||||
from seminar.models import Resitel
|
||||
|
||||
|
||||
|
||||
|
||||
class PrihlaskaForm(forms.Form):
|
||||
jmeno = forms.CharField(label='Jméno', max_length=256, required=True)
|
||||
prijmeni = forms.CharField(label='Příjmení', max_length=256, required=True)
|
||||
|
@ -20,6 +26,10 @@ class PrihlaskaForm(forms.Form):
|
|||
('other', 'Jiné')),
|
||||
required=False)
|
||||
|
||||
skola = forms.ModelChoiceField(
|
||||
queryset=Skola.objects.all(),
|
||||
widget=autocomplete.ModelSelect2(url='autocomplete_skola')
|
||||
)
|
||||
|
||||
# skola_stat_select = forms.ChoiceField(label='Stát',
|
||||
# choices = (('cz', 'Česká Republika'),
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{% extends "seminar/zadani/base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load static %}
|
||||
|
||||
{% block script %}
|
||||
<script src="{% static 'seminar/skoly.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -35,5 +37,7 @@ $("#id_kraj_select").on("change",region_changed);
|
|||
//$("#id_skola_stat_select").on("change",country_changed);
|
||||
</script>
|
||||
|
||||
{{form.media}}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ urlpatterns = [
|
|||
path('prihlaska/',views.prihlaskaView),
|
||||
path('', views.TitulniStranaView.as_view(), name='titulni_strana'),
|
||||
|
||||
path('autocomplete/skola/',views.SkolaAutocomplete.as_view(), name='autocomplete_skola')
|
||||
# Ceka na autocomplete v3
|
||||
# path('autocomplete/organizatori/',
|
||||
# staff_member_required(views.OrganizatorAutocomplete.as_view()),
|
||||
|
|
|
@ -10,8 +10,9 @@ from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect
|
|||
from django.db.models import Q
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.contrib.auth import authenticate, login, get_user_model
|
||||
from dal import autocomplete
|
||||
|
||||
from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Tema, Clanek, Osoba
|
||||
from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Tema, Clanek, Osoba, Skola
|
||||
#from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||
from . import utils
|
||||
from .unicodecsv import UnicodeWriter
|
||||
|
@ -1011,7 +1012,11 @@ def prihlaskaView(request):
|
|||
|
||||
r.save()
|
||||
r.osoba = o
|
||||
#TODO doplnit skolu
|
||||
if form.cleaned_data.get('skola'):
|
||||
r.skola = form.cleaned_data['skola']
|
||||
else:
|
||||
pass
|
||||
#TODO doplnit skolu, kdyz neni v seznamu
|
||||
r.save()
|
||||
|
||||
|
||||
|
@ -1025,6 +1030,19 @@ def prihlaskaView(request):
|
|||
|
||||
return render(request, 'seminar/prihlaska.html', {'form': form})
|
||||
|
||||
class SkolaAutocomplete(autocomplete.Select2QuerySetView):
|
||||
def get_queryset(self):
|
||||
# Don't forget to filter out results depending on the visitor !
|
||||
qs = Skola.objects.all()
|
||||
if self.q:
|
||||
qs = qs.filter(
|
||||
Q(nazev__istartswith=self.q)|
|
||||
Q(kratky_nazev__istartswith=self.q)|
|
||||
Q(ulice__istartswith=self.q)|
|
||||
Q(mesto__istartswith=self.q))
|
||||
|
||||
return qs
|
||||
|
||||
# Ceka na autocomplete v3
|
||||
# class OrganizatorAutocomplete(autocomplete.Select2QuerySetView):
|
||||
# def get_queryset(self):
|
||||
|
|
Loading…
Reference in a new issue