Skip to content

Commit

Permalink
Merge branch 'main' into 10328-percy-flags-date
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmavis authored Jan 25, 2024
2 parents faf23d0 + 2d61300 commit 0c04f73
Show file tree
Hide file tree
Showing 39 changed files with 735 additions and 201 deletions.
61 changes: 61 additions & 0 deletions network-api/networkapi/donate/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from wagtail import hooks
from wagtail.admin.ui.tables import UpdatedAtColumn
from wagtail.snippets.models import register_snippet
from wagtail.snippets.views.snippets import SnippetViewSet, SnippetViewSetGroup

from networkapi.donate_banner.models import DonateBanner
from networkapi.wagtailcustomization.views.snippet_chooser import (
DefaultLocaleSnippetChooserViewSet,
)
from networkapi.wagtailpages.donation_modal import DonationModal


# Customise DonateBanner Snippet admin listing to show extra columns.
class DonateBannerViewSet(SnippetViewSet):
model = DonateBanner
icon = "form" # change as required
menu_order = 100
description = "Donation Banner"
menu_label = "Donation Banners"
list_display = ["name", "cta_link", "is_active", UpdatedAtColumn()]


# Customise chooser to only show the default language banners as options.
# We do not want editors to select the translations as
# localisation will be handled on the template instead.
@hooks.register("register_admin_viewset")
def register_donate_banner_chooser_viewset():
return DefaultLocaleSnippetChooserViewSet(
"wagtailsnippetchoosers_custom_donatebanner",
model=DonateBanner,
url_prefix="donate_banner/chooser",
)


class DonationModalSnippetViewSet(SnippetViewSet):
model = DonationModal
icon = "newspaper"
menu_order = 200
menu_label = "Newsletter Signups"
menu_name = "Newsletter Signups"
list_display = (
"name",
"donate_text",
"donate_url",
"dismiss_text",
)
search_fields = ("name", "header", "body", "donate_text", "donate_url", "dismiss_text")


class DonateViewSetGroup(SnippetViewSetGroup):
items = (
DonateBannerViewSet,
DonationModalSnippetViewSet,
)
menu_icon = "heart"
menu_label = "Donate"
menu_name = "Donate"
menu_order = 1000


register_snippet(DonateViewSetGroup)
31 changes: 1 addition & 30 deletions network-api/networkapi/donate_banner/models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from django.contrib import admin
from django.core.validators import RegexValidator
from django.db import models
from wagtail import hooks
from wagtail.admin.panels import FieldPanel, HelpPanel
from wagtail.admin.ui.tables import UpdatedAtColumn
from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
from wagtail.models import PreviewableMixin, TranslatableMixin
from wagtail.snippets.models import register_snippet
from wagtail.snippets.views.snippets import SnippetViewSet
from wagtail_localize.fields import SynchronizedField, TranslatableField

from networkapi.wagtailcustomization.views.snippet_chooser import (
DefaultLocaleSnippetChooserViewSet,
)
from networkapi.wagtailpages.constants import url_or_query_regex


Expand Down Expand Up @@ -96,29 +89,7 @@ def is_active(self):
return "No"


# Customise DonateBanner Snippet admin listing to show extra columns.
class DonateBannerViewSet(SnippetViewSet):
model = DonateBanner
description = "Donate Banner"
list_display = ["name", "cta_link", "is_active", UpdatedAtColumn()]


register_snippet(DonateBanner, viewset=DonateBannerViewSet)


# Customise chooser to only show the default language banners as options.
# We do not want editors to select the translations as
# localisation will be handled on the template instead.
@hooks.register("register_admin_viewset")
def register_donate_banner_chooser_viewset():
return DefaultLocaleSnippetChooserViewSet(
"wagtailsnippetchoosers_custom_donatebanner",
model=DonateBanner,
url_prefix="donate_banner/chooser",
)


@register_setting(icon="pick")
@register_setting(icon="heart")
class SiteDonateBanner(BaseSiteSetting):
select_related = ["active_donate_banner"]

Expand Down
2 changes: 0 additions & 2 deletions network-api/networkapi/events/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.db import models
from wagtail.snippets.models import register_snippet


@register_snippet
class TitoEvent(models.Model):
"""
Details of an event managed in Tito.
Expand Down
31 changes: 0 additions & 31 deletions network-api/networkapi/highlights/admin.py

This file was deleted.

2 changes: 0 additions & 2 deletions network-api/networkapi/highlights/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from wagtail.admin.panels import FieldPanel
from wagtail.fields import RichTextField
from wagtail.models import TranslatableMixin
from wagtail.snippets.models import register_snippet
from wagtail_localize.fields import TranslatableField

from networkapi.utility.images import get_image_upload_path
Expand Down Expand Up @@ -33,7 +32,6 @@ def published(self):
)


@register_snippet
class Highlight(TranslatableMixin, SortableMixin):
"""
An data type to highlight things like pulse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.9 on 2024-01-23 17:52

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("mozfest", "0044_configure_cards_per_row_on_listing_block"),
]

operations = [
migrations.AlterModelOptions(
name="newslettersignupwithbackground",
options={"ordering": ["name"], "verbose_name": "Mozfest Newsletter Signup"},
),
]
5 changes: 1 addition & 4 deletions network-api/networkapi/mozfest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.fields import RichTextField, StreamField
from wagtail.models import Locale, Page, TranslatableMixin
from wagtail.snippets.models import register_snippet
from wagtail_localize.fields import SynchronizedField, TranslatableField

from networkapi.mozfest import blocks as mozfest_blocks
Expand All @@ -24,7 +23,6 @@
)


@register_snippet
class Ticket(TranslatableMixin):
name = models.CharField(
max_length=100,
Expand Down Expand Up @@ -62,7 +60,6 @@ class Meta(TranslatableMixin.Meta):
verbose_name = "Ticket"


@register_snippet
class NewsletterSignupWithBackground(TranslatableMixin, campaign_models.CTA):
background_image = models.ForeignKey(
"wagtailimages.Image",
Expand All @@ -80,7 +77,7 @@ class NewsletterSignupWithBackground(TranslatableMixin, campaign_models.CTA):

class Meta(TranslatableMixin.Meta):
ordering = ["name"]
verbose_name = "Newsletter Signup With Background"
verbose_name = "Mozfest Newsletter Signup"


class MozfestPrimaryPage(FoundationMetadataPageMixin, FoundationBannerInheritanceMixin, Page):
Expand Down
57 changes: 57 additions & 0 deletions network-api/networkapi/mozfest/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from wagtail.snippets.models import register_snippet
from wagtail.snippets.views.snippets import SnippetViewSet, SnippetViewSetGroup

from networkapi.events.models import TitoEvent
from networkapi.mozfest.models import NewsletterSignupWithBackground, Ticket


class TitoEventSnippetViewSet(SnippetViewSet):
model = TitoEvent
icon = "tito"
menu_order = 000
menu_label = "Tito"
menu_name = "Tito"
list_display = (
"title",
"event_id",
)
search_fields = ("title", "event_id", "newsletter_question_id")


class TicketSnippetViewSet(SnippetViewSet):
model = Ticket
icon = "ticket"
menu_order = 100
menu_label = "Tickets"
menu_name = "Tickets"
list_display = (
"name",
"cost",
"event",
"sticker_text",
)
search_fields = ("name", "description", "cost", "button_text", "releases", "event", "sticker_text")


class NewsletterSignupWithBackgroundSnippetViewSet(SnippetViewSet):
model = NewsletterSignupWithBackground
icon = "newspaper"
menu_order = 200
menu_label = "Newsletter Signups"
menu_name = "Newsletter Signups"
list_display = (
"name",
"newsletter",
)
search_fields = ("name", "header", "description", "newsletter")


class MozfestViewSetGroup(SnippetViewSetGroup):
items = (TitoEventSnippetViewSet, TicketSnippetViewSet, NewsletterSignupWithBackgroundSnippetViewSet)
menu_icon = "mozfest"
menu_label = "Mozfest"
menu_name = "Mozfest"
menu_order = 1300


register_snippet(MozfestViewSetGroup)
28 changes: 0 additions & 28 deletions network-api/networkapi/news/admin.py

This file was deleted.

2 changes: 0 additions & 2 deletions network-api/networkapi/news/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.db.models import Q
from django.utils import timezone
from wagtail.models import TranslatableMixin
from wagtail.snippets.models import register_snippet

from networkapi.utility.images import get_image_upload_path

Expand Down Expand Up @@ -30,7 +29,6 @@ def published(self):
)


@register_snippet
class News(TranslatableMixin, models.Model):
"""
Medium blog posts, articles and other media
Expand Down
1 change: 0 additions & 1 deletion network-api/networkapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
"wagtail.contrib.routable_page",
"wagtail.contrib.styleguide" if DEBUG else None,
"wagtail.contrib.table_block",
"wagtail.contrib.modeladmin",
"wagtail.contrib.frontend_cache",
"wagtail.contrib.settings",
"wagtail_color_panel",
Expand Down
4 changes: 4 additions & 0 deletions network-api/networkapi/templates/icons/flask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions network-api/networkapi/templates/icons/heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions network-api/networkapi/templates/icons/mozfest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions network-api/networkapi/templates/icons/newspaper.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions network-api/networkapi/templates/icons/pni.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions network-api/networkapi/templates/icons/ticket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0c04f73

Please sign in to comment.