2022-11-18 07:09:04 +00:00
|
|
|
from django.utils.decorators import method_decorator
|
|
|
|
|
|
|
|
from core.models import Config
|
|
|
|
from users.decorators import admin_required
|
|
|
|
from users.views.settings import SettingsPage
|
|
|
|
|
|
|
|
|
|
|
|
@method_decorator(admin_required, name="dispatch")
|
|
|
|
class AdminSettingsPage(SettingsPage):
|
|
|
|
"""
|
|
|
|
Shows a settings page dynamically created from our settings layout
|
|
|
|
at the bottom of the page. Don't add this to a URL directly - subclass!
|
|
|
|
"""
|
|
|
|
|
|
|
|
options_class = Config.SystemOptions
|
|
|
|
|
|
|
|
def load_config(self):
|
|
|
|
return Config.load_system()
|
|
|
|
|
|
|
|
def save_config(self, key, value):
|
|
|
|
Config.set_system(key, value)
|
|
|
|
|
|
|
|
|
|
|
|
class BasicSettings(AdminSettingsPage):
|
|
|
|
|
|
|
|
section = "basic"
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"site_name": {
|
|
|
|
"title": "Site Name",
|
|
|
|
},
|
|
|
|
"highlight_color": {
|
|
|
|
"title": "Highlight Color",
|
|
|
|
"help_text": "Used for logo background and other highlights",
|
|
|
|
},
|
|
|
|
"post_length": {
|
|
|
|
"title": "Maximum Post Length",
|
|
|
|
"help_text": "The maximum number of characters allowed per post",
|
|
|
|
},
|
2022-11-23 02:52:40 +00:00
|
|
|
"content_warning_text": {
|
|
|
|
"title": "Content Warning Feature Name",
|
|
|
|
"help_text": "What the feature that lets users provide post summaries is called",
|
|
|
|
},
|
2022-11-18 07:09:04 +00:00
|
|
|
"site_about": {
|
|
|
|
"title": "About This Site",
|
2022-11-19 17:20:13 +00:00
|
|
|
"help_text": "Displayed on the homepage and the about page.\nNewlines are preserved; HTML also allowed.",
|
2022-11-18 07:09:04 +00:00
|
|
|
"display": "textarea",
|
|
|
|
},
|
|
|
|
"site_icon": {
|
|
|
|
"title": "Site Icon",
|
|
|
|
"help_text": "Minimum size 64x64px. Should be square.",
|
|
|
|
},
|
|
|
|
"site_banner": {
|
|
|
|
"title": "Site Banner",
|
|
|
|
"help_text": "Must be at least 650px wide. 3:1 ratio of width:height recommended.",
|
|
|
|
},
|
|
|
|
"identity_max_per_user": {
|
|
|
|
"title": "Maximum Identities Per User",
|
|
|
|
"help_text": "Non-admins will be blocked from creating more than this",
|
|
|
|
},
|
2022-11-20 18:13:44 +00:00
|
|
|
"identity_min_length": {
|
|
|
|
"title": "Minimum Length For User Identities",
|
|
|
|
"help_text": "Non-admins will be blocked from creating identities shorter than this",
|
|
|
|
},
|
2022-11-18 07:09:04 +00:00
|
|
|
"signup_allowed": {
|
|
|
|
"title": "Signups Allowed",
|
|
|
|
"help_text": "If signups are allowed at all",
|
|
|
|
},
|
|
|
|
"signup_invite_only": {
|
|
|
|
"title": "Invite-Only",
|
|
|
|
"help_text": "If signups require an invite code",
|
|
|
|
},
|
|
|
|
"signup_text": {
|
|
|
|
"title": "Signup Page Text",
|
|
|
|
"help_text": "Shown above the signup form",
|
|
|
|
"display": "textarea",
|
|
|
|
},
|
2022-11-19 17:20:13 +00:00
|
|
|
"restricted_usernames": {
|
|
|
|
"title": "Restricted Usernames",
|
|
|
|
"help_text": "Usernames that only admins can register for identities. One per line.",
|
|
|
|
"display": "textarea",
|
|
|
|
},
|
2022-11-29 04:41:36 +00:00
|
|
|
"hashtag_unreviewed_are_public": {
|
|
|
|
"title": "Unreviewed Hashtags Are Public",
|
|
|
|
"help_text": "Public Hashtags may appear in Trending and have a Tags timeline",
|
|
|
|
},
|
2022-11-18 07:09:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
layout = {
|
|
|
|
"Branding": [
|
|
|
|
"site_name",
|
|
|
|
"site_about",
|
|
|
|
"site_icon",
|
|
|
|
"site_banner",
|
|
|
|
"highlight_color",
|
|
|
|
],
|
|
|
|
"Signups": ["signup_allowed", "signup_invite_only", "signup_text"],
|
2022-11-29 04:41:36 +00:00
|
|
|
"Posts": [
|
|
|
|
"post_length",
|
|
|
|
"content_warning_text",
|
|
|
|
"hashtag_unreviewed_are_public",
|
|
|
|
],
|
2022-11-20 18:13:44 +00:00
|
|
|
"Identities": [
|
|
|
|
"identity_max_per_user",
|
|
|
|
"identity_min_length",
|
|
|
|
"restricted_usernames",
|
|
|
|
],
|
2022-11-18 07:09:04 +00:00
|
|
|
}
|