This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import re | |
| import uuid | |
| from django.db import connection | |
| from core.logging import logger | |
| from .utils import ( | |
| get_document_by_import_id, | |
| get_image_by_import_id, | |
| load_page_by_import_id, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| class RobotsTxtMixin(models.Model): | |
| """ | |
| Always mix this class in BEFORE wagtailcore.Page. Otherwise, its override of get_sitemap_urls() won't get called. | |
| """ | |
| hide_from_search_engines = models.BooleanField( | |
| default=False, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## within our "create_site" method, we make an admin and editor group for each site. | |
| ## This method has already created a collecton named for the site | |
| admins = Group.objects.create(name=f'{site.hostname} Admins') | |
| apply_default_permissions(admins, site, 'admin') | |
| admins.save() | |
| editors = Group.objects.create(name=f'{site.hostname} Editors') | |
| apply_default_permissions(editors, site, 'editor') | |
| editors.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################################################# | |
| # Patch the wagtail.admin.views.pages.search.search method to filter by the current site. | |
| # I asked Torchbox to add a hook that would let us delete this patch: https://github.com/wagtail/wagtail/issues/6235 | |
| # 2020-09-03 cnk: updated to work with 2.11a | |
| ################################################################################################################# | |
| @vary_on_headers('X-Requested-With') | |
| @user_passes_test(user_has_any_page_permission) | |
| def single_site_search(request): | |
| # BEGIN PATCH | |
| pages = all_pages = Page.objects.in_site(Site.find_for_request(request)).prefetch_related('content_type').specific() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import forms | |
| from django.conf import settings | |
| from django.urls import re_path | |
| from django.contrib.admin.utils import quote, unquote | |
| from django.core.exceptions import PermissionDenied | |
| from django.core.validators import MinLengthValidator | |
| from django.db import models | |
| from django.http import JsonResponse, HttpResponseNotAllowed | |
| from django.shortcuts import get_object_or_404 | |
| from django.template.loader import render_to_string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source 'https://rubygems.org' | |
| gem 'github-pages', group: :jekyll_plugins |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| frontend | | |
| frontend | > [email protected] start /code/wagtail | |
| frontend | > npm run watch | |
| frontend | | |
| frontend | | |
| frontend | > [email protected] watch /code/wagtail | |
| frontend | > npm-run-all --parallel gulp:dev:watch webpack:dev:watch | |
| frontend | | |
| web | Watching for file changes with StatReloader | |
| web | Performing system checks... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NewsPageForm(WagtailAdminPageForm): | |
| """ | |
| This form exists to make the Summary, Header, and Body fields optional if the external_url field is populated. | |
| """ | |
| def clean(self): | |
| cleaned_data = super().clean() | |
| # If there's an external_url, remove any errors that might have been added for the summary, header, and body. | |
| if cleaned_data.get('external_url'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################################################# | |
| # Patch the wagtail.admin.forms.pages.PageViewRestrictionForm class to filter groups to only those available | |
| # to the current site. | |
| ################################################################################################################# | |
| def page_view_restriction_init(self, *args, **kwargs): | |
| super(PageViewRestrictionForm, self).__init__(*args, **kwargs) | |
| self.fields['groups'].widget = forms.CheckboxSelectMultiple() | |
| # BEGIN PATCH | |
| current_site = Site.find_for_request(get_current_request()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################################################# | |
| # Patch the wagtaildocs.views.documents.edit view so that we keep the same file name if the user uploads a replacement | |
| # with the same filename. The default appends 7 random characters to make the filename unique, which changes the URL. | |
| # 2020-07-10 rrollins: Works with Wagtail 2.9. | |
| # 2020-09-03 cnk: should work with Wagtail 2.11a | |
| # ################################################################################################################# | |
| @permission_checker.require('change') | |
| def edit_without_changing_filename(request, document_id): | |
| Document = get_document_model() | |
| DocumentForm = get_document_form(Document) |