kopia lustrzana https://github.com/jointakahe/takahe
Add identity setting for default post language
rodzic
cec04e8ddb
commit
32216315aa
|
@ -428,7 +428,7 @@ class Preferences(Schema):
|
|||
identity.config_identity.default_post_visibility
|
||||
],
|
||||
"posting:default:sensitive": False,
|
||||
"posting:default:language": None,
|
||||
"posting:default:language": identity.config_identity.preferred_posting_language,
|
||||
"reading:expand:media": "default",
|
||||
"reading:expand:spoilers": identity.config_identity.expand_content_warnings,
|
||||
}
|
||||
|
|
|
@ -286,6 +286,7 @@ class Config(models.Model):
|
|||
visible_reaction_counts: bool = True
|
||||
expand_content_warnings: bool = False
|
||||
boosts_on_profile: bool = True
|
||||
preferred_posting_language: str | None = None
|
||||
|
||||
class DomainOptions(pydantic.BaseModel):
|
||||
site_name: str = ""
|
||||
|
|
|
@ -16,6 +16,7 @@ httpx~=0.23
|
|||
markdown_it_py~=2.1.0
|
||||
pillow~=9.3.0
|
||||
psycopg~=3.1.8
|
||||
pycountry~=22.3.5
|
||||
pydantic~=1.10.2
|
||||
pyld~=2.0.3
|
||||
pylibmc~=1.6.3
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import pycountry
|
||||
|
||||
from activities.models.post import Post
|
||||
from users.views.settings.settings_page import SettingsPage
|
||||
|
||||
|
@ -15,8 +17,24 @@ class PostingPage(SettingsPage):
|
|||
"title": "Expand content warnings",
|
||||
"help_text": "If content warnings should be expanded by default (not honoured by all clients)",
|
||||
},
|
||||
"preferred_posting_language": {
|
||||
"title": "Default posting language",
|
||||
"help_text": "",
|
||||
"choices": sorted(
|
||||
[
|
||||
(lang.alpha_2, lang.name)
|
||||
for lang in pycountry.languages
|
||||
if hasattr(lang, "alpha_2")
|
||||
],
|
||||
key=lambda lang: lang[1],
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
layout = {
|
||||
"Posting": ["default_post_visibility", "expand_content_warnings"],
|
||||
"Posting": [
|
||||
"default_post_visibility",
|
||||
"expand_content_warnings",
|
||||
"preferred_posting_language",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class SettingsPage(FormView):
|
|||
options_class = Config.IdentityOptions
|
||||
template_name = "settings/settings.html"
|
||||
section: ClassVar[str]
|
||||
options: dict[str, dict[str, str | int]]
|
||||
options: dict[str, dict[str, str | int | list[tuple[int | str, str]]]]
|
||||
layout: dict[str, list[str]]
|
||||
|
||||
def get_form_class(self):
|
||||
|
@ -42,7 +42,11 @@ class SettingsPage(FormView):
|
|||
elif config_field.type_ is UploadedImage:
|
||||
form_field = forms.ImageField
|
||||
elif config_field.type_ is str:
|
||||
if details.get("display") == "textarea":
|
||||
choices = details.get("choices")
|
||||
if choices:
|
||||
field_kwargs["widget"] = forms.Select(choices=choices)
|
||||
form_field = forms.CharField
|
||||
elif details.get("display") == "textarea":
|
||||
form_field = partial(
|
||||
forms.CharField,
|
||||
widget=forms.Textarea,
|
||||
|
|
Ładowanie…
Reference in New Issue