From 9a572457844d244562831192a2ba1047e15d01b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Mon, 25 Jul 2016 20:57:35 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Makefile:=20synchronizace=20testu=20s=20pro?= =?UTF-8?q?dukc=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a397f44b..e755aa55 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean_env init_env clean_virtualenv install_packages clean install run all schema_seminar.pdf schema_all.pdf +.PHONY: clean_env init_env clean_virtualenv install_packages clean install run all schema_seminar.pdf schema_all.pdf sync_test_media sync_test_db sync_test sync_local_media sync_local_db sync_local PYTHON=python2.7 VE_VER=13.1.2 LOCAL_PYTHON=bin/python @@ -93,16 +93,36 @@ deploy_prod: touch mamweb/wsgi.py @echo Done. + +# Sync test media directory with production +sync_test_media: + @if [ ${USER} != "www-mam" ]; then echo "Only possible by user www-mam"; exit 1; fi + @if [ `pwd` != "/akce/MaM/WWW/mamweb-test" ]; then echo "Only possible in /akce/MaM/WWW/mamweb-test"; exit 1; fi + rsync -av /akce/MaM/WWW/mamweb-prod/media/ ./media + +# Sync test database with production database +sync_test_db: + @if [ ${USER} != "www-mam" ]; then echo "Only possible by user www-mam"; exit 1; fi + pg_dump mam-test -U mam > dump-test-`date +"%Y%m%d_%H%M"`.sql + pg_dump -Fc mam-prod -U mam > dump-prod.sql + pg_restore -c -d mam-test -U mam dump-prod.sql + rm dump-prod.sql + @echo Done. + +# Sync test with production +sync_test: sync_test_media sync_test_db + + # Sync media directory with atrey. Useful for local development with production database # Does not sync Galerie and CACHE (too huge). -sync_media: +sync_local_media: rsync -ave ssh --exclude Galerie --exclude CACHE\ atrey.karlin.mff.cuni.cz:/akce/MaM/WWW/mamweb-prod/media/ ./media/ # Downloads and restores production database to local database. PostgreSQL only. -sync_db: +sync_local_db: scp atrey.karlin.mff.cuni.cz:`ssh atrey.karlin.mff.cuni.cz 'ls -v /akce/MaM/WWW/backups/mam-prod-*\.pgdump | tail -n 1'` \ ./last.pgdump pg_restore -c -d mam -U mam last.pgdump # Sync database and media. See above lines -sync: sync_media sync_db +sync_local: sync_media sync_db From 352189555dbe6b6efc8e172fcdf81832d9901aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Sat, 6 Aug 2016 17:03:21 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Admin:=20odstran=C4=9Bny=20nefunk=C4=8Dn?= =?UTF-8?q?=C3=AD=20odkazy=20na=20web?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/admin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/seminar/admin.py b/seminar/admin.py index 8d6e758a..27e825cf 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -77,6 +77,7 @@ class ResitelInline(admin.TabularInline): fields = ['jmeno', 'prijmeni', 'skola', 'mesto', 'rok_maturity', ] readonly_fields = ['jmeno', 'prijmeni', 'skola', 'mesto', 'rok_maturity', ] extra = 0 + view_on_site = False def has_add_permission(self, req): return False @@ -89,6 +90,7 @@ class CisloInline(admin.TabularInline): formfield_overrides = { models.TextField: {'widget': forms.TextInput}, } + view_on_site = Cislo.verejne_url def has_add_permission(self, req): return False @@ -100,9 +102,11 @@ class PrilohaReseniInline(admin.StackedInline): formfield_overrides = { models.TextField: {'widget': forms.TextInput}, } + view_on_site = False extra = 0 + class ReseniKProblemuInline(admin.TabularInline): form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['resitel'], fields=['resitel']) model = Reseni @@ -112,6 +116,7 @@ class ReseniKProblemuInline(admin.TabularInline): formfield_overrides = { models.TextField: {'widget': forms.TextInput}, } + view_on_site = False def get_queryset(self, request): qs = super(ReseniKProblemuInline, self).get_queryset(request) @@ -134,6 +139,7 @@ class ReseniKResiteliInline(admin.TabularInline): formfield_overrides = { models.TextField: {'widget': forms.TextInput}, } + view_on_site = False def has_add_permission(self, req): return False @@ -191,6 +197,7 @@ class ResitelAdmin(VersionAdmin): list_filter = ['pohlavi_muz', 'rok_maturity', 'zasilat'] search_fields = ['jmeno', 'prijmeni', 'ulice', 'mesto', 'email'] inlines = [ReseniKResiteliInline] + view_on_site = False def get_queryset(self, request): qs = super(ResitelAdmin, self).get_queryset(request) @@ -216,6 +223,7 @@ class SkolaAdmin(VersionAdmin): list_filter = ['stat', 'je_zs', 'je_ss'] search_fields = ['nazev', 'mesto', 'ulice'] inlines = [ResitelInline] + view_on_site = False admin.site.register(Skola, SkolaAdmin) @@ -288,6 +296,7 @@ class ReseniAdmin(VersionAdmin): list_filter = ['body', 'timestamp', 'forma'] search_fields = [] inlines = [PrilohaReseniInline] + view_on_site = False def get_queryset(self, request): qs = super(ReseniAdmin, self).get_queryset(request) @@ -307,6 +316,7 @@ class PohadkaAdminForm(forms.ModelForm): class PohadkaAdmin(VersionAdmin): form = PohadkaAdminForm + view_on_site = False def get_kod_ulohy(self, obj): return obj.uloha.kod_v_rocniku() From d67f58b9ef8b5567a9b272046c769ec68029d3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Sat, 6 Aug 2016 17:06:12 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Admin:=20zadan=C3=A9=20probl=C3=A9my=20k=20?= =?UTF-8?q?=C4=8D=C3=ADslu=20inline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/admin.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/seminar/admin.py b/seminar/admin.py index 27e825cf..45cc5fb7 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -107,6 +107,18 @@ class PrilohaReseniInline(admin.StackedInline): extra = 0 +class ProblemInline(admin.TabularInline): + model = Problem + fk_name = 'cislo_zadani' + fields = ['kod', 'typ', 'nazev', 'body', 'opravovatel', 'stav'] + formfield_overrides = { + models.TextField: {'widget': forms.TextInput}, + } + view_on_site = Problem.verejne_url + + extra = 0 + + class ReseniKProblemuInline(admin.TabularInline): form = autocomplete_light.modelform_factory(Reseni, autocomplete_fields=['resitel'], fields=['resitel']) model = Reseni @@ -244,6 +256,7 @@ class CisloAdmin(VersionAdmin): make_set_action('verejna_vysledkovka', True, u'Zveřejnit výsledkovku'), make_set_action('verejna_vysledkovka', False, u'Skrýt (zneveřejnit) výsledkovku'), ] + inlines = [ProblemInline] def get_queryset(self, request): qs = super(CisloAdmin, self).get_queryset(request)