Skip to content

Commit

Permalink
Merge branch 'main' into TP1-1033-migrate-GA-to-GTM
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezvsr authored Sep 9, 2024
2 parents 930d88a + 491955b commit d1e64d9
Show file tree
Hide file tree
Showing 21 changed files with 653 additions and 1,428 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% load static %}

<div class="tw-w-max">
<a href="{{ link_href }}" class="tw-flex tw-items-center tw-font-sans tw-text-base tw-font-bold tw-text-blue-80 tw-leading-5 tw-no-underline hover:tw-underline {{ extra_classes }}">
{{ link_text }}
<a href="{{ link.url }}" {% if link.new_window %}target="_blank"{% endif %} class="tw-flex tw-items-center tw-font-sans tw-text-base tw-font-bold tw-text-blue-80 tw-leading-5 tw-no-underline hover:tw-underline {{ extra_classes }}">
{{ link.label }}
<img src="{% static "_images/buyers-guide/arrow-right.svg" %}" class="tw-ml-2 " alt="">
</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
</div>
{% endif %}

{% if link_text and link_href %}
<div class="tw-mt-16">
{% include "./arrow_link.html" with link_href=link_href link_text=link_text %}
</div>
{% if link %}
{% with link=link.0.value %}
<div class="tw-mt-16">
{% include "./arrow_link.html" with link=link %}
</div>
{% endwith %}
{% endif %}
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load bg_nav_tags wagtailcore_tags i18n static %}
{% get_bg_home_page as home_page %}
{% load wagtailcore_tags i18n static %}

<div class="container">
<img class="mb-3 oh-no-face" src="{% static '_images/buyers-guide/faces/oh-no.svg' %}" alt="{% trans "Sad face. No products were found." %}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load bg_nav_tags i18n static wagtailcore_tags wagtailroutablepage_tags %}
{% get_bg_home_page as home_page %}

<div class="d-md-none mt-0 mb-0 tw-bg-white" id="pni-mobile-category-nav">
<div class="container">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load bg_nav_tags i18n wagtailroutablepage_tags wagtailcore_tags static %}
{% get_bg_home_page as home_page %}

{{ pre }}
{% with home_page.get_editorial_content_index as editorial_content_index %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{% block menu_container_classes %} tw-pb-0 {% endblock %}

{% block nav_logo %}
{% get_bg_home_page as home_page %}
<div class="tw-flex tw-flex-col logo-section tw-mx-auto large:tw-mx-0">
<p class="mb-0 tw-h3-heading tw-max-w-none flex-wrap">
<a class="link-back tw-flex" href="{% pageurl home_page %}">
Expand All @@ -26,7 +25,6 @@
{% endblock %}

{% block narrow_screen_nav_links %}
{% get_bg_home_page as home_page %}
{% include "fragments/buyersguide/pni_nav_links.html" with class="tw-block tw-w-fit" pre="<div>" post="</div>" %}
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load wagtailcore_tags bg_selector_tags l10n i18n wagtailroutablepage_tags static bg_nav_tags %}
{% get_bg_home_page as home_page %}

<div id="product-tab" class="tw-w-full tw-mb-8">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
</div>
</div>
</div>
{% get_bg_home_page as home_page %}
{% bg_non_hidden_categories as categories %}
<div class="project-list-section">
<div class="container">
Expand Down Expand Up @@ -138,7 +137,7 @@
data-show-for-categories="{% for category in categories %}{% if category.show_cta %}{{ category.name }}, {% endif %}{% endfor %}"
>
{% with cta=featured_cta %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link_text=cta.link_label link_href=cta.get_target_url large=True %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link=cta.link large=True %}
{% endwith %}
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>{{ page.title }}</h1>
<aside class="tw-flex tw-flex-col medium:tw-flex-row tw-gap-16 tw-py-12">
{% if cta %}
<div class="tw-basis-1/2">
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link_text=cta.link_label link_href=cta.get_target_url %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link=cta.link %}
</div>
{% endif %}

Expand All @@ -62,7 +62,7 @@ <h1>{{ page.title }}</h1>
{% if cta or related_articles %}
<aside class="tw-hidden large:tw-flex tw-col-span-4 tw-flex-col tw-gap-16">
{% if cta %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link_text=cta.link_label link_href=cta.get_target_url %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link=cta.link %}
{% endif %}

{% if related_articles %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{% with cta=featured_cta %}
{% if cta %}
<div class="{{ row_item_classes }}">
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link_text=cta.link_label link_href=cta.get_target_url %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link=cta.link %}
</div>
{% endif %}
{% endwith %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

{% block guts %}

{% get_bg_home_page as home_page %}

<div class="text-center product-header bg-product-image{% if product.draft %} draft-product{% endif %}">
<div class="tw-container tw-block medium:tw-grid tw-grid-cols-12 tw-gap-x-16">
<div class="tw-col-start-3 tw-col-end-11 tw--mx-8 medium:tw--mx-16">
Expand Down Expand Up @@ -101,7 +99,7 @@ <h1 class="tw-h1-heading col-12">{{ product.title }}</h1>
">
{% with cta=featured_cta %}
{% if cta %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link_text=cta.link_label link_href=cta.get_target_url %}
{% include "fragments/buyersguide/call_to_action_box.html" with icon=cta.sticker_image heading=cta.title body=cta.content link=cta.link %}
{% endif %}
{% endwith %}

Expand Down
12 changes: 12 additions & 0 deletions network-api/networkapi/utility/faker/streamfield_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,17 @@ def generate_app_install_download_button_field():
)


def generate_bg_cta_link_field():
link_value = {
"link_to": "external_url",
"external_url": fake.url(schemes=["https"]),
"label": " ".join(fake.words(nb=2)),
"new_window": True,
}

return generate_field("link", link_value)


class StreamfieldProvider(BaseProvider):
"""
A custom Faker Provider for relative image urls, for use with factory_boy
Expand Down Expand Up @@ -792,6 +803,7 @@ def streamfield(self, fields=None):
"newsletter_signup": generate_newsletter_signup_with_background_field,
"mixed_content": generate_mixed_content_field,
"app_install_download_button": generate_app_install_download_button_field,
"buyersguide_call_to_action_link": generate_bg_cta_link_field,
}

streamfield_data = []
Expand Down
3 changes: 1 addition & 2 deletions network-api/networkapi/wagtailpages/factory/buyersguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class Meta:

title = Faker("sentence", nb_words=7, variable_nb_words=True)
content = Faker("paragraph", nb_sentences=3, variable_nb_sentences=True)
link_label = Faker("sentence", nb_words=2)
link_target_url = Faker("url")
link = Faker("streamfield", fields=["buyersguide_call_to_action_link"])


class ProductUpdateFactory(DjangoModelFactory):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Generated by Django 4.2.14 on 2024-08-28 01:05

import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields
from django.db import migrations

import networkapi.wagtailpages.validators


def migrate_link_field(apps, schema_editor):
BuyersGuideCallToAction = apps.get_model("wagtailpages", "BuyersGuideCallToAction")
for instance in BuyersGuideCallToAction.objects.all():

stream_data = []

if instance.link_label and (instance.link_target_url or instance.link_target_page):
if instance.link_target_url:
link_value = {
"link_to": "external_url",
"external_url": instance.link_target_url,
"label": instance.link_label,
"new_window": False,
}
stream_data = [("link", link_value)]

elif instance.link_target_page:
link_value = {
"link_to": "page",
"label": instance.link_label,
"new_window": False,
"page": instance.link_target_page,
}
stream_data = [("link", link_value)]

instance.link = stream_data
instance.save()


class Migration(migrations.Migration):

dependencies = [
("wagtailpages", "0158_alter_blogpage_body_and_more"),
]

operations = [
migrations.AddField(
model_name="buyersguidecalltoaction",
name="link",
field=wagtail.fields.StreamField(
[
(
"link",
wagtail.blocks.StructBlock(
[
("label", wagtail.blocks.CharBlock()),
(
"link_to",
wagtail.blocks.ChoiceBlock(
choices=[
("page", "Page"),
("external_url", "External URL"),
("relative_url", "Relative URL"),
("email", "Email"),
("anchor", "Anchor"),
("file", "File"),
("phone", "Phone"),
],
label="Link to",
),
),
("page", wagtail.blocks.PageChooserBlock(label="Page", required=False)),
(
"external_url",
wagtail.blocks.URLBlock(
help_text="Enter a full URL including http:// or https://",
label="External URL",
max_length=300,
required=False,
),
),
(
"relative_url",
wagtail.blocks.CharBlock(
help_text='A path relative to this domain. For example, "/foo/bar" or "?foo=bar".',
label="Relative URL",
max_length=300,
required=False,
validators=[networkapi.wagtailpages.validators.RelativeURLValidator()],
),
),
(
"anchor",
wagtail.blocks.CharBlock(
help_text='An id attribute of an element on the current page. For example, "#section-1"',
label="#",
max_length=300,
required=False,
validators=[networkapi.wagtailpages.validators.AnchorLinkValidator()],
),
),
("email", wagtail.blocks.EmailBlock(required=False)),
("file", wagtail.documents.blocks.DocumentChooserBlock(label="File", required=False)),
("phone", wagtail.blocks.CharBlock(label="Phone", max_length=30, required=False)),
(
"new_window",
wagtail.blocks.BooleanBlock(label="Open in new window", required=False),
),
]
),
)
],
blank=True,
use_json_field=True,
),
),
migrations.RunPython(migrate_link_field),
migrations.RemoveField(
model_name="buyersguidecalltoaction",
name="link_label",
),
migrations.RemoveField(
model_name="buyersguidecalltoaction",
name="link_target_page",
),
migrations.RemoveField(
model_name="buyersguidecalltoaction",
name="link_target_url",
),
]
Loading

0 comments on commit d1e64d9

Please sign in to comment.