diff --git a/network-api/networkapi/utility/faker/streamfield_provider.py b/network-api/networkapi/utility/faker/streamfield_provider.py index e61730cddc7..0814b95a241 100644 --- a/network-api/networkapi/utility/faker/streamfield_provider.py +++ b/network-api/networkapi/utility/faker/streamfield_provider.py @@ -675,6 +675,18 @@ def generate_mixed_content_field(): ) +def generate_app_install_download_button_field(): + return generate_field( + "button", + { + "link_to": "external_url", + "external_url": fake.url(schemes=["https"]), + "label": " ".join(fake.words(nb=2)), + "new_window": True, + }, + ) + + class StreamfieldProvider(BaseProvider): """ A custom Faker Provider for relative image urls, for use with factory_boy @@ -734,6 +746,7 @@ def streamfield(self, fields=None): "profiles": generate_profiles_field, "newsletter_signup": generate_newsletter_signup_with_background_field, "mixed_content": generate_mixed_content_field, + "app_install_download_button": generate_app_install_download_button_field, } streamfield_data = [] diff --git a/network-api/networkapi/wagtailpages/factory/__init__.py b/network-api/networkapi/wagtailpages/factory/__init__.py index 54c14dffa06..5b4921c214f 100644 --- a/network-api/networkapi/wagtailpages/factory/__init__.py +++ b/network-api/networkapi/wagtailpages/factory/__init__.py @@ -1,6 +1,7 @@ from networkapi.wagtailpages.factory.libraries import rcc, research_hub from . import ( + app_install_page, bannered_campaign_page, blog, buyersguide, @@ -50,6 +51,7 @@ def generate(seed): rcc.generate(seed) # homepage_cause_statement_link requires child pages of homepage to exist homepage_cause_statement_link.generate(seed) + app_install_page.generate(seed) __all__ = [ diff --git a/network-api/networkapi/wagtailpages/factory/app_install_page.py b/network-api/networkapi/wagtailpages/factory/app_install_page.py new file mode 100644 index 00000000000..89c442e9683 --- /dev/null +++ b/network-api/networkapi/wagtailpages/factory/app_install_page.py @@ -0,0 +1,39 @@ +from factory import Faker, SubFactory +from wagtail_factories import PageFactory + +from networkapi.utility.faker.helpers import reseed +from networkapi.wagtailpages import models as pagemodels +from networkapi.wagtailpages.factory import image_factory +from networkapi.wagtailpages.models import AppInstallPage + +from .petition import PetitionFactory + + +class AppInstallPageFactory(PageFactory): + class Meta: + model = AppInstallPage + exclude = ( + "title_text", + "header_text", + "header", + ) + + title = "Regrets Reporter Page" + slug = "regretsreporter" + hero_heading = Faker("text", max_nb_chars=50) + hero_subheading = Faker("text", max_nb_chars=50) + hero_background = SubFactory(image_factory.ImageFactory) + download_buttons = Faker("streamfield", fields=["app_install_download_button"] * 2) + cta = SubFactory(PetitionFactory) + body = Faker("streamfield", fields=["header", "paragraph", "image", "spacer", "image_text", "quote"]) + + +def generate(seed): + reseed(seed) + + print("Generating PNI Homepage") + AppInstallPageFactory.create( + parent=pagemodels.Homepage.objects.first(), + title="App Install Page", + slug="app-install-page", + )