diff --git a/board/templates/board/ban_success.html b/board/templates/board/ban_success.html
index ded270f..c242e70 100644
--- a/board/templates/board/ban_success.html
+++ b/board/templates/board/ban_success.html
@@ -5,7 +5,8 @@
{# Body #}
{% block content %}
- {% translate "A ban has been created. This window will close in 1 second." %}
+ {# We do not use pluralize filter for "seconds" because it's a pain to get it to translate. #}
+ {% blocktranslate %}A ban has been created. This window will close in {{window_timeout}} second(s).{% endblocktranslate %}
{% endblock %}
\ No newline at end of file
diff --git a/board/templates/board/report_success.html b/board/templates/board/report_success.html
index 43fd361..8efe714 100644
--- a/board/templates/board/report_success.html
+++ b/board/templates/board/report_success.html
@@ -5,7 +5,8 @@
{# Body #}
{% block content %}
- {% translate "Post reported. This window will close in 1 second." %}
+ {# We do not use pluralize filter for "seconds" because it's a pain to get it to translate. #}
+ {% blocktranslate %}Post reported. This window will close in {{window_timeout}} second(s).{% endblocktranslate %}
{% endblock %}
\ No newline at end of file
diff --git a/board/urls.py b/board/urls.py
index 55bb1af..fa10d8c 100644
--- a/board/urls.py
+++ b/board/urls.py
@@ -1,32 +1,22 @@
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
-from django.views.generic.base import TemplateView
from board.views import *
app_name = "board"
urlpatterns = [
+ # Board views
path("/", BoardView.as_view(), name="board_detail"),
path("/page//", BoardView.as_view(), name="board_detail"),
path("/post//", PostView.as_view(), name="post_detail"),
+ # Reports
path("report///", ReportView.as_view(), name="report_form"),
- path(
- "report/success/",
- TemplateView.as_view(template_name="board/report_success.html"),
- name="report_success",
- ),
+ path("report/success/", ReportSuccessView.as_view(), name="report_success"),
+ # Bans
path("ban///", BanCreateView.as_view(), name="ban_create"),
- path(
- "ban/success/",
- BanSuccessView.as_view(),
- name="ban_success",
- ),
- path(
- "banned",
- BannedView.as_view(),
- name="banned",
- ),
+ path("ban/success/", BanSuccessView.as_view(), name="ban_success"),
+ path("banned", BannedView.as_view(), name="banned"),
]
# TODO - make this conditional so we can serve images up with whatever server we want
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/board/views.py b/board/views.py
index 50eb9e0..2ac99c2 100644
--- a/board/views.py
+++ b/board/views.py
@@ -19,6 +19,7 @@ __all__ = (
"BoardView",
"PostView",
"ReportView",
+ "ReportSuccessView",
)
@@ -145,9 +146,6 @@ class ReportView(CreatePostView):
form_class = ReportForm
success_url = reverse_lazy("board:report_success")
- def get_context_data(self, **kwargs):
- return super(ReportView, self).get_context_data(**kwargs)
-
@property
def board_url(self) -> str:
return self.kwargs["url"]
@@ -164,6 +162,15 @@ class ReportView(CreatePostView):
return kwargs
+class ReportSuccessView(TemplateView):
+ template_name = "board/report_success.html"
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ context["window_timeout"] = settings.REPORT_WINDOW_CLOSE_TIMEOUT
+ return context
+
+
class BanCreateView(PermissionRequiredMixin, CreateView):
model = Ban
form_class = BanForm
@@ -209,3 +216,8 @@ class BanCreateView(PermissionRequiredMixin, CreateView):
class BanSuccessView(PermissionRequiredMixin, TemplateView):
permission_required = "ban.create"
template_name = "board/ban_success.html"
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ context["window_timeout"] = settings.BAN_WINDOW_CLOSE_TIMEOUT
+ return context
diff --git a/threadchat/settings.py b/threadchat/settings.py
index ccd4860..3bea1b7 100644
--- a/threadchat/settings.py
+++ b/threadchat/settings.py
@@ -137,13 +137,26 @@ MEDIA_ROOT = "media/"
# Media URL - the URL where media is served from
MEDIA_URL = "media/"
+# Thumbnail size in pixels.
THUMB_SIZE = (200, 200)
+# Max upload size in bytes.
MAX_UPLOAD_SIZE = 25 * 1024**2
+# Whether to use HCAPTCHA or not.
USE_HCAPTCHA = False
if USE_HCAPTCHA:
INSTALLED_APPS += ["hcaptcha"]
HCAPTCHA_SITEKEY = env("HCAPTCHA_SITEKEY")
HCAPTCHA_SECRET = env("HCAPTCHA_SECRET")
+
+# How many seconds to wait before closing the report window after a report is
+# created.
+# By default, wait 5 seconds. This should give users plenty of time to read it.
+REPORT_WINDOW_CLOSE_TIMEOUT = 5
+
+# How many seconds to wait before closing the ban window after a ban is created.
+# By default, wait 0 seconds and close immediately. It is assumed that the ban
+# is created successfully, and if an error occurs, the window won't close anyway.
+BAN_WINDOW_CLOSE_TIMEOUT = 0