Browse Source

Odstranen autocomplete v2, pridan v3.

Autocomplete light v galerii nahrazen nativnim admin autocompletem.
Pridan autocomplete light v3 pro vyber skoly v prihlasce.
export_seznamu_prednasek
parent
commit
9b78920dd4
  1. 4
      galerie/admin.py
  2. 0
      galerie/autocomplete_light_registry.py.old
  3. 3
      mamweb/settings_common.py
  4. 1
      mamweb/templates/admin/base_site.html
  5. 1
      mamweb/templates/base.html
  6. 1
      mamweb/urls.py
  7. 2
      requirements.txt
  8. 0
      seminar/autocomplete_light_registry.py.old
  9. 10
      seminar/forms.py
  10. 4
      seminar/templates/seminar/prihlaska.html
  11. 1
      seminar/urls.py
  12. 22
      seminar/views.py

4
galerie/admin.py

@ -5,7 +5,6 @@ from django.contrib import admin
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django import forms from django import forms
from django.db import models from django.db import models
from autocomplete_light import shortcuts as autocomplete_light
# akction # akction
@ -39,11 +38,12 @@ class GalerieInline(admin.TabularInline):
class ObrazekAdmin(admin.ModelAdmin): class ObrazekAdmin(admin.ModelAdmin):
list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag') list_display = ('obrazek_velky', 'nazev', 'popis', 'obrazek_maly_tag')
search_fields = ['nazev','popis']
class GalerieAdmin(admin.ModelAdmin): class GalerieAdmin(admin.ModelAdmin):
form = autocomplete_light.modelform_factory(Galerie, autocomplete_fields=['titulni_obrazek'], fields=['titulni_obrazek'])
model = Galerie model = Galerie
fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi') fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni', 'poradi')
autocomplete_fields = ['titulni_obrazek']
list_display = ('nazev', 'soustredeni', 'galerie_up', 'poradi', 'zobrazit', 'datum_zmeny') list_display = ('nazev', 'soustredeni', 'galerie_up', 'poradi', 'zobrazit', 'datum_zmeny')
inlines = [GalerieInline] inlines = [GalerieInline]
actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu] actions = [zverejnit_fotogalerii, prepnout_fotogalerii_do_org_rezimu]

0
galerie/autocomplete_light_registry.py → galerie/autocomplete_light_registry.py.old

3
mamweb/settings_common.py

@ -103,7 +103,8 @@ INSTALLED_APPS = (
'ckeditor', 'ckeditor',
'ckeditor_uploader', 'ckeditor_uploader',
'taggit', 'taggit',
'autocomplete_light', 'dal',
'dal_select2',
'fluent_comments', 'fluent_comments',
'crispy_forms', 'crispy_forms',

1
mamweb/templates/admin/base_site.html

@ -4,7 +4,6 @@
{% block extrahead %} {% block extrahead %}
<link rel="shortcut icon" href="{% static 'favicon.ico' %}" type="image/x-icon"> <link rel="shortcut icon" href="{% static 'favicon.ico' %}" type="image/x-icon">
<script src="{% static 'js/jquery-1.11.1.js' %}"></script> <script src="{% static 'js/jquery-1.11.1.js' %}"></script>
{% include 'autocomplete_light/static.html' %}
{% endblock %} {% endblock %}
{% block branding %} {% block branding %}

1
mamweb/templates/base.html

@ -11,7 +11,6 @@
<link href="{% static 'css/mamweb.css' %}" rel="stylesheet"> <link href="{% static 'css/mamweb.css' %}" rel="stylesheet">
<link href="{% static 'css/prettyPhoto.css' %}" rel="stylesheet" type="text/css" media="screen" charset="utf-8" /> <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> <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' %}" /> <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> <script type="text/javascript" src="{% static 'fluent_comments/js/ajaxcomments.js' %}"></script>

1
mamweb/urls.py

@ -11,7 +11,6 @@ urlpatterns = [
# Admin a nastroje # Admin a nastroje
path('admin/', admin.site.urls), # NOQA path('admin/', admin.site.urls), # NOQA
path('ckeditor/', include('ckeditor_uploader.urls')), path('ckeditor/', include('ckeditor_uploader.urls')),
path('autocomplete/', include('autocomplete_light.urls')),
# Seminarova aplikace (ma vlastni podadresare) # Seminarova aplikace (ma vlastni podadresare)
path('', include('seminar.urls')), path('', include('seminar.urls')),

2
requirements.txt

@ -22,7 +22,7 @@ django-solo
django-ckeditor django-ckeditor
django-flat-theme django-flat-theme
django-taggit django-taggit
django-autocomplete-light==2.3.6 django-autocomplete-light
django-crispy-forms django-crispy-forms
django-imagekit django-imagekit
django-polymorphic django-polymorphic

0
seminar/autocomplete_light_registry.py → seminar/autocomplete_light_registry.py.old

10
seminar/forms.py

@ -1,6 +1,12 @@
from django import forms from django import forms
from dal import autocomplete
from .models import Skola
from seminar.models import Resitel from seminar.models import Resitel
class PrihlaskaForm(forms.Form): class PrihlaskaForm(forms.Form):
jmeno = forms.CharField(label='Jméno', max_length=256, required=True) jmeno = forms.CharField(label='Jméno', max_length=256, required=True)
prijmeni = forms.CharField(label='Příjmení', 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é')), ('other', 'Jiné')),
required=False) required=False)
skola = forms.ModelChoiceField(
queryset=Skola.objects.all(),
widget=autocomplete.ModelSelect2(url='autocomplete_skola')
)
# skola_stat_select = forms.ChoiceField(label='Stát', # skola_stat_select = forms.ChoiceField(label='Stát',
# choices = (('cz', 'Česká Republika'), # choices = (('cz', 'Česká Republika'),

4
seminar/templates/seminar/prihlaska.html

@ -1,8 +1,10 @@
{% extends "seminar/zadani/base.html" %} {% extends "seminar/zadani/base.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load static %}
{% block script %} {% block script %}
<script src="{% static 'seminar/skoly.js' %}"></script> <script src="{% static 'seminar/skoly.js' %}"></script>
<script type="text/javascript" src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@ -35,5 +37,7 @@ $("#id_kraj_select").on("change",region_changed);
//$("#id_skola_stat_select").on("change",country_changed); //$("#id_skola_stat_select").on("change",country_changed);
</script> </script>
{{form.media}}
{% endblock %} {% endblock %}

1
seminar/urls.py

@ -100,6 +100,7 @@ urlpatterns = [
path('prihlaska/',views.prihlaskaView), path('prihlaska/',views.prihlaskaView),
path('', views.TitulniStranaView.as_view(), name='titulni_strana'), path('', views.TitulniStranaView.as_view(), name='titulni_strana'),
path('autocomplete/skola/',views.SkolaAutocomplete.as_view(), name='autocomplete_skola')
# Ceka na autocomplete v3 # Ceka na autocomplete v3
# path('autocomplete/organizatori/', # path('autocomplete/organizatori/',
# staff_member_required(views.OrganizatorAutocomplete.as_view()), # staff_member_required(views.OrganizatorAutocomplete.as_view()),

22
seminar/views.py

@ -10,8 +10,9 @@ from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect
from django.db.models import Q from django.db.models import Q
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from django.contrib.auth import authenticate, login, get_user_model 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 .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
from . import utils from . import utils
from .unicodecsv import UnicodeWriter from .unicodecsv import UnicodeWriter
@ -1011,7 +1012,11 @@ def prihlaskaView(request):
r.save() r.save()
r.osoba = o 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() r.save()
@ -1025,6 +1030,19 @@ def prihlaskaView(request):
return render(request, 'seminar/prihlaska.html', {'form': form}) 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 # Ceka na autocomplete v3
# class OrganizatorAutocomplete(autocomplete.Select2QuerySetView): # class OrganizatorAutocomplete(autocomplete.Select2QuerySetView):
# def get_queryset(self): # def get_queryset(self):

Loading…
Cancel
Save