Add ActionSuccessView
ActionSuccessView is a a generic view that indicates that something was successful, e.g. deleting a post or banning a user. This hopefully reduces the amount of boilerplate code used for creating success pages since most of them can derive from this generic view. The report and delete success views are updated to use this directly. The ban and modify success views are updated to derive from this class, with special permissions required. The post success view is updated to derive from this class, using a different template. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.urls import path
|
||||
from django.utils.translation import gettext as _
|
||||
from board.views import *
|
||||
|
||||
|
||||
@@ -17,20 +18,35 @@ urlpatterns = [
|
||||
path("post/success/", PostSuccessView.as_view(), name="post_success"),
|
||||
# Reports
|
||||
path("report/<slug:url>/<int:id>/", ReportView.as_view(), name="report_form"),
|
||||
path("report/success/", ReportSuccessView.as_view(), name="report_success"),
|
||||
path(
|
||||
"report/success/",
|
||||
ActionSuccessView.as_view(
|
||||
window_timeout=settings.REPORT_WINDOW_CLOSE_TIMEOUT,
|
||||
message=_("Post reported."),
|
||||
),
|
||||
name="report_success",
|
||||
),
|
||||
# Bans
|
||||
path("ban/<slug:url>/<int:id>/", BanCreateView.as_view(), name="ban_create"),
|
||||
path("ban/success/", BanSuccessView.as_view(), name="ban_success"),
|
||||
path(
|
||||
"ban/success/",
|
||||
BanSuccessView.as_view(window_timeout=settings.ACTION_SUCCESS_CLOSE_TIMEOUT),
|
||||
name="ban_success",
|
||||
),
|
||||
path("banned/", BannedView.as_view(), name="banned"),
|
||||
# Other moderation pages
|
||||
path("modify/<int:pk>/", PostModifyView.as_view(), name="post_modify"),
|
||||
path(
|
||||
"modify/success/", PostModifySuccessView.as_view(), name="post_modify_success"
|
||||
"modify/success/",
|
||||
PostModifySuccessView.as_view(
|
||||
window_timeout=settings.ACTION_SUCCESS_CLOSE_TIMEOUT
|
||||
),
|
||||
name="post_modify_success",
|
||||
),
|
||||
path("post/delete/<int:pk>/", PostDeleteView.as_view(), name="post_delete"),
|
||||
path(
|
||||
"post/delete/success/",
|
||||
PostDeleteSuccessView.as_view(),
|
||||
ActionSuccessView.as_view(window_timeout=settings.ACTION_SUCCESS_CLOSE_TIMEOUT),
|
||||
name="post_delete_success",
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user