From 1b2f1dbc3465133ae88d7b381b8e12b5c0ff9cea Mon Sep 17 00:00:00 2001 From: MaM Web user Date: Tue, 20 Oct 2020 22:39:42 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Makefile:=20P=C5=99id=C3=A1na=20agresivn?= =?UTF-8?q?=C3=AD=20varianta=20pro=20sync=5Ftest=5Fdb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vyrobil Pavel --- Makefile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a9d2e082..3b97c63a 100644 --- a/Makefile +++ b/Makefile @@ -117,12 +117,24 @@ sync_test_db: @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi pg_dump mam_test > dump-test-`date +"%Y%m%d_%H%M"`.sql pg_dump -Fc mam_prod > dump-prod.sql - pg_restore -c -d mam_test dump-prod.sql + pg_restore -c --if-exists -d mam_test dump-prod.sql + rm dump-prod.sql + @echo Done. + +# Aggresive variant: destroy original mam_test db with 'DROP OWNED BY "mam-web";' +sync_test_db_aggressive: + @if [ ${USER} != "mam-web" ]; then echo "Only possible by user mam-web"; exit 1; fi + pg_dump mam_test > dump-test-`date +"%Y%m%d_%H%M"`.sql + pg_dump -Fc mam_prod > dump-prod.sql + @# I am not sure which shell is used, so I am calling bash to make sure + bash -c "psql mam_test <<< 'DROP OWNED BY \"mam-web\";'" + pg_restore -c --if-exists -d mam_test dump-prod.sql rm dump-prod.sql @echo Done. # Sync test with production -sync_test: sync_test_media sync_test_db +# HACK ALERT: using aggressive variant, due to the schemas being too different. +sync_test: sync_test_media sync_test_db_aggressive # Sync media directory with atrey. Useful for local development with production database From 42e179d979e9a2d6274de2c566d77c90ad501e6b Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Thu, 26 Nov 2020 00:36:17 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Migrace:=20null=3DTrue=20u=20=C4=8D=C3=ADsl?= =?UTF-8?q?a=20pro=20body?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/migrations/0001_squashed_0067_auto_20190814_0805.py | 4 ++-- seminar/migrations/0049_auto_20190430_2354.py | 2 +- seminar/migrations/0064_auto_20190610_2358.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py index f9a8b5eb..f819f047 100644 --- a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py +++ b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py @@ -1518,7 +1518,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(primary_key=True, serialize=False)), ('body', models.DecimalField(decimal_places=1, max_digits=8, verbose_name='body')), - ('cislo_body', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body')), + ('cislo_body', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body', null=True)), ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Problem', verbose_name='problém')), ('reseni', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Reseni', verbose_name='řešení')), ], @@ -2025,7 +2025,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='hodnoceni', name='cislo_body', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body'), + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body', null=True), ), migrations.AlterField( model_name='hodnoceni', diff --git a/seminar/migrations/0049_auto_20190430_2354.py b/seminar/migrations/0049_auto_20190430_2354.py index de2b1b0d..985b3531 100644 --- a/seminar/migrations/0049_auto_20190430_2354.py +++ b/seminar/migrations/0049_auto_20190430_2354.py @@ -453,7 +453,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='hodnoceni', name='cislo_body', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body'), + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body', null=True), ), migrations.AddField( model_name='hodnoceni', diff --git a/seminar/migrations/0064_auto_20190610_2358.py b/seminar/migrations/0064_auto_20190610_2358.py index 344b132c..b72a08a0 100644 --- a/seminar/migrations/0064_auto_20190610_2358.py +++ b/seminar/migrations/0064_auto_20190610_2358.py @@ -27,7 +27,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='hodnoceni', name='cislo_body', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body'), + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body', null=True), ), migrations.AlterField( model_name='hodnoceni', From d850354d7acb6a44efd6e994c323008f816638b3 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 3 Mar 2021 01:05:54 +0100 Subject: [PATCH 3/4] Fix --- seminar/views/odevzdavatko.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index d1cedb1b..14305b10 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -57,10 +57,10 @@ class TabulkaOdevzdanychReseniView(ListView): reseni_od = fcd["reseni_od"] reseni_do = fcd["reseni_do"] else: - resitele = FiltrForm.get_initial_for_field(FormFiltr.resitele, "resitele") - problemy = FiltrForm.get_initial_for_field(FormFiltr.problemy, "problemy") - resitele_od = FiltrForm.get_initial_for_field(FormFiltr.resitele_od, "resitele_od") - resitele_do = FiltrForm.get_initial_for_field(FormFiltr.resitele_do, "resitele_do") + resitele = FiltrForm.get_initial_for_field(FiltrForm.resitele, "resitele") + problemy = FiltrForm.get_initial_for_field(FiltrForm.problemy, "problemy") + resitele_od = FiltrForm.get_initial_for_field(FiltrForm.resitele_od, "resitele_od") + resitele_do = FiltrForm.get_initial_for_field(FiltrForm.resitele_do, "resitele_do") # Filtrujeme! From 6b36d50c50c519f98050a7c80364ebb11c426135 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 3 Mar 2021 01:06:24 +0100 Subject: [PATCH 4/4] Fix --- seminar/views/odevzdavatko.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index d1cedb1b..14305b10 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -57,10 +57,10 @@ class TabulkaOdevzdanychReseniView(ListView): reseni_od = fcd["reseni_od"] reseni_do = fcd["reseni_do"] else: - resitele = FiltrForm.get_initial_for_field(FormFiltr.resitele, "resitele") - problemy = FiltrForm.get_initial_for_field(FormFiltr.problemy, "problemy") - resitele_od = FiltrForm.get_initial_for_field(FormFiltr.resitele_od, "resitele_od") - resitele_do = FiltrForm.get_initial_for_field(FormFiltr.resitele_do, "resitele_do") + resitele = FiltrForm.get_initial_for_field(FiltrForm.resitele, "resitele") + problemy = FiltrForm.get_initial_for_field(FiltrForm.problemy, "problemy") + resitele_od = FiltrForm.get_initial_for_field(FiltrForm.resitele_od, "resitele_od") + resitele_do = FiltrForm.get_initial_for_field(FiltrForm.resitele_do, "resitele_do") # Filtrujeme!