Skip to content
Snippets Groups Projects
Commit 19a4ddd5 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '261-allow-site-local-configuration-of-available-languages' into 'master'

Resolve "Allow site-local configuration of available languages"

Closes #261

See merge request AlekSIS/official/AlekSIS!381
parents 5af9f95a c1e5cebd
No related branches found
No related tags found
1 merge request!381Resolve "Allow site-local configuration of available languages"
Pipeline #4286 passed
from django.conf import settings
from django.forms import EmailField, ImageField, URLField
from django.forms.widgets import SelectMultiple
from django.utils.translation import gettext_lazy as _
from dynamic_preferences.preferences import Section
......@@ -22,6 +23,7 @@ notification = Section("notification")
footer = Section("footer")
account = Section("account")
auth = Section("auth", verbose_name=_("Authentication"))
internationalisation = Section("internationalisation", verbose_name=_("Internationalisation"))
@site_preferences_registry.register
......@@ -196,3 +198,14 @@ class AuthenticationBackends(MultipleChoicePreference):
def get_choices(self):
return [(b, b) for b in settings.CUSTOM_AUTHENTICATION_BACKENDS]
@site_preferences_registry.register
class AvailableLanguages(MultipleChoicePreference):
section = internationalisation
name = "languages"
default = [code[0] for code in settings.LANGUAGES]
widget = SelectMultiple
verbose_name = _("Available languages")
field_attribute = {"initial": []}
choices = settings.LANGUAGES
......@@ -8,8 +8,7 @@
<input name="next" type="hidden" value="{{ request.get_full_path }}">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% get_language_info_list for request.site.preferences.internationalisation__languages as languages %}
{# Select #}
<div class="input-field language-field">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment