@@ -14,6 +14,7 @@
Loading
14 14
from django.template.loader import render_to_string
15 15
from django.templatetags.static import static
16 16
from django.utils import timezone
17 +
from django.utils.encoding import force_str
17 18
from django.utils.html import avoid_wrapping, format_html, format_html_join
18 19
from django.utils.safestring import mark_safe
19 20
from django.utils.timesince import timesince
@@ -27,7 +28,7 @@
Loading
27 28
from wagtail.admin.staticfiles import versioned_static as versioned_static_func
28 29
from wagtail.core import hooks
29 30
from wagtail.core.models import (
30 -
    Collection, CollectionViewRestriction, Page, PageLogEntry, PageViewRestriction,
31 +
    Collection, CollectionViewRestriction, Locale, Page, PageLogEntry, PageViewRestriction,
31 32
    UserPagePermissionsProxy)
32 33
from wagtail.core.utils import accepts_kwarg, camelcase_to_underscore
33 34
from wagtail.core.utils import cautious_slugify as _cautious_slugify
@@ -637,3 +638,19 @@
Loading
637 638
        # we were passed None or something else that isn't a valid user object; return
638 639
        # empty string to replicate the behaviour of {{ user.get_full_name|default:user.get_username }}
639 640
        return ''
641 +
642 +
643 +
@register.simple_tag
644 +
def i18n_enabled():
645 +
    return getattr(settings, 'WAGTAIL_I18N_ENABLED', False)
646 +
647 +
648 +
@register.simple_tag
649 +
def locales():
650 +
    return json.dumps([
651 +
        {
652 +
            'code': locale.language_code,
653 +
            'display_name': force_str(locale.get_display_name()),
654 +
        }
655 +
        for locale in Locale.objects.all()
656 +
    ])

@@ -184,7 +184,7 @@
Loading
184 184
            reverse('wagtailsnippets:list', args=['tests', 'advert'])
185 185
        )
186 186
187 -
        self.assertNotContains(response, 'French')
187 +
        self.assertNotContains(response, 'aria-label="French" class="u-link is-live">')
188 188
189 189
        # Check that the add URLs don't include the locale
190 190
        add_url = reverse('wagtailsnippets:add', args=['tests', 'advert'])
@@ -715,6 +715,9 @@
Loading
715 715
class TestLocaleSelectorOnEdit(BaseTestSnippetEditView):
716 716
    fixtures = ['test.json']
717 717
718 +
    LOCALE_SELECTOR_HTML = '<a href="javascript:void(0)" aria-label="English" class="c-dropdown__button  u-btn-current">'
719 +
    LOCALE_INDICATOR_HTML = '<use href="#icon-site"></use></svg>\n    English'
720 +
718 721
    def setUp(self):
719 722
        super().setUp()
720 723
        self.test_snippet = TranslatableSnippet.objects.create(text="This is a test")
@@ -725,7 +728,7 @@
Loading
725 728
    def test_locale_selector(self):
726 729
        response = self.get()
727 730
728 -
        self.assertContains(response, 'English')
731 +
        self.assertContains(response, self.LOCALE_SELECTOR_HTML)
729 732
730 733
        switch_to_french_url = reverse('wagtailsnippets:edit', args=['snippetstests', 'translatablesnippet', quote(self.test_snippet_fr.pk)])
731 734
        self.assertContains(response, f'<a href="{switch_to_french_url}" aria-label="French" class="u-link is-live">')
@@ -735,7 +738,7 @@
Loading
735 738
736 739
        response = self.get()
737 740
738 -
        self.assertContains(response, 'English')
741 +
        self.assertContains(response, self.LOCALE_INDICATOR_HTML)
739 742
740 743
        switch_to_french_url = reverse('wagtailsnippets:edit', args=['snippetstests', 'translatablesnippet', quote(self.test_snippet_fr.pk)])
741 744
        self.assertNotContains(response, f'<a href="{switch_to_french_url}" aria-label="French" class="u-link is-live">')
@@ -744,7 +747,7 @@
Loading
744 747
    def test_locale_selector_not_present_when_i18n_disabled(self):
745 748
        response = self.get()
746 749
747 -
        self.assertNotContains(response, 'English')
750 +
        self.assertNotContains(response, self.LOCALE_SELECTOR_HTML)
748 751
749 752
        switch_to_french_url = reverse('wagtailsnippets:edit', args=['snippetstests', 'translatablesnippet', quote(self.test_snippet_fr.pk)])
750 753
        self.assertNotContains(response, f'<a href="{switch_to_french_url}" aria-label="French" class="u-link is-live">')
@@ -754,7 +757,7 @@
Loading
754 757
755 758
        response = self.get()
756 759
757 -
        self.assertNotContains(response, 'English')
760 +
        self.assertNotContains(response, self.LOCALE_SELECTOR_HTML)
758 761
        self.assertNotContains(response, 'aria-label="French" class="u-link is-live">')
759 762
760 763
Files Coverage
wagtail 90.60%
Project Totals (395 files) 90.60%
15787.11
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-djmaster-postgres-noelasticsearch
backend
15787.12
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=py36-dj22-sqlite-elasticsearch2
backend
15787.14
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=py37-dj22-postgres-elasticsearch6
backend
15787.13
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=py36-dj22-postgres-elasticsearch5
backend
15787.16
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj30-postgres-elasticsearch7
backend
15787.15
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj22-postgres-elasticsearch7
backend
15787.18
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj31-postgres-elasticsearch7-emailuser
backend
15787.17
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj31-postgres-elasticsearch7
backend
15787.2
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=py36-dj22-postgres-noelasticsearch
backend
15787.1
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=py36-dj22-mysql-noelasticsearch
backend
15787.4
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=py37-dj30-sqlite-noelasticsearch
backend
15787.3
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=py37-dj22-sqlite-noelasticsearch
backend
15787.6
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj30-postgres-noelasticsearch
backend
15787.5
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=py37-dj30-mysql-noelasticsearch
backend
15787.8
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj31-postgres-noelasticsearch-emailuser
backend
15787.7
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj31-postgres-noelasticsearch
backend
15787.10
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj31stable-postgres-noelasticsearch
backend
15787.9
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py38-dj31-postgres-noelasticsearch-notz
backend
1
codecov:
2
  notify:
3
    after_n_builds: 10
4
    require_ci_to_pass: no
5

6
coverage:
7
  status:
8
    project: off
9
    patch: off
10

11
comment: off
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.