diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 92d5dc4ed0253d3d0dec5608aa6201a58c583285..64d7afbfcff1d074e875e801e4b1ade744390e0a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.10 + python: python3.11 exclude: snapshots/ repos: diff --git a/donate/menu.py b/donate/menu.py new file mode 100644 index 0000000000000000000000000000000000000000..a97b73de493fbca38a12785a1d9b326e64d33dd4 --- /dev/null +++ b/donate/menu.py @@ -0,0 +1,30 @@ +from wagtail.fields import StreamField + +from shared.blocks import MenuItemBlock as MenuItemBlockBase +from shared.models import MenuMixin as MenuMixinBase + + +class MenuItemBlock(MenuItemBlockBase): + class Meta: + label = "Položka v menu" + template = "donate/blocks/menu_item.html" + + +# +# +# class MenuParentBlock(MenuParentBlockBase): +# class Meta: +# label = "Podmenu" +# template = "styleguide/2.3.x/menu_parent.html" + + +class MenuMixin(MenuMixinBase): + menu = StreamField( + [("menu_item", MenuItemBlock())], # , ("menu_parent", MenuParentBlock()) + verbose_name="Menu", + blank=True, + use_json_field=True, + ) + + class Meta: + abstract = True diff --git a/donate/migrations/0031_donateprojectindexpage_support_description_and_more.py b/donate/migrations/0031_donateprojectindexpage_support_description_and_more.py index f26d0ae6edc003b7484929d6099df7809d28aed2..2bc5a3836b8bc0a8031e2cc8684bc16722eb67a3 100644 --- a/donate/migrations/0031_donateprojectindexpage_support_description_and_more.py +++ b/donate/migrations/0031_donateprojectindexpage_support_description_and_more.py @@ -1,7 +1,7 @@ # Generated by Django 4.1.10 on 2023-09-13 18:47 -from django.db import migrations, models import wagtail.fields +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/donate/migrations/0034_donatehomepage_menu.py b/donate/migrations/0034_donatehomepage_menu.py new file mode 100644 index 0000000000000000000000000000000000000000..dce15d59b133734e9f9023a843626f61f3f71d13 --- /dev/null +++ b/donate/migrations/0034_donatehomepage_menu.py @@ -0,0 +1,50 @@ +# Generated by Django 4.1.10 on 2023-09-22 08:24 + +import wagtail.blocks +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("donate", "0033_donateprojectindexpage_support_position"), + ] + + operations = [ + migrations.AddField( + model_name="donatehomepage", + name="menu", + field=wagtail.fields.StreamField( + [ + ( + "menu_item", + wagtail.blocks.StructBlock( + [ + ( + "title", + wagtail.blocks.CharBlock( + label="Titulek", required=True + ), + ), + ( + "page", + wagtail.blocks.PageChooserBlock( + label="Stránka", required=False + ), + ), + ( + "link", + wagtail.blocks.URLBlock( + label="Odkaz", required=False + ), + ), + ] + ), + ) + ], + blank=True, + use_json_field=True, + verbose_name="Menu", + ), + ), + ] diff --git a/donate/models.py b/donate/models.py index c64754da2e6ec9d955501fbfb893a410951db42f..2f667776051c3b4be61ee11db16455b14029f866 100644 --- a/donate/models.py +++ b/donate/models.py @@ -12,7 +12,9 @@ from wagtail.admin.panels import ( FieldPanel, InlinePanel, MultiFieldPanel, + ObjectList, PublishingPanel, + TabbedInterface, ) from wagtail.fields import RichTextField, StreamField from wagtail.images.blocks import ImageChooserBlock @@ -29,6 +31,7 @@ from tuning import admin_help from .blocks import CrowdfundingRewardBlock, CustomContentBlock from .forms import DonateForm +from .menu import MenuMixin from .utils import get_donated_amount_from_api @@ -90,6 +93,7 @@ class DonateFormAmountsMixin(models.Model): class DonateHomePage( + MenuMixin, DonateFormMixin, DonateFormAmountsMixin, Page, @@ -233,6 +237,17 @@ class DonateHomePage( FieldPanel("faq_page"), ] + ### EDIT HANDLERS + + edit_handler = TabbedInterface( + [ + ObjectList(content_panels, heading="Obsah"), + ObjectList(promote_panels, heading="Propagovat"), + ObjectList(settings_panels, heading="Nastavení"), + ObjectList(MenuMixin.menu_panels, heading="Menu"), + ] + ) + ### RELATIONS subpage_types = [ @@ -287,12 +302,10 @@ class DonateHomePage( block["index"] = project_index block["projects"] = ( - DonateProjectPage. - objects. - child_of(project_index). - live(). - specific(). - order_by("-date")[:3] + DonateProjectPage.objects.child_of(project_index) + .live() + .specific() + .order_by("-date")[:3] ) context["project_support_blocks"].append(block) @@ -658,8 +671,8 @@ class DonateTextPage(Page, ExtendedMetadataPageMixin, SubpageMixin, MetadataPage ### RELATIONS - parent_page_types = ["donate.DonateHomePage"] - subpage_types = [] + parent_page_types = ["donate.DonateHomePage", "donate.DonateTextPage"] + subpage_types = ["donate.DonateTextPage"] ### OTHERS diff --git a/donate/static/donate/assets/css/style.css b/donate/static/donate/assets/css/style.css index 4363a1cd9ae9c970a5f053fc3ac2f5dbcc6d2e38..c85a1b81880f888f8ec8bdcefa211c6adfb89b5d 100644 --- a/donate/static/donate/assets/css/style.css +++ b/donate/static/donate/assets/css/style.css @@ -596,6 +596,7 @@ footer h1, footer h2, footer h3, footer h4, footer h5, footer h6 { .project .card-body p { color: #797676; + white-space: pre-line; } .project .card-footer p { @@ -1213,3 +1214,54 @@ img.full-width { float: right; margin-left: 1.5rem; } + +/* BEGIN TailwindCSS-based image formatting */ + +.mx-auto { + margin-left: auto; + margin-right: auto +} + +.my-6 { + margin-top: 1.5rem; + margin-bottom: 1.5rem +} + +.max-w-\[800px\] { + max-width: 800px +} + +.lg\:max-w-full{ + max-width: 100% +} + +.float-left{ + float: left +} + +.max-w-\[400px\]{ + max-width: 400px +} + +.sm\:max-w-full{ + max-width: 100% +} + +.float-right{ + float: right +} + +.ml-4 { + margin-left: 1rem +} + +.mb-6{ + margin-bottom: 1.5rem +} + +.object-contain { + object-fit: contain; + -o-object-fit: contain +} + +/* END TailwindCSS-based image formatting */ diff --git a/donate/templates/donate/base.html b/donate/templates/donate/base.html index 0457be0ee9a96bdfc3812fc16f914c2c3af010a8..06f4891cf618d5f48f6dcc741a6337943bbb99dd 100644 --- a/donate/templates/donate/base.html +++ b/donate/templates/donate/base.html @@ -6,20 +6,7 @@ <base target="_blank"> {% endif %} - <!-- Font loader --> - <script type="text/javascript"> - WebFontConfig = { - google: { families: ['Roboto+Condensed:300,300i,400,400i,700,700i:latin-ext', 'Bebas+Neue'] } - }; - (function () { - var wf = document.createElement('script'); - wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; - wf.type = 'text/javascript'; - wf.async = 'true'; - var s = document.getElementsByTagName('script')[0]; - s.parentNode.insertBefore(wf, s); - })(); - </script> + <link href="https://gfonts.pirati.cz/css2?family=Bebas+Neue&family=Roboto+Condensed:wght@300;400;700&family=Roboto:wght@300;400;500&display=swap" rel="stylesheet"> <!-- Meta --> <meta charset="utf-8"> @@ -93,22 +80,11 @@ <!-- Navigation --> <div class="collapse navbar-collapse" id="mainNavigation"> <ul class="navbar-nav ml-auto"> - <li class="nav-item"> - {% if page.is_home %} - <a class="nav-link js-scroll-anchor" href="#strana">Podpoř Piráty</a> - {% else %} - <a class="nav-link" href="/#strana">Podpoř Piráty</a> - {% endif %} - </li> - {% for projects_page in page.root_page.project_indexes %} - <li class="nav-item"> - <a class="nav-link" href="{{ projects_page.url }}">{{ projects_page.title }}</a> - </li> + {% for block in page.root_page.menu %} + {% include_block block %} {% endfor %} - <li class="nav-item"> - <a class="nav-link" href="{{ page.root_page.regions_page_url }}">Kraje</a> - </li> </ul> + {% if page.root_page.custom_url_1 and page.root_page.custom_url_1_text %} <a href="{{ page.root_page.custom_url_1 }}" class="d-block d-lg-none mb-3 header_link header_link--desktop" target="_blank" rel="noreferrer"><i class="icon-external-link mr-2" title="Ikona odkazu"></i>{{ page.root_page.custom_url_1_text }}</a> diff --git a/donate/templates/donate/blocks/menu_item.html b/donate/templates/donate/blocks/menu_item.html new file mode 100644 index 0000000000000000000000000000000000000000..e2af3c37059dae85d99136c11e15597303914b95 --- /dev/null +++ b/donate/templates/donate/blocks/menu_item.html @@ -0,0 +1,3 @@ +{% firstof self.page.url self.link as target %} + <a class="nav-link js-scroll-anchor" href="{{ target }}">{{ self.title }}</a> +</a> diff --git a/majak/context_processors.py b/majak/context_processors.py new file mode 100644 index 0000000000000000000000000000000000000000..361bfebe83fd6aafe0f1bbe2890424c03f0c3c3d --- /dev/null +++ b/majak/context_processors.py @@ -0,0 +1,5 @@ +from django.conf import settings + + +def styleguide_url_processor(request): + return {"styleguide_url": settings.STYLEGUIDE_URL} diff --git a/majak/settings/base.py b/majak/settings/base.py index 4542b8db1e2490c475d03d06d0f9a831c97b7bee..d42dcacce345fc8c624d5c17fbf4516e7d364acf 100644 --- a/majak/settings/base.py +++ b/majak/settings/base.py @@ -149,6 +149,7 @@ TEMPLATES = [ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "django_settings_export.settings_export", + "majak.context_processors.styleguide_url_processor", ], }, }, @@ -264,6 +265,8 @@ WAGTAILADMIN_BASE_URL = BASE_URL # CUSTOM SETTINGS # ------------------------------------------------------------------------------ +STYLEGUIDE_URL = env.str("STYLEGUIDE_URL", "https://styleguide.pirati.cz/2.16.x") + MAJAK_ENV = env.str("MAJAK_ENV", default="prod") SETTINGS_EXPORT = ["MAJAK_ENV"] diff --git a/shared/image_formats.py b/shared/image_formats.py index 25ae5e33b1de328e98f95bf0f473cf5e44044532..fc1a1a8f2cd44c76ecc6f2d9d2e9d6dd70025c4e 100644 --- a/shared/image_formats.py +++ b/shared/image_formats.py @@ -4,7 +4,7 @@ register_image_format( Format( "tailwind_center_800", "šablona: Uprostřed (max 800px)", - "mx-auto my-6", + "mx-auto my-6 max-w-[800px] lg:max-w-full object-contain", "max-800x800", ) ) @@ -13,7 +13,7 @@ register_image_format( Format( "tailwind_left_400", "šablona: Vlevo (max 400px)", - "float-left mr-4 mb-6", + "float-left mr-4 mb-6 max-w-[400px] sm:max-w-full object-contain", "max-400x400", ) ) @@ -22,7 +22,7 @@ register_image_format( Format( "tailwind_left_200", "šablona: Vlevo (max 200px)", - "float-left mr-4 mb-6", + "float-left mr-4 mb-6 object-contain", "max-200x200", ) ) @@ -31,7 +31,7 @@ register_image_format( Format( "tailwind_right_400", "šablona: Vpravo (max 400px)", - "float-right ml-4 mb-6", + "float-right ml-4 mb-6 max-w-[400px] sm:max-w-full object-contain", "max-400x400", ) ) @@ -40,7 +40,7 @@ register_image_format( Format( "tailwind_right_200", "šablona: Vpravo (max 200px)", - "float-right ml-4 mb-6", + "float-right ml-4 mb-6 object-contain", "max-200x200", ) ) diff --git a/tuning/templates/tuning/sites_list.html b/tuning/templates/tuning/sites_list.html index c3fd57e567ecda932654c2e7301d3482b425ca19..cb4ef1801b38cf0dc59dc0ff8f2198b40cdf1b50 100644 --- a/tuning/templates/tuning/sites_list.html +++ b/tuning/templates/tuning/sites_list.html @@ -13,8 +13,8 @@ {% include "shared/favicon_snippet.html" %} <!-- Styles --> - <link href="https://styleguide.pirati.cz/2.3.x/css/styles.css" rel="stylesheet" media="all" /> - <link href="https://styleguide.pirati.cz/2.3.x/css/pattern-scaffolding.css" rel="stylesheet" media="all" /> + <link href="{{ styleguide_url }}/css/styles.css" rel="stylesheet" media="all" /> + <link href="{{ styleguide_url }}/css/pattern-scaffolding.css" rel="stylesheet" media="all" /> <style type="text/css"> .head-alt-md, .head-alt-lg { @@ -109,7 +109,7 @@ <section class="footer__brand"> {% if page.root_page.show_logo %} <a href="https://www.pirati.cz"> - <img src="https://styleguide.pirati.cz/2.3.x/images/logo-full-white.svg" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" /> + <img src="{{ styleguide_url }}/images/logo-full-white.svg" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" /> </a> {% endif %} <p class="para hidden md:block md:mb-4 lg:mb-0 text-grey-200"> @@ -128,7 +128,7 @@ </footer> <script src="{% static "shared/vendor/vue/vue.2.6.11.js" %}"></script> - <script src="https://styleguide.pirati.cz/2.3.x/js/main.bundle.js"></script> + <script src="{{ styleguide_url }}/js/main.bundle.js"></script> <script src="{% static "shared/vendor/jquery/jquery-3.4.1.min.js" %}"></script> <script src="{% static "shared/vendor/lazysizes/lazysizes.min.js" %}"></script> </body> diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index c99498b327b8409f3c9c2e51c558fb92dce2b1ab..36cb6b92c078871f936a08314cf490b7ab286583 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -17,8 +17,8 @@ {% include "shared/favicon_snippet.html" %} <!-- Styles --> - <link href="https://styleguide.pirati.cz/2.14.x/css/styles.css" rel="stylesheet" media="all" /> - <link href="https://styleguide.pirati.cz/2.14.x/css/pattern-scaffolding.css" rel="stylesheet" media="all" /> + <link href="{{ styleguide_url }}/css/styles.css" rel="stylesheet" media="all" /> + <link href="{{ styleguide_url }}/css/pattern-scaffolding.css" rel="stylesheet" media="all" /> <link href="{% static "shared/vendor/fancybox/jquery.fancybox.min.css" %}" rel="stylesheet"> <link rel="stylesheet" href="{% static "shared/vendor/vue-formulate-2.5.3/css/snow.min.css" %}"> <link rel="stylesheet" href="{% static "shared/css/helpers.css" %}"> @@ -95,7 +95,7 @@ <section class="footer__brand"> {% if page.root_page.show_logo %} <a href="https://www.pirati.cz"> - <img src="https://styleguide.pirati.cz/2.14.x/images/logo-full-white.svg" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" /> + <img src="{{ styleguide_url }}/images/logo-full-white.svg" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" /> </a> {% endif %} <p class="para hidden md:block md:mb-4 lg:mb-0 text-grey-200"> @@ -155,7 +155,7 @@ {% endif %} <script src="{% static "shared/vendor/vue/vue.2.6.11.js" %}"></script> - <script src="https://styleguide.pirati.cz/2.14.x/js/main.bundle.js"></script> + <script src="{{ styleguide_url }}/js/main.bundle.js"></script> <script src="{% static "shared/vendor/jquery/jquery-3.4.1.min.js" %}"></script> <script src="{% static "shared/vendor/lazysizes/lazysizes.min.js" %}"></script> <script src="{% static "shared/vendor/fancybox/jquery.fancybox.min.js" %}"></script> diff --git a/uniweb/templates/uniweb/logo_snippet.html b/uniweb/templates/uniweb/logo_snippet.html index 322713add504b6239217e91df3147a8c43ef7cd0..754ee4b4cbb1bc73fc4c07460d508bd1f767a46c 100644 --- a/uniweb/templates/uniweb/logo_snippet.html +++ b/uniweb/templates/uniweb/logo_snippet.html @@ -4,5 +4,5 @@ {% image page.root_page.logo original as logo %} <img src="{{ logo.full_url }}" class="w-8" /> {% else %} - <img src="https://styleguide.pirati.cz/2.14.x/images/logo-round-white.svg" class="w-8" /> + <img src="{{ styleguide_url }}/images/logo-round-white.svg" class="w-8" /> {% endif %}