diff --git a/donate/templates/donate/donate_home_page.html b/donate/templates/donate/donate_home_page.html index dc86beb2545e4bd009ef088df600725575aa7e0d..22670c247b1cc928132718badd73c3a295a4fa5b 100644 --- a/donate/templates/donate/donate_home_page.html +++ b/donate/templates/donate/donate_home_page.html @@ -57,16 +57,16 @@ <legend class="col-form-label col-md-4 col-form-label-lg">Částka</legend> <div class="col-md-8"> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount1" name="amount" value="100" class="custom-control-input" checked required> - <label class="custom-control-label col-form-label-lg" for="amount1">100 Kč</label> + <input type="radio" id="amount1" name="amount" value="200" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount1">200 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount2" name="amount" value="200" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount2">200 Kč</label> + <input type="radio" id="amount2" name="amount" value="500" class="custom-control-input" checked required> + <label class="custom-control-label col-form-label-lg" for="amount2">500 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount3" name="amount" value="500" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount3">500 Kč</label> + <input type="radio" id="amount3" name="amount" value="1000" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount3">1000 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" id="amount4" name="amount" value="-1" class="custom-control-input"> diff --git a/donate/templates/donate/donate_info_page.html b/donate/templates/donate/donate_info_page.html index 94dbcee9b348f0fe3e0a7caeb6412b001996567d..4de8233f288605cd5ddca8a504282334ede76f7b 100644 --- a/donate/templates/donate/donate_info_page.html +++ b/donate/templates/donate/donate_info_page.html @@ -38,16 +38,16 @@ <legend class="col-form-label col-md-12 col-form-label-lg">Částka</legend> <div class="col-md-12"> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount1" name="amount" value="100" class="custom-control-input" checked> - <label class="custom-control-label col-form-label-lg" for="amount1">100 Kč</label> + <input type="radio" id="amount1" name="amount" value="200" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount1">200 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount2" name="amount" value="200" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount2">200 Kč</label> + <input type="radio" id="amount2" name="amount" value="500" class="custom-control-input" checked> + <label class="custom-control-label col-form-label-lg" for="amount2">500 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount3" name="amount" value="500" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount3">500 Kč</label> + <input type="radio" id="amount3" name="amount" value="1000" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount3">1000 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" id="amount4" name="amount" value="-1" class="custom-control-input"> diff --git a/donate/templates/donate/donate_region_page.html b/donate/templates/donate/donate_region_page.html index c4ec5d56821257247323fcb213dfd64a248b639d..a319e129b4e5c8ade7a71bf3d61b717e1ca3487a 100644 --- a/donate/templates/donate/donate_region_page.html +++ b/donate/templates/donate/donate_region_page.html @@ -44,16 +44,16 @@ <legend class="col-form-label col-md-12 col-form-label-lg">Částka</legend> <div class="col-md-12"> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount1" name="amount" value="100" class="custom-control-input" checked> - <label class="custom-control-label col-form-label-lg" for="amount1">100 Kč</label> + <input type="radio" id="amount1" name="amount" value="200" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount1">200 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount2" name="amount" value="200" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount2">200 Kč</label> + <input type="radio" id="amount2" name="amount" value="500" class="custom-control-input" checked> + <label class="custom-control-label col-form-label-lg" for="amount2">500 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount3" name="amount" value="500" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount3">500 Kč</label> + <input type="radio" id="amount3" name="amount" value="1000" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount3">1000 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" id="amount4" name="amount" value="-1" class="custom-control-input"> diff --git a/donate/templates/donate/donate_targeted_donations_page.html b/donate/templates/donate/donate_targeted_donations_page.html index a62237fab1177085291421538c3fbfcd4f1af36f..b68e3565a01bea0717e8d7dc265b11ba7e1dcc7d 100644 --- a/donate/templates/donate/donate_targeted_donations_page.html +++ b/donate/templates/donate/donate_targeted_donations_page.html @@ -53,16 +53,16 @@ <legend class="col-form-label col-md-3 col-form-label-lg">Částka</legend> <div class="col-md-9"> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount1" name="amount" value="100" class="custom-control-input" checked required> - <label class="custom-control-label col-form-label-lg" for="amount1">100 Kč</label> + <input type="radio" id="amount1" name="amount" value="200" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount1">200 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount2" name="amount" value="200" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount2">200 Kč</label> + <input type="radio" id="amount2" name="amount" value="500" class="custom-control-input" checked required> + <label class="custom-control-label col-form-label-lg" for="amount2">500 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> - <input type="radio" id="amount3" name="amount" value="500" class="custom-control-input"> - <label class="custom-control-label col-form-label-lg" for="amount3">500 Kč</label> + <input type="radio" id="amount3" name="amount" value="1000" class="custom-control-input"> + <label class="custom-control-label col-form-label-lg" for="amount3">1000 Kč</label> </div> <div class="custom-control custom-radio custom-control-inline"> <input type="radio" id="amount4" name="amount" value="-1" class="custom-control-input"> diff --git a/program2021/fixtures/characteristic.json b/program2021/fixtures/characteristic.json new file mode 100644 index 0000000000000000000000000000000000000000..34070730e94c130eff44d8a993e0827b8766a93c --- /dev/null +++ b/program2021/fixtures/characteristic.json @@ -0,0 +1,226 @@ +[ + { + "model": "program2021.SearchCharacteristic", + "pk": 1, + "fields": { + "name": "Žena", + "form_param": "female" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 2, + "fields": { + "name": "Muž", + "form_param": "male" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 3, + "fields": { + "name": "věk do 30", + "form_param": "age30" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 4, + "fields": { + "name": "věk 30-49", + "form_param": "age50" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 5, + "fields": { + "name": "věk 50-64", + "form_param": "age65" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 6, + "fields": { + "name": "věk 65+", + "form_param": "age99" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 7, + "fields": { + "name": "mám děti", + "form_param": "kids" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 8, + "fields": { + "name": "bezdětný/á", + "form_param": "nokids" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 9, + "fields": { + "name": "Student", + "form_param": "student" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 10, + "fields": { + "name": "zaměstnanec*kyně ve veřejné sféře", + "form_param": "employee-public" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 11, + "fields": { + "name": "zaměstnanec*kyně v soukromé sféře", + "form_param": "employee-private" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 12, + "fields": { + "name": "podnikatel*ka", + "form_param": "entrepreneur" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 13, + "fields": { + "name": "na mateřské / rodičovské", + "form_param": "maternity" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 14, + "fields": { + "name": "v důchodu", + "form_param": "retired" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 15, + "fields": { + "name": "Životní údeoveň velmi dobrá", + "form_param": "wealth-great" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 16, + "fields": { + "name": "Životní úroveň dobrá", + "form_param": "wealth-good" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 17, + "fields": { + "name": "Životní úroveň průmerná", + "form_param": "wealth-average" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 18, + "fields": { + "name": "Životní úroveň špatná", + "form_param": "wealth-bad" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 19, + "fields": { + "name": "Cestuji na kole", + "form_param": "travel-bike" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 20, + "fields": { + "name": "Cestuji autem", + "form_param": "travel-car" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 21, + "fields": { + "name": "Cestuji veřejnou dopravou", + "form_param": "travel-public" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 22, + "fields": { + "name": "Žiji ve velkém městě", + "form_param": "metropolis" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 23, + "fields": { + "name": "Žiji ve středním městě", + "form_param": "town" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 24, + "fields": { + "name": "Žiji v malém městě / na vesnici", + "form_param": "village" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 25, + "fields": { + "name": "Základní škola", + "form_param": "zs" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 26, + "fields": { + "name": "Střední škola bez maturity", + "form_param": "ss" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 27, + "fields": { + "name": "SŠ s maturitou", + "form_param": "maturita" + } + }, + { + "model": "program2021.SearchCharacteristic", + "pk": 28, + "fields": { + "name": "Vysoká škola", + "form_param": "vs" + } + } +] diff --git a/program2021/migrations/0003_auto_20200805_1034.py b/program2021/migrations/0003_auto_20200805_1034.py new file mode 100644 index 0000000000000000000000000000000000000000..396d02db3cb8fc25cd54ff16925404176a99c7d1 --- /dev/null +++ b/program2021/migrations/0003_auto_20200805_1034.py @@ -0,0 +1,59 @@ +# Generated by Django 3.0.8 on 2020-08-05 08:34 + +import django.db.models.deletion +import modelcluster.contrib.taggit +import modelcluster.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("taggit", "0003_taggeditem_add_unique_index"), + ("program2021", "0002_auto_20200805_0726"), + ] + + operations = [ + migrations.CreateModel( + name="Program2021PointPageSearchTag", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "content_object", + modelcluster.fields.ParentalKey( + on_delete=django.db.models.deletion.CASCADE, + to="program2021.Program2021PointPage", + ), + ), + ( + "tag", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="program2021_program2021pointpagesearchtag_items", + to="taggit.Tag", + ), + ), + ], + options={"abstract": False,}, + ), + migrations.AddField( + model_name="program2021pointpage", + name="search_tags", + field=modelcluster.contrib.taggit.ClusterTaggableManager( + blank=True, + help_text='Tagy pro vyhledavani. Musi byt zadany presne, aby to fungovalo. Tagy jsou deleny do skupin se spolecnym prefixem, napr. "gender". \nPriklad: chces-li programovy bod pouze pro muze, zadej tag "gender-male", pokud je to jedno, musis zadat tag "gender-every". Seznam tagu a skupin:\nx y z\nb d f\nl o p q\n ', + related_name="search_tags", + through="program2021.Program2021PointPageSearchTag", + to="taggit.Tag", + verbose_name="Tags", + ), + ), + ] diff --git a/program2021/migrations/0004_auto_20200930_1156.py b/program2021/migrations/0004_auto_20200930_1156.py new file mode 100644 index 0000000000000000000000000000000000000000..7c8bb8c2afb16cd01df91ca48adc9376612f779a --- /dev/null +++ b/program2021/migrations/0004_auto_20200930_1156.py @@ -0,0 +1,41 @@ +# Generated by Django 3.1.1 on 2020-09-30 09:56 + +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("program2021", "0003_program2021pointpage_image_title"), + ] + + operations = [ + migrations.AlterField( + model_name="program2021pointpage", + name="images", + field=wagtail.core.fields.StreamField( + [ + ( + "item", + wagtail.core.blocks.StructBlock( + [ + ( + "image", + wagtail.images.blocks.ImageChooserBlock( + label="ilustrační obrázek" + ), + ), + ("title", wagtail.core.blocks.CharBlock(label="popis")), + ], + label="obrázek", + ), + ) + ], + blank=True, + verbose_name="ilustrační obrázky", + ), + ), + ] diff --git a/program2021/migrations/0004_merge_20200812_1337.py b/program2021/migrations/0004_merge_20200812_1337.py new file mode 100644 index 0000000000000000000000000000000000000000..8fed978fb3c1ca2d58e84434b574fc1e610828ca --- /dev/null +++ b/program2021/migrations/0004_merge_20200812_1337.py @@ -0,0 +1,13 @@ +# Generated by Django 3.0.8 on 2020-08-12 11:37 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("program2021", "0003_auto_20200805_1034"), + ("program2021", "0003_program2021pointpage_image_title"), + ] + + operations = [] diff --git a/program2021/migrations/0005_auto_20200812_1337.py b/program2021/migrations/0005_auto_20200812_1337.py new file mode 100644 index 0000000000000000000000000000000000000000..d2391ed2e85e2a3c5be85f55f243b932d122adab --- /dev/null +++ b/program2021/migrations/0005_auto_20200812_1337.py @@ -0,0 +1,78 @@ +# Generated by Django 3.0.8 on 2020-08-12 11:37 + +import django.db.models.deletion +import modelcluster.contrib.taggit +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("taggit", "0003_taggeditem_add_unique_index"), + ("program2021", "0004_merge_20200812_1337"), + ] + + operations = [ + migrations.CreateModel( + name="SearchCharacteristic", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "name", + models.CharField( + max_length=200, + verbose_name="lidský název pro použití v administraci", + ), + ), + ], + ), + migrations.AlterField( + model_name="program2021pointpage", + name="search_tags", + field=modelcluster.contrib.taggit.ClusterTaggableManager( + blank=True, + help_text='Deleny do skupin se spolecnym prefixem, napr. "gender". Pokud je bod spolecny pro vsechny moznosti dane skupiny, pouzij tag se suffixem "-every". \nPriklad: chces-li programovy bod pouze pro muze, zadej tag "gender-male", pokud je to jedno, musis zadat tag "gender-every". \nPro kazdou skupinu musis zadat aspon jeden tag, jinak se bod nedostane nikdy do vysledku vyhledavani. Seznam tagu po skupinach:\n(gender-male gender-female gender-every) \n(age-30 age-50 age-65 age-99 age-every) \n(kids-yes kids-no kids-every)\n(occupation-student occupation-employee-public occupation-employee-private occupation-entrepreneur occupation-maternity occupation-retired occupation-every)\n(wealth-excelent wealth-good wealth-average wealth-bad wealth-every)\n(travel-bike travel-car travel-public travel-every)\n(housing-metropolis housing-town housing-village housing-every) \n(education-zs education-ss education-maturita education-vs education-every)\n ', + related_name="search_tags", + through="program2021.Program2021PointPageSearchTag", + to="taggit.Tag", + verbose_name="Tagy pro vyhledávání", + ), + ), + migrations.CreateModel( + name="CharacteristicWeight", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("weight", models.IntegerField()), + ( + "program_point", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="program2021.Program2021PointPage", + ), + ), + ( + "search_characteristic", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="program2021.SearchCharacteristic", + ), + ), + ], + ), + ] diff --git a/program2021/migrations/0006_auto_20200812_1556.py b/program2021/migrations/0006_auto_20200812_1556.py new file mode 100644 index 0000000000000000000000000000000000000000..2741e763dba243170702f95f1eec30c2086077aa --- /dev/null +++ b/program2021/migrations/0006_auto_20200812_1556.py @@ -0,0 +1,38 @@ +# Generated by Django 3.0.8 on 2020-08-12 13:56 + +import django.db.models.deletion +import modelcluster.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("program2021", "0005_auto_20200812_1337"), + ] + + operations = [ + migrations.AlterField( + model_name="characteristicweight", + name="program_point", + field=modelcluster.fields.ParentalKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="program_point_link", + to="program2021.Program2021PointPage", + ), + ), + migrations.AlterField( + model_name="characteristicweight", + name="search_characteristic", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="program2021.SearchCharacteristic", + verbose_name="Charakteristika", + ), + ), + migrations.AlterField( + model_name="characteristicweight", + name="weight", + field=models.IntegerField(verbose_name="Váha"), + ), + ] diff --git a/program2021/migrations/0007_auto_20200812_1951.py b/program2021/migrations/0007_auto_20200812_1951.py new file mode 100644 index 0000000000000000000000000000000000000000..959a81069af16a92b394d7276ba0425f22187e87 --- /dev/null +++ b/program2021/migrations/0007_auto_20200812_1951.py @@ -0,0 +1,52 @@ +# Generated by Django 3.0.8 on 2020-08-12 17:51 + +import django.db.models.deletion +import modelcluster.contrib.taggit +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("taggit", "0003_taggeditem_add_unique_index"), + ("program2021", "0006_auto_20200812_1556"), + ] + + operations = [ + migrations.AddField( + model_name="searchcharacteristic", + name="form_param", + field=models.CharField( + blank=True, + max_length=20, + null=True, + verbose_name="ID parametru ve formuláři", + ), + ), + migrations.AlterField( + model_name="characteristicweight", + name="search_characteristic", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="program2021.SearchCharacteristic", + verbose_name="Zadáno", + ), + ), + migrations.AlterField( + model_name="program2021pointpage", + name="search_tags", + field=modelcluster.contrib.taggit.ClusterTaggableManager( + blank=True, + help_text='Deleny do skupin se spolecnym prefixem, napr. "gender". Pokud je bod spolecny pro vsechny moznosti dane skupiny, pouzij tag se suffixem "-every".\nPriklad: chces-li programovy bod pouze pro muze, zadej tag "gender-male", pokud je to jedno, musis zadat tag "gender-every".\nPro kazdou skupinu musis zadat aspon jeden tag, jinak se bod nedostane nikdy do vysledku vyhledavani. Seznam tagu po skupinach:\n(gender-male gender-female gender-every)\n(age-30 age-50 age-65 age-99 age-every)\n(kids-yes kids-no kids-every)\n(occupation-student occupation-employee-public occupation-employee-private occupation-entrepreneur occupation-maternity occupation-retired occupation-every)\n(wealth-excelent wealth-good wealth-average wealth-bad wealth-every)\n(travel-bike travel-car travel-public travel-every)\n(housing-metropolis housing-town housing-village housing-every)\n(education-zs education-ss education-maturita education-vs education-every)\n ', + related_name="search_tags", + through="program2021.Program2021PointPageSearchTag", + to="taggit.Tag", + verbose_name="Tagy pro vyhledávání", + ), + ), + migrations.AlterField( + model_name="searchcharacteristic", + name="name", + field=models.CharField(max_length=200, verbose_name="Název"), + ), + ] diff --git a/program2021/migrations/0008_auto_20200812_2117.py b/program2021/migrations/0008_auto_20200812_2117.py new file mode 100644 index 0000000000000000000000000000000000000000..ebbb30e09deece80e6b7c0f321c8a119fbd3de37 --- /dev/null +++ b/program2021/migrations/0008_auto_20200812_2117.py @@ -0,0 +1,15 @@ +# Generated by Django 3.0.8 on 2020-08-12 19:17 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("program2021", "0007_auto_20200812_1951"), + ] + + operations = [ + migrations.RemoveField(model_name="program2021pointpage", name="search_tags",), + migrations.DeleteModel(name="Program2021PointPageSearchTag",), + ] diff --git a/program2021/migrations/0009_merge_20201026_2345.py b/program2021/migrations/0009_merge_20201026_2345.py new file mode 100644 index 0000000000000000000000000000000000000000..721bf891805aada16a9dca34164a9d5e90a55a39 --- /dev/null +++ b/program2021/migrations/0009_merge_20201026_2345.py @@ -0,0 +1,13 @@ +# Generated by Django 3.1.2 on 2020-10-26 22:45 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("program2021", "0008_auto_20200812_2117"), + ("program2021", "0004_auto_20200930_1156"), + ] + + operations = [] diff --git a/program2021/models.py b/program2021/models.py index 9d10e0812cf25614d27e82aeab90d9afc12e978a..d0f7eb244108b23e1b8b9cd4e70afa9080383c0e 100644 --- a/program2021/models.py +++ b/program2021/models.py @@ -6,6 +6,7 @@ from taggit.models import TaggedItemBase from wagtail.admin.edit_handlers import ( FieldPanel, HelpPanel, + InlinePanel, MultiFieldPanel, ObjectList, StreamFieldPanel, @@ -19,6 +20,39 @@ from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmetadata.models import MetadataPageMixin +class SearchCharacteristic(models.Model): + """ Ciselnik charakteristik odesilanych uzivatelem, napriklad vek65+ """ + + name = models.CharField("Název", max_length=200, blank=False, null=False) + + # mapování chareakteristiky na přislusnou POST promennou odeslanou HTML formularem + form_param = models.CharField( + "ID parametru ve formuláři", max_length=20, blank=True, null=True + ) + + def __str__(self): + return self.name + + +class CharacteristicWeight(models.Model): + """ Prirazeni vahy jedntlivych charakteristik programovym blokum """ + + search_characteristic = models.ForeignKey( + SearchCharacteristic, on_delete=models.CASCADE, verbose_name="Zadáno" + ) + program_point = ParentalKey( + "Program2021PointPage", + on_delete=models.CASCADE, + related_name="program_point_link", + ) + weight = models.IntegerField(verbose_name="Váha") + + panels = [ + FieldPanel("search_characteristic"), + FieldPanel("weight"), + ] + + class Program2021HomePage(Page): ### FIELDS headline = models.CharField( @@ -54,7 +88,24 @@ class Program2021HomePage(Page): def get_context(self, request): context = super().get_context(request) - context["points"] = self.get_children().live().specific() + + if request.method == "POST": + + sent_tags = [request.POST.get(x, None) for x in request.POST.keys()] + sent_tags = [x for x in sent_tags if x] + + # dopocitej vahu podle predanych parametru z vyhledavani... + context["points"] = self.get_children().live().specific() + for point in context["points"]: + point.weight = point.get_weight(sent_tags) + + # ...a setrid dle ni vysledky. HACK: pomale, ale pocitame max. v desitkach zaznamu, tedy acceptable + context["points"] = sorted(context["points"], key=lambda x: -x.weight) + + else: + # neformular - vrat vsechny body + context["points"] = self.get_children().live().specific() + return context @@ -186,7 +237,18 @@ class Program2021PointPage(Page, MetadataPageMixin): blank=True, ) images = StreamField( - [("image", ImageChooserBlock(label="ilustrační obrázek"))], + [ + ( + "item", + blocks.StructBlock( + [ + ("image", ImageChooserBlock(label="ilustrační obrázek")), + ("title", blocks.CharBlock(label="popis")), + ], + label="obrázek", + ), + ), + ], verbose_name="ilustrační obrázky", blank=True, ) @@ -239,6 +301,8 @@ class Program2021PointPage(Page, MetadataPageMixin): StreamFieldPanel("faq"), ] + search_panels = [InlinePanel("program_point_link", label="Váhy vyhledávání")] + promote_panels = [ MultiFieldPanel( [ @@ -255,6 +319,7 @@ class Program2021PointPage(Page, MetadataPageMixin): [ ObjectList(content_panels, heading=gettext_lazy("Content")), ObjectList(benefits_content_panels, heading="Benefity"), + ObjectList(search_panels, heading="Hledání"), ObjectList(faq_content_panels, heading="FAQ"), ObjectList(promote_panels, heading=gettext_lazy("Promote")), ] @@ -269,3 +334,14 @@ class Program2021PointPage(Page, MetadataPageMixin): class Meta: verbose_name = "Programový bod" + + def get_weight(self, param_ids): + """ Vraci celkovou vahu tagu, predanych v seznamu param_ids """ + # Kvuli prehlednosti nepisu jako oneliner :) + my_weights = self.program_point_link.all() + involved_weights = [ + x.weight + for x in my_weights + if x.search_characteristic.form_param in param_ids + ] + return sum(involved_weights) diff --git a/program2021/templates/program2021/base.html b/program2021/templates/program2021/base.html index 3bad8dad11e73384609c20037a3f8d11537c033e..7bca669c699cd0de2918bdf8706bf01429de4807 100644 --- a/program2021/templates/program2021/base.html +++ b/program2021/templates/program2021/base.html @@ -1,4 +1,4 @@ -{% load static wagtailcore_tags wagtailmetadata_tags %} +{% load static wagtailcore_tags wagtailimages_tags wagtailmetadata_tags %} <!doctype html> <html lang="en"> <head> diff --git a/program2021/templates/program2021/program2021_home_page.html b/program2021/templates/program2021/program2021_home_page.html index 2fcfe53c3d04bf4489300972b3873b6488a826ea..a889c69ead00a5efc1c2d9fec7d9fffac390474f 100644 --- a/program2021/templates/program2021/program2021_home_page.html +++ b/program2021/templates/program2021/program2021_home_page.html @@ -5,21 +5,22 @@ <section class="jumbotron text-center"> <div class="container"> <h1>{{ page.headline }}</h1> - <p class="lead text-muted">{{ page.perex }}</p> + <p class="lead mt-3"><big>{{ page.perex }}</big></p> - <form class="text-left mt-5"> + <form class="text-left mt-5" action="{% pageurl page %}" method="POST"> + {% csrf_token %} <div class="row my-3"> <div class="col-2 text-right">pohlaví:</div> <div class="col-4 btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-outline-secondary"> - <input type="radio" name="gender" id="gender1" autocomplete="off"> žena + <input type="radio" name="gender" id="gender1" value="female" autocomplete="off"> žena </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="gender" id="gender2" autocomplete="off"> muž + <input type="radio" name="gender" id="gender2" value="male" autocomplete="off"> muž </label> <label class="btn btn-outline-secondary active"> - <input type="radio" name="gender" id="gender3" autocomplete="off" checked> jiné / nechci uvést + <input type="radio" name="gender" id="gender3" value="" autocomplete="off"> jiné / nechci uvést </label> </div> </div> @@ -28,19 +29,19 @@ <div class="col-2 text-right">věk:</div> <div class="col-6 btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-outline-secondary active"> - <input type="radio" name="age" id="age1" autocomplete="off"> do 30 let + <input type="radio" name="age" id="age1" value="age30" autocomplete="off"> do 30 let </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="age" id="age2" autocomplete="off"> 30 - 49 let + <input type="radio" name="age" id="age2" value="age50" autocomplete="off"> 30 - 49 let </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="age" id="age3" autocomplete="off"> 50 - 64 let + <input type="radio" name="age" id="age3" value="age65" autocomplete="off"> 50 - 64 let </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="age" id="age4" autocomplete="off"> 65+ let + <input type="radio" name="age" id="age4" value="age99" autocomplete="off"> 65+ let </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="age" id="age5" autocomplete="off" checked> nechci uvést + <input type="radio" name="age" id="age5" value="" autocomplete="off"> nechci uvést </label> </div> </div> @@ -49,13 +50,13 @@ <div class="col-2 text-right">mám děti:</div> <div class="col-3 btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-outline-secondary"> - <input type="radio" name="kids" id="kids1" autocomplete="off"> ano + <input type="radio" name="kids" id="kids1" value="kids" autocomplete="off"> ano </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="kids" id="kids2" autocomplete="off"> ne + <input type="radio" name="kids" id="kids2" value="nokids" autocomplete="off"> ne </label> <label class="btn btn-outline-secondary active"> - <input type="radio" name="kids" id="kids3" autocomplete="off" checked> nechci uvést + <input type="radio" name="kids" id="kids3" value="" autocomplete="off"> nechci uvést </label> </div> </div> @@ -65,14 +66,14 @@ <label for="occupation">jsem:</label> </div> <div class="col-4"> - <select class="form-control" id="occupation"> - <option>jiné / nechci uvést</option> - <option>student*ka</option> - <option>zaměstnanec*kyně ve veřejné sféře</option> - <option>zaměstnanec*kyně v soukromé sféře</option> - <option>podnikatel*ka</option> - <option>na mateřské / rodičovské</option> - <option>v důchodu</option> + <select class="form-control" id="occupation" name="occupation"> + <option value="">jiné / nechci uvést</option> + <option value="student">studující</option> + <option value="employee-public">zaměstnaný/á ve veřejné sféře</option> + <option value="employee-private">zaměstnaný/á v soukromé sféře</option> + <option value="entrepreneur">podnikající</option> + <option value="maternity">na mateřské / rodičovské</option> + <option value="retired">v důchodu</option> </select> </div> </div> @@ -82,12 +83,12 @@ <label for="wealth">životní úroveň:</label> </div> <div class="col-4"> - <select class="form-control" id="wealth"> - <option>jiné / nechci uvést</option> - <option>velmi dobrá</option> - <option>dobrá</option> - <option>ani dobrá, ani špatná</option> - <option>špatná</option> + <select class="form-control" id="wealth" name="wealth"> + <option value="">jiné / nechci uvést</option> + <option value="wealth-great">velmi dobrá</option> + <option value="wealth-good">dobrá</option> + <option value="wealth-average">ani dobrá, ani špatná</option> + <option value="wealth-bad">špatná</option> </select> </div> </div> @@ -98,15 +99,15 @@ </div> <div class="col-4"> <div class="custom-control custom-checkbox"> - <input type="checkbox" class="custom-control-input" id="travel1"> + <input type="checkbox" class="custom-control-input" id="travel1" value="travel-bike" name="travel-bike"> <label class="custom-control-label" for="travel1">na kole</label> </div> <div class="custom-control custom-checkbox"> - <input type="checkbox" class="custom-control-input" id="travel2"> + <input type="checkbox" class="custom-control-input" id="travel2" value="travel-car" name="travel-car"> <label class="custom-control-label" for="travel2">autem</label> </div> <div class="custom-control custom-checkbox"> - <input type="checkbox" class="custom-control-input" id="travel3"> + <input type="checkbox" class="custom-control-input" id="travel3" value="travel-public" name="travel-public"> <label class="custom-control-label" for="travel3">veřejnou dopravou</label> </div> </div> @@ -117,11 +118,11 @@ <label for="housing">bydlím:</label> </div> <div class="col-4"> - <select class="form-control" id="housing"> - <option>jiné / nechci uvést</option> - <option>ve velkém městě nebo jeho okolí</option> - <option>ve středně velkém městě (10 - 50 tis.)</option> - <option>v malém městě nebo na vesnici</option> + <select class="form-control" id="housing" name="housing"> + <option value="">jiné / nechci uvést</option> + <option value="metropolis">ve velkém městě nebo jeho okolí</option> + <option value="town">ve středně velkém městě (10 - 50 tis.)</option> + <option value="village">v malém městě nebo na vesnici</option> </select> </div> </div> @@ -130,23 +131,31 @@ <div class="col-2 text-right">vzdělání:</div> <div class="col-6 btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-outline-secondary"> - <input type="radio" name="education" id="education1" autocomplete="off"> ZŠ + <input type="radio" name="education" id="education1" value="zs" autocomplete="off"> ZŠ </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="education" id="education2" autocomplete="off"> SŠ bez maturity + <input type="radio" name="education" id="education2" value="ss" autocomplete="off"> SŠ bez maturity </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="education" id="education3" autocomplete="off"> SŠ s maturitou + <input type="radio" name="education" id="education3" value="maturita" autocomplete="off"> SŠ s maturitou </label> <label class="btn btn-outline-secondary"> - <input type="radio" name="education" id="education4" autocomplete="off"> VŠ + <input type="radio" name="education" id="education4" value="vs" autocomplete="off"> VŠ </label> <label class="btn btn-outline-secondary active"> - <input type="radio" name="education" id="education5" autocomplete="off" checked> nechci uvést + <input type="radio" name="education" id="education5" value="" autocomplete="off"> nechci uvést </label> </div> </div> + <div class="row form-group"> + <div class="col-2"> + </div> + <div class="col-4"> + <input type="submit" value="Vyhledat"> + </div> + </div> + </form> </div> diff --git a/program2021/templates/program2021/program2021_point_page.html b/program2021/templates/program2021/program2021_point_page.html index e73b31b791ca68d56592a74c70407dc4904b9ffa..ea50b14b9c8c4ae8006ea03f7f69271319151779 100644 --- a/program2021/templates/program2021/program2021_point_page.html +++ b/program2021/templates/program2021/program2021_point_page.html @@ -1,11 +1,12 @@ {% extends "program2021/base.html" %} -{% load wagtailimages_tags wagtailcore_tags %} +{% load static wagtailimages_tags wagtailcore_tags %} + {% block content %} <div class="container"> <div class="row"> - <div class="jumbotron mb-5"> + <div class="jumbotron mb-5 col-12"> <div class="row"> <div class="col-12 col-lg-4"> @@ -26,14 +27,18 @@ </p> </div> - <div class="col-md-6 pr-5"> - <h3>Problém</h3> - <p>{{ page.problem }}</p> + <div class="col-md-6 p-1"> + <div class="jumbotron h-100"> + <h3>Problém</h3> + <p>{{ page.problem }}</p> + </div> </div> - <div class="col-md-6 pl-5"> - <h3>Ideál</h3> - <p>{{ page.ideal }}</p> + <div class="col-md-6 p-1"> + <div class="jumbotron h-100"> + <h3>Ideál</h3> + <p>{{ page.ideal }}</p> + </div> </div> <div class="w-100 my-4"></div> @@ -88,7 +93,18 @@ <p>{{ page.sources|richtext }}</p> </div> - <div class="w-100 my-4"></div> + {% if page.images %} + <div class="row about-images mb-5 mt-3 jumbotron"> + {% for block in page.images %} + {% image block.value.image width-2000 as img %} + {% image block.value.image fill-300x200 as thumb %} + <div class="col-6 col-md-3 mb-4"> + <a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ block.value.title }}"></a><br> + {{ block.value.title }} + </div><!-- /column --> + {% endfor %} + </div><!-- /row --> + {% endif %} </div> </div> diff --git a/requirements/base.txt b/requirements/base.txt index a8d63b9075d76df3fdb643ef978a9c3d8e562ea3..1de72b6bc2d22eeeba451e5a1807f50633f25bd9 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -9,22 +9,22 @@ asgiref==3.2.10 # via django async-generator==1.10 # via nbclient attrs==20.2.0 # via jsonschema beautifulsoup4==4.8.2 # via wagtail -bleach==3.1.5 # via nbconvert +bleach==3.2.1 # via nbconvert certifi==2020.6.20 # via requests, sentry-sdk -cffi==1.14.2 # via cryptography +cffi==1.14.3 # via cryptography chardet==3.0.4 # via requests -cryptography==3.1 # via josepy, mozilla-django-oidc, pyopenssl +cryptography==3.1.1 # via josepy, mozilla-django-oidc, pyopenssl defusedxml==0.6.0 # via nbconvert django-environ==0.4.5 # via -r base.in -django-extensions==3.0.8 # via -r base.in -django-filter==2.3.0 # via wagtail -django-modelcluster==5.0.2 # via wagtail +django-extensions==3.0.9 # via -r base.in +django-filter==2.4.0 # via wagtail +django-modelcluster==5.1 # via wagtail django-redis==4.12.1 # via -r base.in django-settings-export==1.2.1 # via -r base.in django-taggit==1.3.0 # via wagtail django-treebeard==4.3.1 # via wagtail -django==3.1.1 # via django-filter, django-redis, django-settings-export, django-taggit, django-treebeard, djangorestframework, mozilla-django-oidc, wagtail -djangorestframework==3.11.1 # via wagtail +django==3.1.2 # via django-filter, django-redis, django-settings-export, django-taggit, django-treebeard, djangorestframework, mozilla-django-oidc, wagtail +djangorestframework==3.12.1 # via wagtail draftjs-exporter==2.1.7 # via wagtail entrypoints==0.3 # via nbconvert et-xmlfile==1.0.1 # via openpyxl @@ -38,17 +38,17 @@ josepy==1.4.0 # via mozilla-django-oidc jsonschema==3.2.0 # via nbformat jupyter-client==6.1.7 # via nbclient jupyter-core==4.6.3 # via jupyter-client, nbconvert, nbformat -jupyterlab-pygments==0.1.1 # via nbconvert +jupyterlab-pygments==0.1.2 # via nbconvert l18n==2018.5 # via wagtail markupsafe==1.1.1 # via jinja2 mistune==0.8.4 # via nbconvert mozilla-django-oidc==1.2.4 # via pirates nbclient==0.5.0 # via nbconvert -nbconvert==6.0.2 # via -r base.in -nbformat==5.0.7 # via nbclient, nbconvert -nest-asyncio==1.4.0 # via nbclient +nbconvert==6.0.7 # via -r base.in +nbformat==5.0.8 # via nbclient, nbconvert +nest-asyncio==1.4.1 # via nbclient numpy==1.19.2 # via opencv-python -opencv-python==4.4.0.42 # via -r base.in +opencv-python==4.4.0.44 # via -r base.in openpyxl==3.0.5 # via tablib packaging==20.4 # via bleach pandocfilters==1.4.2 # via nbconvert @@ -58,7 +58,7 @@ psycopg2-binary==2.8.6 # via -r base.in pyasn1-modules==0.2.8 # via python-ldap pyasn1==0.4.8 # via pyasn1-modules, python-ldap pycparser==2.20 # via cffi -pygments==2.7.0 # via jupyterlab-pygments, nbconvert +pygments==2.7.1 # via jupyterlab-pygments, nbconvert pyopenssl==19.1.0 # via josepy pyparsing==2.4.7 # via packaging pyrsistent==0.17.3 # via jsonschema @@ -68,24 +68,24 @@ pytz==2020.1 # via django, django-modelcluster, l18n pyzmq==19.0.2 # via jupyter-client redis==3.5.3 # via django-redis requests==2.24.0 # via -r base.in, mozilla-django-oidc, wagtail -sentry-sdk==0.17.5 # via -r base.in +sentry-sdk==0.19.0 # via -r base.in six==1.15.0 # via bleach, cryptography, html5lib, ics, josepy, jsonschema, l18n, mozilla-django-oidc, packaging, pyopenssl, python-dateutil soupsieve==2.0.1 # via beautifulsoup4 -sqlparse==0.3.1 # via django +sqlparse==0.4.1 # via django tablib[xls,xlsx]==2.0.0 # via wagtail tatsu==5.5.0 # via ics testpath==0.4.4 # via nbconvert tornado==6.0.4 # via jupyter-client -traitlets==5.0.4 # via -r base.in, jupyter-client, jupyter-core, nbclient, nbconvert, nbformat +traitlets==5.0.5 # via -r base.in, jupyter-client, jupyter-core, nbclient, nbconvert, nbformat unidecode==1.1.1 # via wagtail urllib3==1.25.10 # via requests, sentry-sdk wagtail-metadata==3.3.0 # via -r base.in -wagtail==2.10.1 # via -r base.in, wagtail-metadata +wagtail==2.10.2 # via -r base.in, wagtail-metadata webencodings==0.5.1 # via bleach, html5lib whitenoise==5.2.0 # via -r base.in willow==1.4 # via wagtail xlrd==1.2.0 # via tablib -xlsxwriter==1.3.3 # via wagtail +xlsxwriter==1.3.7 # via wagtail xlwt==1.3.0 # via tablib # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/dev.txt b/requirements/dev.txt index a95d82ffdc0ce951744530258d45d2cca5bc0bb0..8173c620b0edf804c23f03254fb4a3255d47246a 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -5,28 +5,27 @@ # pip-compile dev.in # attrs==20.2.0 # via pytest -coverage==5.2.1 # via pytest-cov -factory-boy==3.0.1 # via pytest-factoryboy -faker==4.1.2 # via factory-boy +coverage==5.3 # via pytest-cov +factory-boy==3.1.0 # via pytest-factoryboy +faker==4.14.0 # via factory-boy fastdiff==0.2.0 # via snapshottest freezegun==1.0.0 # via pytest-freezegun inflection==0.5.1 # via pytest-factoryboy -iniconfig==1.0.1 # via pytest -more-itertools==8.5.0 # via pytest +iniconfig==1.1.1 # via pytest packaging==20.4 # via pytest, pytest-sugar pluggy==0.13.1 # via pytest py==1.9.0 # via pytest pyparsing==2.4.7 # via packaging pytest-cov==2.10.1 # via -r dev.in -pytest-django==3.9.0 # via -r dev.in +pytest-django==3.10.0 # via -r dev.in pytest-factoryboy==2.0.3 # via -r dev.in pytest-freezegun==0.4.2 # via -r dev.in pytest-mock==3.3.1 # via -r dev.in pytest-sugar==0.9.4 # via -r dev.in -pytest==6.0.1 # via -r dev.in, pytest-cov, pytest-django, pytest-factoryboy, pytest-freezegun, pytest-mock, pytest-sugar +pytest==6.1.1 # via -r dev.in, pytest-cov, pytest-django, pytest-factoryboy, pytest-freezegun, pytest-mock, pytest-sugar python-dateutil==2.8.1 # via faker, freezegun six==1.15.0 # via packaging, python-dateutil, snapshottest -snapshottest==0.5.1 # via -r dev.in +snapshottest==0.6.0 # via -r dev.in termcolor==1.1.0 # via pytest-sugar, snapshottest text-unidecode==1.3 # via faker toml==0.10.1 # via pytest diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index 91b07f9a32f0000e7fd361316bf1cfcbe3abf20e..9a0e02c7acd030d9bed4d429c39b96a8691ae7d2 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -37,10 +37,10 @@ <div> <div class="container container--wide navbar__content max-w-screen-xl" :class="{'navbar__content--initialized': true}"> <div class="navbar__brand my-4 flex items-center lg:pr-8 lg:my-0"> - <a href="#"> + <a href="/"> <img src="{% static "uniweb/assets/images/logo-round-white.svg" %}" class="w-8" /> </a> - <span class="pl-4 font-bold text-xl lg:border-r lg:border-grey-300 lg:pr-8">{{ page.root_page.seo_title }}</span> + <a href="/" class="pl-4 font-bold text-xl lg:border-r lg:border-grey-300 lg:pr-8">{{ page.root_page.seo_title }}</a> </div> {% if page.root_page.top_menu %} <div class="navbar__menutoggle my-4 flex justify-end lg:hidden"> diff --git a/uniweb/templatetags/uniweb_filters.py b/uniweb/templatetags/uniweb_filters.py index 4dd5f4027dd0317353c094ff36f3d92e58890f7d..bf858a057486ae5d43b27aacde809fc7985c6010 100644 --- a/uniweb/templatetags/uniweb_filters.py +++ b/uniweb/templatetags/uniweb_filters.py @@ -25,6 +25,9 @@ def jupyterize(value): c.TagRemovePreprocessor.enabled = True # Nutne c.TagRemovePreprocessor.remove_cell_tags = ["exclude"] c.TagRemovePreprocessor.remove_input_tags = ["output"] + c.TemplateExporter.exclude_output_prompt = ( + True # potlaci prazdne vystupy typu "Out[8]" + ) c.preprocessors = ["TagRemovePreprocessor"] nb_body, _ = nbconvert.TemplateExporter(