Trying out JSFrame for windows

Winbox has this annoying bug where you can't move the window below the
calculated area of the document, so you can't drag it over blank space.
JSFrame fixes this and does basically what we want as well. This has
been implemented for post replies and I am going to implement it for
reports and ban creation too.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-25 20:42:10 -07:00
parent 8ab760d456
commit e596d59e82
9 changed files with 181 additions and 2 deletions

View File

@@ -19,6 +19,8 @@ __all__ = (
"BannedView",
"BoardView",
"PostView",
"PostSuccessView",
"ReplyCreateView",
"ReportView",
"ReportSuccessView",
)
@@ -105,6 +107,32 @@ class BoardView(CreateView):
return super(BoardView, self).get_context_data(**kwargs)
class ReplyCreateView(CreateView):
model = Post
form_class = ReplyForm
slug_field = "url"
slug_url_kwarg = "url"
template_name = "board/reply_create_view.html"
success_url = reverse_lazy("board:post_success")
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["board"] = self.board
post_id = self.kwargs["id"]
context["post"] = get_object_or_404(Post, id=post_id)
context["max_upload_size"] = settings.MAX_UPLOAD_SIZE
print(context["board"])
return context
def get_form_kwargs(self):
kwargs = super(ReplyCreateView, self).get_form_kwargs()
post_id = self.kwargs["id"]
post = get_object_or_404(Post, id=post_id)
kwargs["op"] = post
kwargs["reply"] = post
return kwargs
class PostView(CreateView):
model = Post
form_class = ReplyForm
@@ -130,6 +158,15 @@ class PostView(CreateView):
return kwargs
class PostSuccessView(TemplateView):
template_name = "board/post_success.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["window_timeout"] = settings.POST_WINDOW_CLOSE_TIMEOUT
return context
class ReportView(CreateView):
model = Report
form_class = ReportForm
@@ -160,7 +197,7 @@ class ReportSuccessView(TemplateView):
return context
class BanCreateView(PermissionRequiredMixin, CreateView):
class BanCreateView(PermissionRequiredMixin, edit.CreateView):
model = Ban
form_class = BanForm
permission_required = "ban.create"
@@ -190,7 +227,7 @@ class BanCreateView(PermissionRequiredMixin, CreateView):
return context
def get_form_kwargs(self) -> Dict[str, Any]:
kwargs = super(CreateView, self).get_form_kwargs()
kwargs = super(edit.CreateView, self).get_form_kwargs()
post_id = self.kwargs["id"]
post = get_object_or_404(Post, id=post_id)
kwargs["op"] = post