-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into TP1-1034-fundriseup-donations-gtm
- Loading branch information
Showing
23 changed files
with
241 additions
and
139 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
18 changes: 18 additions & 0 deletions
18
network-api/networkapi/templates/tags/multipage_menu_link_note.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% load i18n %} | ||
|
||
{% with class="tw-text-red-80 tw-text-sm tw-ml-1" %} | ||
{% comment %}These notes are internal facing only. Only logged in users can see them.{% endcomment %} | ||
|
||
{% if menu_entry.restriction == "login" %} | ||
<span class="{{ class }}">(logged in users only)</span> | ||
{% elif menu_entry.restriction == "groups" %} | ||
<span class="{{ class }}">(restricted to specific groups)</span> | ||
{% elif menu_entry.restriction == "password" %} | ||
<span class="{{ class }}">(password protected)</span> | ||
{% endif %} | ||
|
||
{% if not menu_entry.page.live %} | ||
<span class="{{ class }}">(draft)</span> | ||
{% endif %} | ||
|
||
{% endwith %} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,14 @@ | ||
import functools | ||
from django.utils.translation import trans_real | ||
|
||
import django | ||
from django.utils.translation.trans_real import accept_language_re | ||
from .override_utils import parse_accept_lang_header, to_language | ||
|
||
# WARNING: this is not necessarily a good idea, but is the only way to override | ||
# Django's default behaviour of requiring language codes to be lowercased. | ||
# We have to modify the core Django method, because we have no way to replace | ||
# all the core functionality that relies on this - e.g., url resolvers that | ||
# the Django admin and third party apps use. | ||
# A fix upstream has been asked in https://code.djangoproject.com/ticket/31795 | ||
|
||
|
||
def language_code_to_iso_3166(language): | ||
"""Turn a language name (en-us) into an ISO 3166 format (en-US).""" | ||
language, _, country = language.lower().partition("-") | ||
if country: | ||
return f"{language}-{country.upper()}" | ||
return language | ||
|
||
|
||
def to_language(locale): | ||
"""Turn a locale name (en_US) into a language name (en-US).""" | ||
return locale.replace("_", "-") | ||
|
||
|
||
@functools.lru_cache(maxsize=1000) | ||
def parse_accept_lang_header(lang_string): | ||
""" | ||
Parse the lang_string, which is the body of an HTTP Accept-Language | ||
header, and return a tuple of (lang, q-value), ordered by 'q' values. | ||
Return an empty tuple if there are any format errors in lang_string. | ||
""" | ||
result = [] | ||
pieces = accept_language_re.split(lang_string.lower()) | ||
if pieces[-1]: | ||
return () | ||
for i in range(0, len(pieces) - 1, 3): | ||
first, lang, priority = pieces[i : i + 3] | ||
if first: | ||
return () | ||
if priority: | ||
priority = float(priority) | ||
else: | ||
priority = 1.0 | ||
result.append((language_code_to_iso_3166(lang), priority)) | ||
result.sort(key=lambda k: k[1], reverse=True) | ||
return tuple(result) | ||
|
||
|
||
# Replace some functions in django.utils.translation.trans_real with our own | ||
# versions that support a language in the form en-US instead of en-us. | ||
django.utils.translation.trans_real.to_language = to_language | ||
django.utils.translation.trans_real.parse_accept_lang_header = parse_accept_lang_header | ||
trans_real.to_language = to_language | ||
trans_real.parse_accept_lang_header = parse_accept_lang_header |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import functools | ||
|
||
from django.utils.translation.trans_real import accept_language_re | ||
|
||
|
||
def language_code_to_iso_3166(language): | ||
"""Turn a language name (en-us) into an ISO 3166 format (en-US).""" | ||
language, _, country = language.lower().partition("-") | ||
if country: | ||
return f"{language}-{country.upper()}" | ||
return language | ||
|
||
|
||
def to_language(locale): | ||
"""Turn a locale name (en_US) into a language name (en-US).""" | ||
return locale.replace("_", "-") | ||
|
||
|
||
@functools.lru_cache(maxsize=1000) | ||
def parse_accept_lang_header(lang_string): | ||
""" | ||
Parse the lang_string, which is the body of an HTTP Accept-Language | ||
header, and return a tuple of (lang, q-value), ordered by 'q' values. | ||
Return an empty tuple if there are any format errors in lang_string. | ||
""" | ||
result = [] | ||
pieces = accept_language_re.split(lang_string.lower()) | ||
if pieces[-1]: | ||
return () | ||
for i in range(0, len(pieces) - 1, 3): | ||
first, lang, priority = pieces[i : i + 3] | ||
if first: | ||
return () | ||
if priority: | ||
priority = float(priority) | ||
else: | ||
priority = 1.0 | ||
result.append((language_code_to_iso_3166(lang), priority)) | ||
result.sort(key=lambda k: k[1], reverse=True) | ||
return tuple(result) |
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.