From 5c6b49eefcceea0cc4b8ab9e502127e55ddcaf74 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Tue, 11 Jun 2019 01:26:12 +0200 Subject: [PATCH] Django 2.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit URL jsou rozbité, vždy zobrazí titulku, ale běží. --- korektury/views.py | 8 ++-- mamweb/settings_common.py | 5 ++- mamweb/urls.py | 18 ++++---- mamweb/wsgi.py | 21 +++------ requirements.txt | 40 ++++++++--------- seminar/templatetags/mam_menu.py | 2 +- seminar/urls.py | 76 ++++++++++++++++---------------- 7 files changed, 80 insertions(+), 90 deletions(-) diff --git a/korektury/views.py b/korektury/views.py index d00da453..6a46b42c 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -23,10 +23,10 @@ class KorekturyListView(generic.ListView): model = KorekturovanePDF # Nefunguje, filtry se vubec nepouziji queryset = KorekturovanePDF.objects.annotate( - k_oprave_cnt=Count('oprava',filter=Q(oprava__status='k_oprave')), - opraveno_cnt=Count('oprava',filter=Q(oprava__status='opraveno')), - neni_chyba_cnt=Count('oprava',filter=Q(oprava__status='neni_chyba')), - k_zaneseni_cnt=Count('oprava',filter=Q(oprava__status='k_zaneseni')), + k_oprave_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='k_oprave')), + opraveno_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='opraveno')), + neni_chyba_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='neni_chyba')), + k_zaneseni_cnt=Count('oprava',distinct=True,filter=Q(oprava__status='k_zaneseni')), ) template_name = 'korektury/seznam.html' diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 87d01f37..6201d348 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -57,9 +57,10 @@ MIDDLEWARE = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', - 'mamweb.middleware.LoggedInHintCookieMiddleware', +# FIXME: rozbilo se při přechodu na Django 2.0, nevím, jestli +# se to dá zahodit bez náhrady +# 'mamweb.middleware.LoggedInHintCookieMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', diff --git a/mamweb/urls.py b/mamweb/urls.py index 4d4df748..26646528 100644 --- a/mamweb/urls.py +++ b/mamweb/urls.py @@ -9,29 +9,29 @@ from django import views urlpatterns = [ # Admin a nastroje - url(r'^admin/', include(admin.site.urls)), # NOQA - url(r'^ckeditor/', include('ckeditor_uploader.urls')), - url(r'^autocomplete/', include('autocomplete_light.urls')), + url('admin/', admin.site.urls), # NOQA + url('ckeditor/', include('ckeditor_uploader.urls')), + url('autocomplete/', include('autocomplete_light.urls')), # Seminarova aplikace (ma vlastni podadresare) - url(r'^', include('seminar.urls')), + url('', include('seminar.urls')), # Korekturovaci aplikace (ma vlastni podadresare) - url(r'^', include('korektury.urls')), + url('', include('korektury.urls')), # Prednaskova aplikace (ma vlastni podadresare) - url(r'^', include('prednasky.urls')), + url('', include('prednasky.urls')), # Comments (interni i verejne) - url(r'^comments_dj/', include('django_comments.urls')), - url(r'^comments_fl/', include('fluent_comments.urls')), + url('comments_dj/', include('django_comments.urls')), + url('comments_fl/', include('fluent_comments.urls')), ] # This is only needed when using runserver. if settings.DEBUG: urlpatterns += [ - url(r'^media/(?P.*)$', views.static.serve, # NOQA + url('media/', views.static.serve, # NOQA {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), ] urlpatterns += staticfiles_urlpatterns() diff --git a/mamweb/wsgi.py b/mamweb/wsgi.py index b2c0c787..ddb7f25c 100644 --- a/mamweb/wsgi.py +++ b/mamweb/wsgi.py @@ -4,25 +4,14 @@ WSGI config for mamweb project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ """ -import sys, os, os.path, traceback, time, signal -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mamweb.settings") - -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lib', 'python2.7', 'site-packages'))) +import os +from django.core.wsgi import get_wsgi_application -try: - from django.core.wsgi import get_wsgi_application - application = get_wsgi_application() +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mamweb.settings") -except Exception: - print('handling WSGI exception') - # Error loading applications - if 'mod_wsgi' in sys.modules: - traceback.print_exc() - os.kill(os.getpid(), signal.SIGINT) - time.sleep(2) +application = get_wsgi_application() diff --git a/requirements.txt b/requirements.txt index 25d438d1..c39037fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,30 +1,30 @@ # basic libs -psycopg2==2.7.5 -html5lib==1.0.1 -ipython==5.8.0 -Pillow==5.2.0 -pytz==2018.5 -six==1.10.0 -pexpect==4.6.0 -traitlets==4.3.2 -Unidecode==1.0.22 +psycopg2 +html5lib +ipython +Pillow +pytz +six +pexpect +traitlets +Unidecode # Django and modules -Django>=1.11.17,<2.0 +Django<2.3 #django-bootstrap-sass -django-mptt==0.9.1 -django-reversion==2.0.13 -django-sekizai==0.10.0 -django-countries==5.3.1 -django-solo==1.1.3 -django-ckeditor==5.6.1 -django-flat-theme==1.1.4 -django-taggit==0.23.0 +django-mptt +django-reversion +django-sekizai +django-countries +django-solo +django-ckeditor +django-flat-theme +django-taggit django-autocomplete-light==2.3.6 -django-crispy-forms==1.7.2 -django-imagekit==4.0.2 +django-crispy-forms +django-imagekit # Comments akismet==1.0.1 diff --git a/seminar/templatetags/mam_menu.py b/seminar/templatetags/mam_menu.py index bf0ec3d4..9ae7ac68 100644 --- a/seminar/templatetags/mam_menu.py +++ b/seminar/templatetags/mam_menu.py @@ -10,6 +10,6 @@ def seminar_rocniky(parser, token): 'rocniky': Rocnik.objects.all() } -@register.assignment_tag +@register.simple_tag def aktualni_rocniky(): return Rocnik.objects.all() diff --git a/seminar/urls.py b/seminar/urls.py index aa41c386..6574f88c 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -9,105 +9,105 @@ staff_member_required = user_passes_test(lambda u: u.is_staff) urlpatterns = [ # REDIRECTy - url(r'^jak-resit/$', RedirectView.as_view(url='/co-je-MaM/jak-resit/')), + url('jak-resit/', RedirectView.as_view(url='/co-je-MaM/jak-resit/')), # Organizatori - url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'), - url(r'^co-je-MaM/organizatori/organizovali/$', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'), + url('co-je-MaM/organizatori/', views.CojemamOrganizatoriView.as_view(), name='organizatori'), + url('co-je-MaM/organizatori/organizovali/', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'), # Archiv - url(r'^archiv/cisla/$', views.ArchivView.as_view()), - url(r'^archiv/temata/$', views.ArchivTemataView.as_view()), + url('archiv/cisla/', views.ArchivView.as_view()), + url('archiv/temata/', views.ArchivTemataView.as_view()), - url(r'^rocnik/(?P\d+)/$', views.RocnikView.as_view(), name='seminar_rocnik'), - #url(r'^cislo/(?P\d+)\.(?P[0-9-]+)/$', views.CisloView.as_view(), name='seminar_cislo'), - url(r'^problem/(?P\d+)/$', views.ProblemView.as_view(), name='seminar_problem'), - #url(r'^problem/(?P\d+)/(?P\d+)/$', views.PrispevekView.as_view(), name='seminar_problem_prispevek'), + url('rocnik//', views.RocnikView.as_view(), name='seminar_rocnik'), + #url('cislo/./', views.CisloView.as_view(), name='seminar_cislo'), + url('problem//', views.ProblemView.as_view(), name='seminar_problem'), + #url('problem/(?P\d+)/(?P\d+)/', views.PrispevekView.as_view(), name='seminar_problem_prispevek'), # Soustredeni url( - r'^soustredeni/probehlo/$', + 'soustredeni/probehlo/', views.SoustredeniListView.as_view(), name='seminar_seznam_soustredeni' ), url( - r'^soustredeni/probehlo/(?P\d+)/$', + 'soustredeni/probehlo//', views.SoustredeniView.as_view(), name='seminar_soustredeni' ), url( - r'^soustredeni/(?P\d+)/seznam_ucastniku$', + 'soustredeni//seznam_ucastniku', staff_member_required(views.SoustredeniUcastniciView.as_view()), name='soustredeni_ucastnici' ), url( - r'^soustredeni/(?P\d+)/maily_ucastniku$', + 'soustredeni//maily_ucastniku', staff_member_required(views.SoustredeniMailyUcastnikuView.as_view()), name='maily_ucastniku' ), url( - r'^soustredeni/(?P\d+)/stvrzenky/(?P\d+)$', + 'soustredeni//stvrzenky/', staff_member_required(views.soustredeniStvrzenkyExportView), name='soustredeni_stvrzenky' ), url( - r'^soustredeni/(?P\d+)/export_ucastniku$', + 'soustredeni//export_ucastniku', staff_member_required(views.soustredeniUcastniciExportView), name='soustredeni_ucastnici_export' ), url( - r'^soustredeni/(?P\d+)/fotogalerie/', + 'soustredeni//fotogalerie/', include('galerie.urls') ), # Zadani - url(r'^zadani/aktualni/$', views.AktualniZadaniView, name='seminar_aktualni_zadani'), - url(r'^zadani/temata/$', views.ZadaniTemataView, name='seminar_temata'), - #url(r'^zadani/vysledkova-listina/$', views.ZadaniAktualniVysledkovkaView, name='seminar_vysledky'), - url(r'^$', views.TitulniStranaView.as_view(), name='titulni_strana'), - url(r'^stare-novinky/$', views.StareNovinkyView.as_view(), name='stare_novinky'), + url('zadani/aktualni/', views.AktualniZadaniView, name='seminar_aktualni_zadani'), + url('zadani/temata/', views.ZadaniTemataView, name='seminar_temata'), + #url('zadani/vysledkova-listina/', views.ZadaniAktualniVysledkovkaView, name='seminar_vysledky'), + url('', views.TitulniStranaView.as_view(), name='titulni_strana'), + url('stare-novinky/', views.StareNovinkyView.as_view(), name='stare_novinky'), # Clanky - url(r'^clanky/resitel/$', views.ClankyResitelView.as_view(), name='clanky_resitel'), - #url(r'^clanky/org/$', views.ClankyOrganizatorView.as_view(), name='clanky_organizator'), + url('clanky/resitel/', views.ClankyResitelView.as_view(), name='clanky_resitel'), + #url('clanky/org/', views.ClankyOrganizatorView.as_view(), name='clanky_organizator'), # Aesop - url(r'^aesop-export/mam-rocnik-(?P\d+)\.csv$', export.ExportRocnikView.as_view(), name='seminar_export_rocnik'), - url(r'^aesop-export/mam-sous-(?P[\d-]+)\.csv$', export.ExportSousView.as_view(), name='seminar_export_sous'), - url(r'^aesop-export/index.csv$', export.ExportIndexView.as_view(), name='seminar_export_index'), + url('aesop-export/mam-rocnik-.csv', export.ExportRocnikView.as_view(), name='seminar_export_rocnik'), + url('aesop-export/mam-sous-.csv', export.ExportSousView.as_view(), name='seminar_export_sous'), + url('aesop-export/index.csv', export.ExportIndexView.as_view(), name='seminar_export_index'), # Stranky viditelne pouze pro orgy: #url( - # r'^rocnik/(?P\d+)/vysledkovka.tex$', + # 'rocnik/(?P\d+)/vysledkovka.tex', # staff_member_required(views.RocnikVysledkovkaView.as_view()), # name='seminar_cislo_vysledkovka' #), - #url(r'^cislo/(?P\d+).(?P[0-9-]+)/vysledkovka.tex$', + #url('cislo/(?P\d+).(?P[0-9-]+)/vysledkovka.tex', # staff_member_required(views.CisloVysledkovkaView.as_view()), name='seminar_cislo_vysledkovka'), - url(r'^cislo/(?P\d+).(?P[0-9-]+)/obalky.pdf$', + url('cislo/./obalky.pdf', staff_member_required(views.cisloObalkyView), name='seminar_cislo_obalky'), - #url(r'^cislo/(?P\d+).(?P[0-9-]+)/tituly.tex$', + #url('cislo/(?P\d+).(?P[0-9-]+)/tituly.tex', # staff_member_required(views.TitulyView), name='seminar_cislo_titul'), - url(r'^stav$', + url('stav', staff_member_required(views.StavDatabazeView), name='stav_databaze'), - url(r'^cislo/(?P\d+).(?P[0-9-]+)/obalkovani$', + url('cislo/./obalkovani', staff_member_required(views.obalkovaniView), name='seminar_cislo_resitel_obalkovani'), - url(r'^cislo/(?P\d+).(?P[0-9-]+)/tex-download.json$', + url('cislo/./tex-download.json', staff_member_required(views.texDownloadView), name='seminar_tex_download'), - url(r'^soustredeni/(?P\d+)/obalky.pdf', + url('soustredeni//obalky.pdf', staff_member_required(views.soustredeniObalkyView), name='seminar_soustredeni_obalky'), - url(r'^tex-upload/login/$', views.LoginView, name='seminar_login'), + url('tex-upload/login/', views.LoginView, name='seminar_login'), url( - r'^tex-upload/$', + 'tex-upload/', staff_member_required(views.texUploadView), name='seminar_tex_upload' ), - url(r'^prihlaska/$',views.get_name), + url('prihlaska/',views.get_name), # Ceka na autocomplete v3 - # url(r'^autocomplete/organizatori/$', + # url('autocomplete/organizatori/', # staff_member_required(views.OrganizatorAutocomplete.as_view()), # name='seminar_autocomplete_organizator')