From 6d9c2ea02101d0e24340bbb4bf448cfae1bec139 Mon Sep 17 00:00:00 2001 From: LEdoian Date: Mon, 17 Sep 2018 00:01:16 +0200 Subject: [PATCH 1/6] =?UTF-8?q?Zm=C4=9Bna=20NoArgsCommand=20na=20BaseComma?= =?UTF-8?q?nd=20kv=C5=AFli=20upgrade=20Djanga?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://docs.djangoproject.com/en/1.11/releases/1.8/ django.core.management.NoArgsCommand The class NoArgsCommand is now deprecated and will be removed in Django 1.10. Use BaseCommand instead, which takes no arguments by default. --- seminar/management/commands/auth.py | 4 ++-- seminar/management/commands/testdata.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/seminar/management/commands/auth.py b/seminar/management/commands/auth.py index 1aa504dd..894a87bc 100644 --- a/seminar/management/commands/auth.py +++ b/seminar/management/commands/auth.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand from django.contrib.sessions.models import Session from django.contrib.auth.models import User -class Command(NoArgsCommand): +class Command(BaseCommand): u"""Vypiš username přihlášeného orga s daným session_key. Příkaz pro manage.py, který ze vstupu přečte session_key (tak, jak je diff --git a/seminar/management/commands/testdata.py b/seminar/management/commands/testdata.py index dda7b097..aaa59462 100644 --- a/seminar/management/commands/testdata.py +++ b/seminar/management/commands/testdata.py @@ -4,7 +4,7 @@ import datetime import os import random -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand from django.core.management import call_command from django.conf import settings @@ -14,7 +14,7 @@ import django.contrib.auth User = django.contrib.auth.get_user_model() -class Command(NoArgsCommand): +class Command(BaseCommand): help = "Clear database and load testing data." def handle_noargs(self, **options): From d4317ae9f2b52b308302b3d7b5940e25da597f21 Mon Sep 17 00:00:00 2001 From: LEdoian Date: Mon, 17 Sep 2018 00:10:00 +0200 Subject: [PATCH 2/6] =?UTF-8?q?Fix=20(nebyla=20definov=C3=A1na=20metoda=20?= =?UTF-8?q?handle)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://stackoverflow.com/questions/43107630/from-django-core-management-base-import-noargscommand-commanderror-importerror --- seminar/management/commands/auth.py | 2 +- seminar/management/commands/testdata.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/seminar/management/commands/auth.py b/seminar/management/commands/auth.py index 894a87bc..71757418 100644 --- a/seminar/management/commands/auth.py +++ b/seminar/management/commands/auth.py @@ -11,7 +11,7 @@ class Command(BaseCommand): uložen v cookie sessionid) a pokud session existuje a příslušný přihlášený uživatel má právo přihlásit se do admina, vypíše jeho username. """ - def handle_noargs(self, **options): + def handle(self, *args, **options): session_key = raw_input() s = Session.objects.get(pk=session_key).get_decoded() user_id = s['_auth_user_id'] diff --git a/seminar/management/commands/testdata.py b/seminar/management/commands/testdata.py index aaa59462..9f38ab57 100644 --- a/seminar/management/commands/testdata.py +++ b/seminar/management/commands/testdata.py @@ -17,7 +17,7 @@ User = django.contrib.auth.get_user_model() class Command(BaseCommand): help = "Clear database and load testing data." - def handle_noargs(self, **options): + def handle(self, *args, **options): assert settings.DEBUG == True dbfile = settings.DATABASES['default']['NAME'] if os.path.exists(dbfile): From ba5ceb14ba4a945aa39c5d9e56c9526c58e151ae Mon Sep 17 00:00:00 2001 From: LEdoian Date: Mon, 17 Sep 2018 22:18:27 +0200 Subject: [PATCH 3/6] =?UTF-8?q?Makefile:=20mo=C5=BEnost=20deploy=5Ftest=20?= =?UTF-8?q?deploynout=20i=20jinou=20branch.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 51bbdfad..7abd5a36 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ PYTHON=python2.7 VE_VER=16.0.0 LOCAL_PYTHON=bin/python +TEST_BRANCH?=test all: install @@ -66,7 +67,7 @@ deploy_test: @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi @if [ `pwd` != "/akce/mam/www/mamweb-test" ]; then echo "Only possible in /akce/mam/www/mamweb-test"; exit 1; fi @echo "Installing version from origin/test ..." - git pull origin test + git pull origin $(TEST_BRANCH) git clean -f make install ./manage.py migrate From 2e9ff73eacb3e6c6905f72aa04849df831c13596 Mon Sep 17 00:00:00 2001 From: LEdoian Date: Tue, 18 Sep 2018 02:07:01 +0200 Subject: [PATCH 4/6] =?UTF-8?q?Korektury:=20rozd=C4=9Blen=C3=AD=20aktu?= =?UTF-8?q?=C3=A1ln=C3=ADch=20a=20star=C3=BDch=20na=20dv=C4=9B=20str=C3=A1?= =?UTF-8?q?nky?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/templates/korektury/base.html | 4 ++++ korektury/templates/korektury/help.html | 7 +++++++ korektury/templates/korektury/seznam.html | 12 ++++++++++++ korektury/templates/korektury/submenu.html | 13 +++++++++++++ korektury/urls.py | 3 ++- korektury/views.py | 13 +++++++++++++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 korektury/templates/korektury/submenu.html diff --git a/korektury/templates/korektury/base.html b/korektury/templates/korektury/base.html index b31d5d47..886a15e1 100644 --- a/korektury/templates/korektury/base.html +++ b/korektury/templates/korektury/base.html @@ -1,5 +1,9 @@ {% extends "base.html" %} +{% block submenu %} + {% include "korektury/submenu.html" %} +{% endblock %} + {% block content %} {# blok do kterého se nacita text, v pripade jinyhc templatu obalit vlastnim blokem #} {% endblock %} diff --git a/korektury/templates/korektury/help.html b/korektury/templates/korektury/help.html index 0024848e..f2ddafb9 100644 --- a/korektury/templates/korektury/help.html +++ b/korektury/templates/korektury/help.html @@ -1,4 +1,11 @@ {% extends "korektury/base.html" %} + +{% block submenu %} + {% with "help" as selected %} + {% include "korektury/submenu.html" %} + {% endwith %} +{% endblock %} + {% load staticfiles %} {% block title %} Nápověda ke korigovátku {% endblock title %} diff --git a/korektury/templates/korektury/seznam.html b/korektury/templates/korektury/seznam.html index 7531679b..6420ec7d 100644 --- a/korektury/templates/korektury/seznam.html +++ b/korektury/templates/korektury/seznam.html @@ -1,6 +1,18 @@ {% extends "korektury/base.html" %} {% load staticfiles %} +{% block submenu %} + {% if aktualni %} + {% with "aktualni" as selected %} + {% include "korektury/submenu.html" %} + {% endwith %} + {% else %} + {% with "zastarale" as selected %} + {% include "korektury/submenu.html" %} + {% endwith %} + {% endif %} +{% endblock %} + {% block script%} {% endblock %} diff --git a/korektury/templates/korektury/submenu.html b/korektury/templates/korektury/submenu.html new file mode 100644 index 00000000..0a5ed988 --- /dev/null +++ b/korektury/templates/korektury/submenu.html @@ -0,0 +1,13 @@ +{% with "/korektury" as cesta %} + + + +{% endwith %} + + diff --git a/korektury/urls.py b/korektury/urls.py index 2f131516..ecad4804 100644 --- a/korektury/urls.py +++ b/korektury/urls.py @@ -6,7 +6,8 @@ from . import views staff_member_required = user_passes_test(lambda u: u.is_staff) urlpatterns = [ - url(r'^korektury/$', staff_member_required(views.KorekturyListView.as_view()), name='korektury-list'), + url(r'^korektury/$', staff_member_required(views.KorekturyAktualniListView.as_view()), name='korektury-list'), + url(r'^korektury/zastarale/$', staff_member_required(views.KorekturyZastaraleListView.as_view()), name='korektury-list-zastarale'), url(r'^korektury/(?P\d+)/$', staff_member_required(views.KorekturyView.as_view()), name='korektury'), url(r'^korektury/help/', staff_member_required(views.KorekturyHelpView.as_view()), name='korektury-help'), ] diff --git a/korektury/views.py b/korektury/views.py index 1e5a9298..bc2acdd8 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -21,6 +21,19 @@ class KorekturyListView(generic.ListView): model = KorekturovanePDF template_name = 'korektury/seznam.html' +class KorekturyAktualniListView(KorekturyListView): + def __init__ (self): + self.queryset=self.get_queryset().exclude(status="zastarale") + + def get_context_data(self, **kwargs): + context = super(KorekturyAktualniListView,self).get_context_data(**kwargs) + context['aktualni'] = True + return context + +class KorekturyZastaraleListView(KorekturyListView): + def __init__ (self): + self.queryset=self.get_queryset().filter(status="zastarale") + ### Korektury class KorekturyView(generic.TemplateView): model = Oprava From 52d14c667aa59e9348387993994160de81fd6ab8 Mon Sep 17 00:00:00 2001 From: MaM Web user Date: Tue, 18 Sep 2018 02:20:55 +0200 Subject: [PATCH 5/6] =?UTF-8?q?Revert=20"Makefile:=20mo=C5=BEnost=20deploy?= =?UTF-8?q?=5Ftest=20deploynout=20i=20jinou=20branch."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tohle stejně nefungovalo. Asi je to dobrý nápad, ale git se chová jinak, než jsem si myslel. This reverts commit ba5ceb14ba4a945aa39c5d9e56c9526c58e151ae. --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7abd5a36..51bbdfad 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ PYTHON=python2.7 VE_VER=16.0.0 LOCAL_PYTHON=bin/python -TEST_BRANCH?=test all: install @@ -67,7 +66,7 @@ deploy_test: @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi @if [ `pwd` != "/akce/mam/www/mamweb-test" ]; then echo "Only possible in /akce/mam/www/mamweb-test"; exit 1; fi @echo "Installing version from origin/test ..." - git pull origin $(TEST_BRANCH) + git pull origin test git clean -f make install ./manage.py migrate From 8d22ab3c91b33eedaa930c66d8707714068262b8 Mon Sep 17 00:00:00 2001 From: LEdoian Date: Fri, 21 Sep 2018 00:25:54 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Hez=C4=8D=C3=AD=20verze?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/templates/korektury/seznam.html | 10 +--------- korektury/views.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/korektury/templates/korektury/seznam.html b/korektury/templates/korektury/seznam.html index 6420ec7d..2498fbce 100644 --- a/korektury/templates/korektury/seznam.html +++ b/korektury/templates/korektury/seznam.html @@ -2,15 +2,7 @@ {% load staticfiles %} {% block submenu %} - {% if aktualni %} - {% with "aktualni" as selected %} - {% include "korektury/submenu.html" %} - {% endwith %} - {% else %} - {% with "zastarale" as selected %} - {% include "korektury/submenu.html" %} - {% endwith %} - {% endif %} + {% include "korektury/submenu.html" %} {% endblock %} {% block script%} diff --git a/korektury/views.py b/korektury/views.py index bc2acdd8..56f198f2 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -22,17 +22,26 @@ class KorekturyListView(generic.ListView): template_name = 'korektury/seznam.html' class KorekturyAktualniListView(KorekturyListView): - def __init__ (self): - self.queryset=self.get_queryset().exclude(status="zastarale") + def get_queryset(self, *args, **kwargs): + queryset=super(KorekturyAktualniListView,self).get_queryset() + queryset=queryset.exclude(status="zastarale") + return queryset def get_context_data(self, **kwargs): context = super(KorekturyAktualniListView,self).get_context_data(**kwargs) - context['aktualni'] = True + context['selected'] = 'aktualni' return context class KorekturyZastaraleListView(KorekturyListView): - def __init__ (self): - self.queryset=self.get_queryset().filter(status="zastarale") + def get_queryset(self, *args, **kwargs): + queryset=super(KorekturyZastaraleListView,self).get_queryset() + queryset=queryset.filter(status="zastarale") + return queryset + + def get_context_data(self, **kwargs): + context = super(KorekturyZastaraleListView,self).get_context_data(**kwargs) + context['selected'] = 'zastarale' + return context ### Korektury class KorekturyView(generic.TemplateView):