Add preliminary report system
The report system is pretty low-tech. However the scaffolding is there for a lot of new stuff. What we currently have: * Users can create reports * Staff can view reports * Admins can create report templates There's a post drop-down menu available on all posts now, too. This is where "report post" menu item lives and other things like that can be added too. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -3,11 +3,11 @@ from django.http import Http404, HttpResponseRedirect
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.views.generic import DetailView
|
||||
from django.views.generic.edit import CreateView
|
||||
from django.urls import reverse
|
||||
from board.models import Post, Board
|
||||
from board.forms import PostForm, ReplyForm
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from board.models import Post, Board, Report
|
||||
from board.forms import PostForm, ReplyForm, ReportForm
|
||||
|
||||
__all__ = ("BoardView", "PostView")
|
||||
__all__ = ("BoardView", "PostView", "ReportView")
|
||||
|
||||
|
||||
def get_client_ip(request):
|
||||
@@ -107,3 +107,27 @@ class PostView(CreatePostView):
|
||||
kwargs["op"] = post
|
||||
kwargs["reply"] = post
|
||||
return kwargs
|
||||
|
||||
|
||||
class ReportView(CreatePostView):
|
||||
model = Report
|
||||
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"]
|
||||
|
||||
@property
|
||||
def post_id(self) -> int:
|
||||
return self.kwargs["id"]
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(ReportView, self).get_form_kwargs()
|
||||
post_id = self.kwargs["id"]
|
||||
post = get_object_or_404(Post, id=post_id)
|
||||
kwargs["op"] = post
|
||||
return kwargs
|
||||
|
||||
Reference in New Issue
Block a user