2022-11-17 23:09:04 -08:00
|
|
|
from django.utils.decorators import method_decorator
|
2022-12-05 09:55:30 -08:00
|
|
|
from django.utils.safestring import mark_safe
|
2022-11-17 23:09:04 -08:00
|
|
|
|
|
|
|
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-12-15 14:55:33 -08:00
|
|
|
"post_minimum_interval": {
|
|
|
|
"title": "Minimum Posting Interval",
|
|
|
|
"help_text": "The minimum number of seconds a user must wait between posts",
|
|
|
|
},
|
2022-11-22 18:52:40 -08:00
|
|
|
"content_warning_text": {
|
|
|
|
"title": "Content Warning Feature Name",
|
|
|
|
"help_text": "What the feature that lets users provide post summaries is called",
|
|
|
|
},
|
2022-11-17 23:09:04 -08:00
|
|
|
"site_about": {
|
|
|
|
"title": "About This Site",
|
2022-12-05 18:21:00 -08:00
|
|
|
"help_text": "Displayed on the homepage and the about page.\nUse Markdown for formatting.",
|
2022-11-17 23:09:04 -08: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 10:13:44 -08: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-17 23:09:04 -08:00
|
|
|
"signup_allowed": {
|
|
|
|
"title": "Signups Allowed",
|
2022-12-21 23:03:21 -08:00
|
|
|
"help_text": "If uninvited signups are allowed.\nInvite codes will always work.",
|
2022-11-17 23:09:04 -08:00
|
|
|
},
|
|
|
|
"signup_text": {
|
|
|
|
"title": "Signup Page Text",
|
2022-12-17 16:02:42 -08:00
|
|
|
"help_text": "Shown above the signup form.\nUse Markdown for formatting.",
|
2022-11-17 23:09:04 -08:00
|
|
|
"display": "textarea",
|
|
|
|
},
|
2022-11-19 09:20:13 -08:00
|
|
|
"restricted_usernames": {
|
|
|
|
"title": "Restricted Usernames",
|
|
|
|
"help_text": "Usernames that only admins can register for identities. One per line.",
|
|
|
|
"display": "textarea",
|
|
|
|
},
|
2022-11-28 20:41:36 -08:00
|
|
|
"hashtag_unreviewed_are_public": {
|
|
|
|
"title": "Unreviewed Hashtags Are Public",
|
|
|
|
"help_text": "Public Hashtags may appear in Trending and have a Tags timeline",
|
|
|
|
},
|
2022-12-14 23:50:54 -08:00
|
|
|
"emoji_unreviewed_are_public": {
|
|
|
|
"title": "Unreviewed Emoji Are Public",
|
|
|
|
"help_text": "Public Emoji may appear as images, instead of shortcodes",
|
|
|
|
},
|
2022-12-29 09:31:32 -08:00
|
|
|
"public_timeline": {
|
|
|
|
"title": "Public Timeline",
|
|
|
|
"help_text": "If enabled, allows anonymous access to the public timeline",
|
|
|
|
},
|
|
|
|
"site_frontpage_posts": {
|
|
|
|
"title": "Show Public Timeline On Front Page",
|
|
|
|
"help_text": "Whether to show some recent posts on the logged-out homepage",
|
|
|
|
},
|
2022-11-17 23:09:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
layout = {
|
|
|
|
"Branding": [
|
|
|
|
"site_name",
|
|
|
|
"site_about",
|
|
|
|
"site_icon",
|
|
|
|
"site_banner",
|
|
|
|
"highlight_color",
|
|
|
|
],
|
2022-12-21 23:03:21 -08:00
|
|
|
"Signups": [
|
|
|
|
"signup_allowed",
|
|
|
|
"signup_text",
|
|
|
|
],
|
2022-11-28 20:41:36 -08:00
|
|
|
"Posts": [
|
|
|
|
"post_length",
|
2022-12-15 14:55:33 -08:00
|
|
|
"post_minimum_interval",
|
2022-11-28 20:41:36 -08:00
|
|
|
"content_warning_text",
|
|
|
|
"hashtag_unreviewed_are_public",
|
2022-12-14 23:50:54 -08:00
|
|
|
"emoji_unreviewed_are_public",
|
2022-11-28 20:41:36 -08:00
|
|
|
],
|
2022-12-29 09:31:32 -08:00
|
|
|
"Timelines": [
|
|
|
|
"public_timeline",
|
|
|
|
"site_frontpage_posts",
|
|
|
|
],
|
2022-11-20 10:13:44 -08:00
|
|
|
"Identities": [
|
|
|
|
"identity_max_per_user",
|
|
|
|
"identity_min_length",
|
|
|
|
"restricted_usernames",
|
|
|
|
],
|
2022-11-17 23:09:04 -08:00
|
|
|
}
|
2022-12-05 09:55:30 -08:00
|
|
|
|
|
|
|
|
|
|
|
cache_field_defaults = {
|
|
|
|
"min_value": 0,
|
|
|
|
"max_value": 900,
|
|
|
|
"step_size": 15,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class TuningSettings(AdminSettingsPage):
|
|
|
|
|
|
|
|
section = "tuning"
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"cache_timeout_page_default": {
|
|
|
|
**cache_field_defaults,
|
|
|
|
"title": "Default Timeout",
|
|
|
|
"help_text": "The number of seconds to cache a rendered page",
|
|
|
|
},
|
|
|
|
"cache_timeout_page_timeline": {
|
|
|
|
**cache_field_defaults,
|
|
|
|
"title": "Timeline Timeout",
|
|
|
|
"help_text": "The number of seconds to cache a rendered timeline page",
|
|
|
|
},
|
|
|
|
"cache_timeout_page_post": {
|
|
|
|
**cache_field_defaults,
|
|
|
|
"title": "Individual Post Timeout",
|
|
|
|
"help_text": mark_safe(
|
|
|
|
"The number of seconds to cache a rendered individual Post page<br>Note: This includes the JSON responses to other servers"
|
|
|
|
),
|
|
|
|
},
|
|
|
|
"cache_timeout_identity_feed": {
|
|
|
|
**cache_field_defaults,
|
|
|
|
"title": "Identity Feed Timeout",
|
|
|
|
"help_text": "The number of seconds to cache a rendered Identity RSS feed",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
layout = {
|
|
|
|
"Rendered Page Cache": [
|
|
|
|
"cache_timeout_page_default",
|
|
|
|
"cache_timeout_page_timeline",
|
|
|
|
"cache_timeout_page_post",
|
|
|
|
],
|
|
|
|
"RSS Feeds": [
|
|
|
|
"cache_timeout_identity_feed",
|
|
|
|
],
|
|
|
|
}
|
2022-12-05 18:21:00 -08:00
|
|
|
|
|
|
|
|
|
|
|
class PoliciesSettings(AdminSettingsPage):
|
|
|
|
|
|
|
|
section = "policies"
|
|
|
|
|
|
|
|
options = {
|
|
|
|
"policy_terms": {
|
|
|
|
"title": "Terms of Service Page",
|
2022-12-17 14:30:51 -08:00
|
|
|
"help_text": "Will only be shown if it has content. Use Markdown for formatting.\nIf you would like to redirect elsewhere, enter just a URL.",
|
2022-12-05 18:21:00 -08:00
|
|
|
"display": "textarea",
|
|
|
|
},
|
|
|
|
"policy_privacy": {
|
|
|
|
"title": "Privacy Policy Page",
|
2022-12-17 14:30:51 -08:00
|
|
|
"help_text": "Will only be shown if it has content. Use Markdown for formatting.\nIf you would like to redirect elsewhere, enter just a URL.",
|
2022-12-05 18:21:00 -08:00
|
|
|
"display": "textarea",
|
|
|
|
},
|
|
|
|
"policy_rules": {
|
|
|
|
"title": "Server Rules Page",
|
2022-12-17 14:30:51 -08:00
|
|
|
"help_text": "Will only be shown if it has content. Use Markdown for formatting.\nIf you would like to redirect elsewhere, enter just a URL.",
|
2022-12-05 18:21:00 -08:00
|
|
|
"display": "textarea",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
layout = {
|
|
|
|
"Policies": [
|
|
|
|
"policy_rules",
|
|
|
|
"policy_terms",
|
|
|
|
"policy_privacy",
|
|
|
|
],
|
|
|
|
}
|