зеркало из https://github.com/mozilla/kitsune.git
Remove wagtail from the code-base
This commit is contained in:
Родитель
6bb6fbb9dc
Коммит
e92c5a9b4b
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 4.2.16 on 2024-10-14 03:54
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("products", "0019_alter_singleproductindexpage_body"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="sumoplaceholderpage",
|
||||
name="page_ptr",
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name="SingleProductIndexPage",
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name="SumoPlaceholderPage",
|
||||
),
|
||||
]
|
|
@ -8,8 +8,6 @@ from kitsune.sumo.models import ModelBase
|
|||
from kitsune.sumo.urlresolvers import reverse
|
||||
from kitsune.sumo.utils import webpack_static
|
||||
|
||||
from wagtail.models import PreviewableMixin
|
||||
|
||||
HOT_TOPIC_SLUG = "hot"
|
||||
|
||||
|
||||
|
@ -29,7 +27,7 @@ class BaseProductTopic(ModelBase):
|
|||
abstract = True
|
||||
|
||||
|
||||
class Product(BaseProductTopic, PreviewableMixin):
|
||||
class Product(BaseProductTopic):
|
||||
codename = models.CharField(max_length=255, blank=True, default="")
|
||||
slug = models.SlugField()
|
||||
image = ImagePlusField(
|
|
@ -1,2 +0,0 @@
|
|||
from .models import * # noqa
|
||||
from .pages import * # noqa
|
|
@ -1,137 +0,0 @@
|
|||
from django.db import models
|
||||
from django.http import Http404
|
||||
|
||||
from kitsune.products.models import Product
|
||||
from kitsune.wiki.facets import topics_for
|
||||
from kitsune.wiki.utils import get_featured_articles
|
||||
|
||||
from typing import List
|
||||
|
||||
from wagtail import blocks
|
||||
from wagtail.fields import StreamField
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.models import Page
|
||||
from wagtail.snippets.blocks import SnippetChooserBlock
|
||||
|
||||
|
||||
class SumoPlaceholderPage(Page):
|
||||
"""A page used to allow for child pages to be created
|
||||
so we can have a proper Wagtail tree structure"""
|
||||
|
||||
settings_panels = Page.settings_panels + [
|
||||
FieldPanel("show_in_menus"),
|
||||
]
|
||||
content_panels = [
|
||||
FieldPanel("title"),
|
||||
FieldPanel("slug"),
|
||||
]
|
||||
|
||||
promote_panels: List[FieldPanel] = []
|
||||
preview_modes: List[Page.preview_modes] = []
|
||||
|
||||
is_placeholder = True
|
||||
|
||||
def serve(self, request):
|
||||
raise Http404
|
||||
|
||||
|
||||
# Define Blocks for Stream Fields
|
||||
# Wagtail: This is a StructBlock that allows selection of a Product Snippet
|
||||
class ProductSnippetBlock(blocks.StructBlock):
|
||||
"""Block for product snippets"""
|
||||
|
||||
product = SnippetChooserBlock(target_model="products.Product", required=True)
|
||||
|
||||
class Meta:
|
||||
template = "products/blocks/product_snippet_block.html"
|
||||
icon = "placeholder"
|
||||
label = "Product Card"
|
||||
|
||||
|
||||
class SearchBlock(blocks.StructBlock):
|
||||
"""Block for the search form"""
|
||||
|
||||
def get_context(self, value, parent_context=None):
|
||||
context = super().get_context(value, parent_context=parent_context)
|
||||
return context
|
||||
|
||||
class Meta:
|
||||
template = "products/blocks/search_block.html"
|
||||
icon = "search"
|
||||
label = "Search Form"
|
||||
|
||||
|
||||
class CTABlock(blocks.StructBlock):
|
||||
"""Block for the call to action"""
|
||||
|
||||
headline = blocks.CharBlock(required=True, max_length=255)
|
||||
details = blocks.RichTextBlock(required=True)
|
||||
link = blocks.URLBlock(required=True)
|
||||
type = blocks.ChoiceBlock(
|
||||
choices=[
|
||||
("Community", "Community"),
|
||||
("Paid", "Paid"),
|
||||
("Other", "Other"),
|
||||
]
|
||||
)
|
||||
|
||||
class Meta:
|
||||
template = "products/blocks/cta_block.html"
|
||||
icon = "plus-inverse"
|
||||
label = "Call to Action"
|
||||
|
||||
|
||||
class FeaturedArticlesBlock(blocks.StructBlock):
|
||||
"""Block for the featured articles"""
|
||||
|
||||
def get_context(self, value, parent_context=None):
|
||||
context = super().get_context(value, parent_context=parent_context)
|
||||
context["featured"] = get_featured_articles(product=context["product"])
|
||||
return context
|
||||
|
||||
class Meta:
|
||||
template = "products/blocks/featured_articles_block.html"
|
||||
icon = "doc-full-inverse"
|
||||
label = "Featured Articles"
|
||||
|
||||
|
||||
class FrequentTopicsBlock(blocks.StructBlock):
|
||||
"""Block for the frequent topics"""
|
||||
|
||||
def get_context(self, value, parent_context=None):
|
||||
context = super().get_context(value, parent_context=parent_context)
|
||||
context["topics"] = topics_for(
|
||||
user=context["user"], product=context["product"], parent=None
|
||||
)
|
||||
return context
|
||||
|
||||
class Meta:
|
||||
template = "products/blocks/frequent_topics_block.html"
|
||||
icon = "doc-full-inverse"
|
||||
label = "Frequent Topics"
|
||||
max = 1
|
||||
|
||||
|
||||
class SingleProductIndexPage(Page):
|
||||
"""A page representing a product"""
|
||||
|
||||
template = "products/product_wagtail.html"
|
||||
|
||||
product = models.ForeignKey(Product, on_delete=models.PROTECT, related_name="product_index")
|
||||
|
||||
body = StreamField(
|
||||
[
|
||||
("search", SearchBlock()),
|
||||
("cta", CTABlock()),
|
||||
("featured_articles", FeaturedArticlesBlock()),
|
||||
("product_snippet", ProductSnippetBlock()),
|
||||
("frequent_topics", FrequentTopicsBlock()),
|
||||
("text", blocks.RichTextBlock()),
|
||||
]
|
||||
)
|
||||
|
||||
content_panels = Page.content_panels + [FieldPanel("product"), FieldPanel("body")]
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Single Product Index"
|
||||
verbose_name_plural = "Single Product Indexes"
|
|
@ -1,74 +0,0 @@
|
|||
from django.http import Http404
|
||||
from django.test import RequestFactory
|
||||
|
||||
from wagtail.models import Page
|
||||
from wagtail.test.utils import WagtailPageTestCase
|
||||
from wagtail.views import serve as wagtail_serve
|
||||
|
||||
from kitsune.products.models import SingleProductIndexPage, SumoPlaceholderPage
|
||||
from kitsune.products.tests import ProductFactory
|
||||
|
||||
|
||||
class SumoCMSTests(WagtailPageTestCase):
|
||||
def test_can_create_dummy_page(self):
|
||||
"""Test that our page was created"""
|
||||
homepage = Page.objects.get(url_path="/")
|
||||
product_dummy = SumoPlaceholderPage(title="Product Dummy", slug="products")
|
||||
homepage.add_child(instance=product_dummy)
|
||||
|
||||
# See if it is now in the database
|
||||
retrieved = Page.objects.get(id=product_dummy.id)
|
||||
self.assertEqual(retrieved.title, "Product Dummy")
|
||||
|
||||
def test_can_create_product_index_page(self):
|
||||
"""Test that we can create a single product index page"""
|
||||
homepage = Page.objects.get(url_path="/")
|
||||
product_dummy = SumoPlaceholderPage(title="Product Dummy", slug="products")
|
||||
homepage.add_child(instance=product_dummy)
|
||||
test_product = ProductFactory(
|
||||
title="Firefox", slug="firefox", display_order=1, visible=True
|
||||
)
|
||||
product_index = SingleProductIndexPage(
|
||||
title="Firefox WT", slug="firefox", product=test_product
|
||||
)
|
||||
product_dummy.add_child(instance=product_index)
|
||||
|
||||
# See if it is now in the database
|
||||
retrieved = Page.objects.get(id=product_index.id)
|
||||
self.assertEqual(retrieved.title, "Firefox WT", "The titles should match")
|
||||
self.assertEqual(retrieved.slug, "firefox", "The slugs should match")
|
||||
|
||||
def test_can_serve_wt_product_index(self):
|
||||
"""Test that we can create a single product index page and serve it"""
|
||||
homepage = Page.objects.get(url_path="/")
|
||||
product_dummy = SumoPlaceholderPage(title="Product Dummy", slug="products")
|
||||
homepage.add_child(instance=product_dummy)
|
||||
test_product = ProductFactory(
|
||||
title="Firefox", slug="firefox", display_order=1, visible=True
|
||||
)
|
||||
product_index = SingleProductIndexPage(
|
||||
title="Firefox WT", slug="firefox", product=test_product
|
||||
)
|
||||
product_dummy.add_child(instance=product_index)
|
||||
|
||||
# Serve the page
|
||||
response = self.client.get("/en-US/products/firefox", follow=True)
|
||||
self.assertEqual(response.status_code, 200, "The page should be served successfully")
|
||||
|
||||
def test_placeholder_returns_404(self):
|
||||
"""Test that a placeholder page returns a 404"""
|
||||
homepage = Page.objects.get(url_path="/")
|
||||
product_dummy = SumoPlaceholderPage(title="Product Dummy", slug="products")
|
||||
homepage.add_child(instance=product_dummy)
|
||||
|
||||
# Try assertPageIsRenderable
|
||||
dummy_page = Page.objects.get(id=product_dummy.id)
|
||||
self.assertPageIsRenderable(dummy_page, accept_404=True)
|
||||
|
||||
# Serve the page
|
||||
request_factory = RequestFactory()
|
||||
request = request_factory.get("/en-US/products/")
|
||||
# Can't use test client here because it will follow the
|
||||
# redirect and return a 200
|
||||
with self.assertRaises(Http404):
|
||||
wagtail_serve(request, "/en-US/products/")
|
|
@ -7,7 +7,6 @@ from django.shortcuts import get_object_or_404, redirect, render
|
|||
from product_details import product_details
|
||||
|
||||
from kitsune.products.models import Product, Topic, TopicSlugHistory
|
||||
from kitsune.sumo.decorators import prefer_cms
|
||||
from kitsune.wiki.decorators import check_simple_wiki_locale
|
||||
from kitsune.wiki.facets import documents_for, topics_for
|
||||
from kitsune.wiki.models import Document, Revision
|
||||
|
@ -23,7 +22,6 @@ def product_list(request):
|
|||
|
||||
|
||||
@check_simple_wiki_locale
|
||||
@prefer_cms
|
||||
def product_landing(request, slug):
|
||||
"""The product landing page."""
|
||||
if slug == "firefox-accounts":
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
from wagtail.admin.panels import FieldPanel
|
||||
|
||||
from wagtail.snippets.models import register_snippet
|
||||
from wagtail.snippets.views.snippets import SnippetViewSet
|
||||
|
||||
from kitsune.products.models import Product
|
||||
|
||||
|
||||
class ProductViewSet(SnippetViewSet):
|
||||
model = Product
|
||||
panels = [
|
||||
FieldPanel("title"),
|
||||
FieldPanel("codename"),
|
||||
FieldPanel("slug"),
|
||||
FieldPanel("description"),
|
||||
FieldPanel("image"),
|
||||
FieldPanel("image_alternate"),
|
||||
FieldPanel("display_order"),
|
||||
FieldPanel("visible"),
|
||||
FieldPanel("platforms"),
|
||||
]
|
||||
|
||||
def get_preview_template(self, request, mode_name):
|
||||
return "products/product_card_preview.html"
|
||||
|
||||
|
||||
register_snippet(ProductViewSet)
|
|
@ -9,7 +9,6 @@ import re
|
|||
import dj_database_url
|
||||
import django_cache_url
|
||||
from decouple import Csv, config
|
||||
from wagtail.admin.localization import WAGTAILADMIN_PROVIDED_LANGUAGES
|
||||
|
||||
from kitsune.lib.sumo_locales import LOCALES
|
||||
|
||||
|
@ -447,10 +446,6 @@ TEMPLATES = [
|
|||
"django_jinja.builtins.extensions.StaticFilesExtension",
|
||||
"django_jinja.builtins.extensions.DjangoFiltersExtension",
|
||||
"jinja2.ext.i18n",
|
||||
"wagtail.jinja2tags.core",
|
||||
"wagtail.admin.jinja2tags.userbar",
|
||||
"wagtail.images.jinja2tags.images",
|
||||
"wagtail.contrib.settings.jinja2tags.settings",
|
||||
],
|
||||
"policies": {
|
||||
"ext.i18n.trimmed": True,
|
||||
|
@ -515,7 +510,6 @@ MIDDLEWARE: tuple[str, ...] = (
|
|||
"kitsune.users.middleware.LogoutInvalidatedSessionsMiddleware",
|
||||
"csp.middleware.CSPMiddleware",
|
||||
"dockerflow.django.middleware.DockerflowMiddleware",
|
||||
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
||||
)
|
||||
|
||||
# SecurityMiddleware settings
|
||||
|
@ -554,7 +548,6 @@ if READ_ONLY:
|
|||
AUTHENTICATION_BACKENDS = ("kitsune.sumo.readonlyauth.ReadOnlyBackend",)
|
||||
OIDC_ENABLE = False
|
||||
ENABLE_ADMIN = False
|
||||
WAGTAIL_ENABLE_ADMIN = False
|
||||
else:
|
||||
OIDC_ENABLE = config("OIDC_ENABLE", default=True, cast=bool)
|
||||
ENABLE_ADMIN = config("ENABLE_ADMIN", default=OIDC_ENABLE, cast=bool)
|
||||
|
@ -1315,51 +1308,3 @@ MOZILLA_LOCATION_SERVICE = config(
|
|||
"MOZILLA_LOCATION_SERVICE",
|
||||
default="https://location.services.mozilla.com/v1/country?key=fa6d7fc9-e091-4be1-b6c1-5ada5815ae9d", # noqa
|
||||
)
|
||||
|
||||
# Wagtail settings
|
||||
WAGTAIL_ENABLE = config("WAGTAIL_ENABLE", default=False, cast=bool)
|
||||
WAGTAIL_ENABLE_ADMIN = config("WAGTAIL_ENABLE_ADMIN", default=False, cast=bool)
|
||||
WAGTAIL_I18N_ENABLED = True
|
||||
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES
|
||||
WAGTAILADMIN_PERMITTED_LANGUAGES = [
|
||||
# Only include items in this list that SuMO supports and that are included
|
||||
# in wagtail.admin.localization.WAGTAILADMIN_PROVIDED_LANGUAGES. These are
|
||||
# only used by Wagtail for localizing its admin interface.
|
||||
("ar", "Arabic"),
|
||||
("ca", "Catalan"),
|
||||
("cs", "Czech"),
|
||||
("de", "German"),
|
||||
("el", "Greek"),
|
||||
("en", "English"),
|
||||
("es", "Spanish"),
|
||||
("et", "Estonian"),
|
||||
("fi", "Finnish"),
|
||||
("fr", "French"),
|
||||
("gl", "Galician"),
|
||||
("hr", "Croatian"),
|
||||
("hu", "Hungarian"),
|
||||
("id-id", "Indonesian"),
|
||||
("it", "Italian"),
|
||||
("ja", "Japanese"),
|
||||
("ko", "Korean"),
|
||||
("lt", "Lithuanian"),
|
||||
("nl", "Dutch"),
|
||||
("fa", "Persian"),
|
||||
("pl", "Polish"),
|
||||
("pt-br", "Brazilian Portuguese"),
|
||||
("pt-pt", "Portuguese"),
|
||||
("ro", "Romanian"),
|
||||
("ru", "Russian"),
|
||||
("sv", "Swedish"),
|
||||
("sk-sk", "Slovak"),
|
||||
("sl", "Slovenian"),
|
||||
("th", "Thai"),
|
||||
("tr", "Turkish"),
|
||||
("uk", "Ukrainian"),
|
||||
("zh-hans", "Chinese (Simplified)"),
|
||||
("zh-hant", "Chinese (Traditional)"),
|
||||
]
|
||||
WAGTAIL_SITE_NAME = config("WAGTAIL_SITE_NAME", default="Mozilla Support CMS")
|
||||
WAGTAILADMIN_BASE_URL = config("WAGTAILADMIN_BASE_URL", default="")
|
||||
WAGTAILIMAGES_MAX_UPLOAD_SIZE = IMAGE_MAX_FILESIZE
|
||||
WAGTAILDOCS_DOCUMENT_MODEL = "sumo.WagtailDocument"
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
import json
|
||||
import re
|
||||
from functools import wraps
|
||||
|
||||
from csp.utils import build_policy
|
||||
from django import http
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import Http404
|
||||
|
||||
from kitsune.sumo.utils import is_ratelimited
|
||||
|
||||
from wagtail.views import serve as wagtail_serve
|
||||
|
||||
|
||||
# Copy/pasta from from https://gist.github.com/1405096
|
||||
# TODO: Log the hell out of the exceptions.
|
||||
JSON = "application/json"
|
||||
|
@ -132,51 +126,3 @@ def skip_if_read_only_mode(fn):
|
|||
return fn(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def csp_allow_inline_scripts_and_styles(fn):
|
||||
"""
|
||||
Add a CSP header to the response of the decorated view that allows inline
|
||||
scripts and styles. The CSP header is created from the CSP values in the
|
||||
settings, and then updated to include the "'unsafe-inline'" source within
|
||||
both the "style-src" and "script-src" directives. The CSP header is inserted
|
||||
in the response so that the normal insertion of the header within the
|
||||
CSPMiddleware is bypassed. That, in turn, prevents the CSPMiddleware from
|
||||
adding the nonce sources, which would override the "'unsafe-inline'" sources
|
||||
and effectively cause them to be ignored.
|
||||
"""
|
||||
|
||||
@wraps(fn)
|
||||
def wrapped(*args, **kwargs):
|
||||
response = fn(*args, **kwargs)
|
||||
response["Content-Security-Policy"] = build_policy(
|
||||
update={
|
||||
"style-src": "'unsafe-inline'",
|
||||
"script-src": "'unsafe-inline'",
|
||||
}
|
||||
)
|
||||
return response
|
||||
|
||||
return wrapped
|
||||
|
||||
|
||||
def remove_locale(url):
|
||||
# Define the regex pattern for locale (e.g., /en-US/ or /en-us/)
|
||||
locale_pattern = r"^/([a-z]{2}(-[a-zA-Z]{2})?)/"
|
||||
# Remove the locale part
|
||||
return re.sub(locale_pattern, "/", url)
|
||||
|
||||
|
||||
def prefer_cms(view_func):
|
||||
@wraps(view_func)
|
||||
def _wrapped_view(request, *args, **kwargs):
|
||||
path = remove_locale(request.path_info)
|
||||
try:
|
||||
wagtail_response = wagtail_serve(request, path)
|
||||
if wagtail_response.status_code == 200:
|
||||
return wagtail_response
|
||||
except Http404:
|
||||
pass # Continue to the original view if no Wagtail page is found
|
||||
return view_func(request, *args, **kwargs)
|
||||
|
||||
return _wrapped_view
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# Generated by Django 4.2.16 on 2024-10-14 03:54
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("sumo", "0003_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.DeleteModel(
|
||||
name="WagtailDocument",
|
||||
),
|
||||
]
|
|
@ -1,2 +0,0 @@
|
|||
from .models import LocaleField, ModelBase # noqa
|
||||
from .pages import WagtailDocument # noqa
|
|
@ -1,5 +0,0 @@
|
|||
from wagtail.documents.models import AbstractDocument
|
||||
|
||||
|
||||
class WagtailDocument(AbstractDocument):
|
||||
pass
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "wagtailadmin/404.html" %}
|
||||
{% load sumo_tags %}
|
||||
|
||||
{% block branding_logo %}
|
||||
<img src="{% webpack_static 'sumo/img/mozilla-icon.png' %}" alt="{{ _("Mozilla Icon") }}"/>
|
||||
{% endblock %}
|
|
@ -1,63 +0,0 @@
|
|||
{% extends "wagtailadmin/admin_base.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% load sumo_tags %}
|
||||
|
||||
{% block branding_favicon %}
|
||||
<link rel="shortcut icon" href="{% webpack_static 'sumo/img/favicon.ico' %}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block branding_title %}{{ _("Mozilla Support") }}{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% include "entrypoints/wagtail.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script nonce="{{ request.csp_nonce }}">
|
||||
(function(document, window) {
|
||||
window.wagtailConfig = window.wagtailConfig || {};
|
||||
wagtailConfig.ADMIN_API = {
|
||||
PAGES: '{% url "wagtailadmin_api:pages:listing" %}',
|
||||
DOCUMENTS: '{% url "wagtailadmin_api:documents:listing" %}',
|
||||
IMAGES: '{% url "wagtailadmin_api:images:listing" %}',
|
||||
{# // Use this to add an extra query string on all API requests. #}
|
||||
{# // Example value: '&order=-id' #}
|
||||
EXTRA_CHILDREN_PARAMETERS: '',
|
||||
};
|
||||
|
||||
{% i18n_enabled as i18n_enabled %}
|
||||
{% locales as locales %}
|
||||
wagtailConfig.I18N_ENABLED = {% if i18n_enabled %}true{% else %}false{% endif %};
|
||||
wagtailConfig.LOCALES = {{ locales|safe }};
|
||||
|
||||
{% if locale %}
|
||||
wagtailConfig.ACTIVE_CONTENT_LOCALE = '{{ locale.language_code }}'
|
||||
{% endif %}
|
||||
|
||||
wagtailConfig.STRINGS = {% js_translation_strings %};
|
||||
|
||||
wagtailConfig.ADMIN_URLS = {
|
||||
PAGES: '{% url "wagtailadmin_explore_root" %}'
|
||||
};
|
||||
})(document, window);
|
||||
</script>
|
||||
{% wagtail_config as config %}
|
||||
{{ config|json_script:"wagtail-config" }}
|
||||
<script src="{% versioned_static 'wagtailadmin/js/vendor/jquery-3.6.0.min.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/vendor/jquery-ui-1.13.2.min.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/vendor/jquery.datetimepicker.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/vendor/bootstrap-transition.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/vendor/bootstrap-modal.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/vendor/tag-it.js' %}"></script>
|
||||
<script src="{% url 'wagtailadmin_javascript_catalog' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/core.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/vendor.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/wagtailadmin.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/telepath/telepath.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/sidebar.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/modal-workflow.js' %}"></script>
|
||||
|
||||
{% hook_output 'insert_global_admin_js' %}
|
||||
|
||||
{% block extra_js %}{% endblock %}
|
||||
{% endblock %}
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load sumo_tags %}
|
||||
|
||||
{% block branding_logo %}
|
||||
<img width="80" src="{% webpack_static 'sumo/img/mozilla-icon.png' %}" alt="{{ _("Mozilla Icon") }}"/>
|
||||
{% endblock %}
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "wagtailadmin/home.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block branding_welcome %}
|
||||
{{ _("Welcome to the Mozilla Support CMS") }}
|
||||
{% endblock %}
|
|
@ -1,39 +0,0 @@
|
|||
{% extends "wagtailadmin/admin_base.html" %}
|
||||
{% load i18n wagtailadmin_tags sumo_tags %}
|
||||
{% block titletag %}{{ _("Sign in") }}{% endblock %}
|
||||
{% block bodyclass %}login{% endblock %}
|
||||
|
||||
{% block furniture %}
|
||||
<main class="content-wrapper" id="main">
|
||||
<h1>
|
||||
{% block branding_login %}
|
||||
{{ _("Mozilla Support CMS") }}
|
||||
{% endblock %}
|
||||
</h1>
|
||||
|
||||
<div class="messages" role="status">
|
||||
{# Always show messages div so it can be appended to by JS #}
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li class="{{ message.tags }}">{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% block above_login %}{% endblock %}
|
||||
|
||||
<h2 class="sw-login-headline">
|
||||
<a href="{% url 'oidc_authentication_init' %}?next=/cms">{{ _("Sign in via SSO") }}</a>
|
||||
</h2>
|
||||
|
||||
{% block below_login %}{% endblock %}
|
||||
|
||||
{% block branding_logo %}
|
||||
<div class="login-logo">
|
||||
<img src="{% webpack_static 'sumo/img/mozilla-icon.png' %}" alt="{{ _("Mozilla Icon") }}"/>
|
||||
</div>
|
||||
{% endblock %}
|
||||
</main>
|
||||
{% endblock %}
|
|
@ -1,9 +0,0 @@
|
|||
{% spaceless %}
|
||||
<div class="w-hidden">
|
||||
<svg>
|
||||
<defs>
|
||||
{{ icons|safe }}
|
||||
</defs>
|
||||
</svg>
|
||||
</div>
|
||||
{% endspaceless %}
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "wagtailadmin/userbar/base.html" %}
|
||||
{% load sumo_tags %}
|
||||
|
||||
{% block branding_logo %}
|
||||
<img width="80" src="{% webpack_static 'sumo/img/mozilla-icon.png' %}" alt="{{ _("Mozilla Icon") }}"/>
|
||||
{% endblock %}
|
|
@ -11,7 +11,7 @@ from django.http import (
|
|||
JsonResponse,
|
||||
)
|
||||
from django.middleware.csrf import get_token
|
||||
from django.shortcuts import redirect, render
|
||||
from django.shortcuts import render
|
||||
from django.utils import translation
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.decorators.cache import never_cache
|
||||
|
@ -151,12 +151,3 @@ def serve_cors(*args, **kwargs):
|
|||
from django.views.static import serve
|
||||
|
||||
return serve(*args, **kwargs)
|
||||
|
||||
|
||||
def cms_login(request):
|
||||
"""The login view for the Wagtail CMS."""
|
||||
# If user is already logged-in and has permission, redirect them to the CMS dashboard.
|
||||
if request.user.is_authenticated and request.user.has_perm("wagtailadmin.access_admin"):
|
||||
return redirect(get_next_url(request) or reverse("wagtailadmin_home"))
|
||||
|
||||
return render(request, "wagtailadmin/login.html")
|
||||
|
|
|
@ -5,13 +5,9 @@ from django.views.generic.base import RedirectView
|
|||
from django.views.static import serve as servestatic
|
||||
from graphene_django.views import GraphQLView
|
||||
from waffle.views import wafflejs
|
||||
from wagtail import urls as wagtail_urls
|
||||
from wagtail.admin.urls import urlpatterns as wagtail_admin_urlpatterns
|
||||
from wagtail.utils.urlpatterns import decorate_urlpatterns
|
||||
|
||||
from kitsune.dashboards.api import WikiMetricList
|
||||
from kitsune.sumo import views as sumo_views
|
||||
from kitsune.sumo.decorators import csp_allow_inline_scripts_and_styles
|
||||
from kitsune.sumo.i18n import i18n_patterns
|
||||
|
||||
# Note: This must come before importing admin because it patches the
|
||||
|
@ -38,7 +34,6 @@ urlpatterns = i18n_patterns(
|
|||
path("announcements/", include("kitsune.announcements.urls")),
|
||||
path("community/", include("kitsune.community.urls")),
|
||||
path("badges/", include("kitsune.kbadge.urls")),
|
||||
path("documents/", include("wagtail.documents.urls")),
|
||||
path("locales", sumo_views.locales, name="sumo.locales"),
|
||||
path("", include("kitsune.products.urls")),
|
||||
path("", include("kitsune.dashboards.urls")),
|
||||
|
@ -51,21 +46,6 @@ urlpatterns = i18n_patterns(
|
|||
if settings.OIDC_ENABLE:
|
||||
urlpatterns.append(path("", include("kitsune.users.urls_oidc")))
|
||||
|
||||
if settings.WAGTAIL_ENABLE_ADMIN:
|
||||
urlpatterns.append(path("cms/login/", sumo_views.cms_login, name="wagtailadmin_login"))
|
||||
urlpatterns.append(
|
||||
path(
|
||||
"cms/",
|
||||
include(
|
||||
decorate_urlpatterns(
|
||||
wagtail_admin_urlpatterns, csp_allow_inline_scripts_and_styles
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
if settings.WAGTAIL_ENABLE:
|
||||
urlpatterns += i18n_patterns(path("", include(wagtail_urls)))
|
||||
|
||||
urlpatterns += [
|
||||
path("1/", include("kitsune.inproduct.urls")),
|
||||
|
|
|
@ -5003,13 +5003,13 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess
|
|||
|
||||
[[package]]
|
||||
name = "wagtail"
|
||||
version = "6.1.3"
|
||||
version = "6.2.2"
|
||||
description = "A Django content management system."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "wagtail-6.1.3-py3-none-any.whl", hash = "sha256:b6c4d5705adf51a5e49ea416032dd0a6534588fc31c5c9a95f698e6ddec0a203"},
|
||||
{file = "wagtail-6.1.3.tar.gz", hash = "sha256:8f4908ab1b6b963a8aa7adf8f0ec738cd1dc79b9816c6d5f59018f600a404378"},
|
||||
{file = "wagtail-6.2.2-py3-none-any.whl", hash = "sha256:d0382603aef5d7e4a46529aa125857774a317c2870c9b6836767932969829429"},
|
||||
{file = "wagtail-6.2.2.tar.gz", hash = "sha256:506ac2b59dae85069ae754b45bc13b91cbd86e92d4f5d663658773b0ed7a16b9"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
@ -5019,7 +5019,7 @@ Django = ">=4.2,<6.0"
|
|||
django-filter = ">=23.3,<25"
|
||||
django-modelcluster = ">=6.2.1,<7.0"
|
||||
django-permissionedforms = ">=0.1,<1.0"
|
||||
django-taggit = ">=4.0,<5.1"
|
||||
django-taggit = ">=5.0,<5.1"
|
||||
django-treebeard = ">=4.5.1,<5.0"
|
||||
djangorestframework = ">=3.15.1,<4.0"
|
||||
draftjs-exporter = ">=2.1.5,<6.0"
|
||||
|
@ -5032,7 +5032,7 @@ telepath = ">=0.3.1,<1"
|
|||
Willow = {version = ">=1.8.0,<2", extras = ["heif"]}
|
||||
|
||||
[package.extras]
|
||||
docs = ["Sphinx (>=1.5.2)", "myst-parser (==2.0.0)", "pyenchant (>=3.1.1,<4)", "sphinx-autobuild (>=0.6.0)", "sphinx-copybutton (>=0.5,<1.0)", "sphinx-wagtail-theme (==6.3.0)", "sphinxcontrib-spelling (>=7,<8)"]
|
||||
docs = ["Sphinx (>=7.0)", "myst-parser (==2.0.0)", "pyenchant (>=3.1.1,<4)", "sphinx-autobuild (>=0.6.0)", "sphinx-copybutton (>=0.5,<1.0)", "sphinx-wagtail-theme (==6.3.0)", "sphinxcontrib-spelling (>=7,<8)"]
|
||||
testing = ["Jinja2 (>=3.0,<3.2)", "azure-mgmt-cdn (>=12.0,<13.0)", "azure-mgmt-frontdoor (>=1.0,<1.1)", "boto3 (>=1.28,<2)", "coverage (>=3.7.0)", "curlylint (==0.13.1)", "django-pattern-library (>=0.7)", "djhtml (==3.0.6)", "doc8 (==0.8.1)", "factory-boy (>=3.2)", "freezegun (>=0.3.8)", "polib (>=1.1,<2.0)", "python-dateutil (>=2.7)", "pytz (>=2014.7)", "ruff (==0.1.5)", "semgrep (==1.40.0)", "tblib (>=2.0,<3.0)"]
|
||||
|
||||
[[package]]
|
||||
|
@ -5362,4 +5362,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "e53420ab41b77037f210be0d958e7f4d8a4642f76445f2f56afce3547784bb0d"
|
||||
content-hash = "8d55513b8828663aad4b50c78c5b9fed62ed244441d570d7808ce1c2f5caa701"
|
||||
|
|
|
@ -88,7 +88,7 @@ mkdocs-material = "^9.5.3"
|
|||
dockerflow = "^2022.8.0"
|
||||
google-analytics-data = "0.18.7"
|
||||
pyparsing = "3.1.2"
|
||||
wagtail = "6.1.3"
|
||||
wagtail = "6.2.2"
|
||||
wagtail-localize = "1.9"
|
||||
django-silk = "^5.1.0"
|
||||
requests = "^2.32.3"
|
||||
|
|
|
@ -10,8 +10,8 @@ module.exports = Object.keys(entrypoints).map(entry =>
|
|||
chunks: [entry],
|
||||
inject: false,
|
||||
scriptLoading: "defer",
|
||||
templateContent: ({htmlWebpackPlugin}) => {
|
||||
if ((entry == "screen") || (entry == "wagtail")) {
|
||||
templateContent: ({ htmlWebpackPlugin }) => {
|
||||
if (entry == "screen") {
|
||||
return `<link href="${htmlWebpackPlugin.files.css[0]}" rel="stylesheet" nonce="{{ request.csp_nonce }}">`;
|
||||
}
|
||||
// inject nonce in the script for django-csp to populate
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const entrypoints = {
|
||||
screen: ["sumo/scss/screen.scss"],
|
||||
wagtail: ["sumo/scss/wagtail.scss"],
|
||||
common: [
|
||||
"sumo/js/i18n.js",
|
||||
"sumo/js/kbox.js",
|
||||
|
|
Загрузка…
Ссылка в новой задаче