コード例 #1
0
def register_account_preferred_language_preferences(request):
    if len(get_available_admin_languages()) > 1:
        return {
            'url': reverse('wagtailadmin_account_language_preferences'),
            'label': _('Language preferences'),
            'help_text': _('Choose the language you want to use here.'),
        }
コード例 #2
0
def _add12hrFormats():
    # Time12hrInput will not work unless django.forms.fields.TimeField
    # can process 12hr times, so sneak them into the default and all the
    # selectable locales that define TIME_INPUT_FORMATS.

    # strptime does not accept %P, %p is for both cases here.
    _12hrFormats = ['%I:%M%p', # 2:30pm
                    '%I%p']    # 7am

    # TIME_INPUT_FORMATS is defined in django.conf.global_settings if not
    # by the user's local settings.
    if (_12hrFormats[0] not in settings.TIME_INPUT_FORMATS or
        _12hrFormats[1] not in settings.TIME_INPUT_FORMATS):
        settings.TIME_INPUT_FORMATS += _12hrFormats

    # As at 2019-06-13 none of the built-in locales define TIME_INPUT_FORMATS
    # but a user-defined locale could or it could be added to a built-in one.
    langCodes = [language[0] for language in get_available_admin_languages()]
    langCodes.append(settings.LANGUAGE_CODE)
    for lang in langCodes:
        for module in get_format_modules(lang):
            inputFormats = getattr(module, 'TIME_INPUT_FORMATS', None)
            if (inputFormats is not None and
                (_12hrFormats[0] not in inputFormats or
                 _12hrFormats[1] not in inputFormats)):
                inputFormats += _12hrFormats
コード例 #3
0
ファイル: wagtail_hooks.py プロジェクト: bbusenius/wagtail
def register_account_preferred_language_preferences(request):
    if len(get_available_admin_languages()) > 1:
        return {
            'url': reverse('wagtailadmin_account_language_preferences'),
            'label': _('Language preferences'),
            'help_text': _('Choose the language you want to use here.'),
        }
コード例 #4
0
def account(request):
    user_perms = UserPagePermissionsProxy(request.user)
    show_notification_preferences = user_perms.can_edit_pages() or user_perms.can_publish_pages()

    return render(request, 'wagtailadmin/account/account.html', {
        'show_change_password': password_management_enabled() and request.user.has_usable_password(),
        'show_notification_preferences': show_notification_preferences,
        'show_preferred_language_preferences': len(get_available_admin_languages()) > 1
    })
コード例 #5
0
ファイル: forms.py プロジェクト: gaurav476/Blog_Website
class PreferredLanguageForm(forms.ModelForm):
    preferred_language = forms.ChoiceField(
        required=False,
        choices=lambda: sorted(BLANK_CHOICE_DASH + get_available_admin_languages(), key=lambda l: l[1])
    )

    class Meta:
        model = UserProfile
        fields = ("preferred_language",)
コード例 #6
0
def account(request):
    user_perms = UserPagePermissionsProxy(request.user)
    show_notification_preferences = user_perms.can_edit_pages(
    ) or user_perms.can_publish_pages()

    return render(
        request, 'wagtailadmin/account/account.html', {
            'show_change_password':
            password_management_enabled()
            and request.user.has_usable_password(),
            'show_notification_preferences':
            show_notification_preferences,
            'show_preferred_language_preferences':
            len(get_available_admin_languages()) > 1
        })
コード例 #7
0
 def test_available_admin_languages_by_default(self):
     self.assertListEqual(get_available_admin_languages(),
                          WAGTAILADMIN_PROVIDED_LANGUAGES)
コード例 #8
0
 def test_available_admin_languages_with_permitted_languages(self):
     self.assertListEqual(get_available_admin_languages(),
                          [('en', 'English'), ('es', 'Spanish')])
コード例 #9
0
 def test_available_admin_languages_by_default(self):
     self.assertListEqual(get_available_admin_languages(), WAGTAILADMIN_PROVIDED_LANGUAGES)
コード例 #10
0
 def test_available_admin_languages_with_permitted_languages(self):
     self.assertListEqual(get_available_admin_languages(), [('en', 'English'), ('es', 'Spanish')])
コード例 #11
0
def _get_language_choices():
    return sorted(BLANK_CHOICE_DASH + get_available_admin_languages(),
                  key=lambda l: l[1].lower())
コード例 #12
0
ファイル: forms.py プロジェクト: bbusenius/wagtail
def _get_language_choices():
    return sorted(BLANK_CHOICE_DASH + get_available_admin_languages(),
                  key=lambda l: l[1].lower())