Fix issues with POST/GET arguments and the modal

This commit is contained in:
Mark Veidemanis 2022-08-14 22:58:29 +01:00
parent e7b7695efd
commit 8b7dffa1b4
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
5 changed files with 36 additions and 6 deletions

View File

@ -13,7 +13,10 @@
"channel": "{{ params.channel|escapejs }}",
"time": "{{ params.time|escapejs }}",
"date": "{{ params.date|escapejs }}",
"index": "{{ params.index }}"}'
"index": "{{ params.index }}",
"type": "{{ params.type|escapejs }}",
"mtype": "{{ params.mtype|escapejs }}",
"nick": "{{ params.nick|escapejs }}",}'
hx-target="#modals-here"
hx-trigger="load">
</div>

View File

@ -3,6 +3,7 @@
{% load django_tables2_bulma_template %}
{% load static %}
{% load joinsep %}
{% load urlsafe %}
{% block table-wrapper %}
<div id="drilldown-table" class="container box column-shifter-container" style="position:relative; z-index:1;">
{% block table %}
@ -233,7 +234,8 @@
"mtype": "{{ row.cells.mtype }}",
"nick": "{{ row.cells.nick|escapejs }}"}'
hx-target="#modals-here"
hx-trigger="click">
hx-trigger="click"
href="/?modal=context&net={{row.cells.net|escapejs}}&num={{row.cells.num|escapejs}}&src={{row.cells.src|escapejs}}&channel={{row.cells.channel|urlsafe}}&time={{row.cells.time|escapejs}}&date={{row.cells.date|escapejs}}&index={{params.index}}&type={{row.cells.type}}&mtype={{row.cells.mtype}}&nick={{row.cells.mtype|escapejs}}">
{{ row.cells.msg }}
</a>
</td>

View File

@ -0,0 +1,9 @@
import urllib.parse
from django import template
register = template.Library()
@register.filter
def urlsafe(h):
return urllib.parse.quote(h, safe="")

View File

@ -438,12 +438,15 @@ class ThresholdIRCActionsRegistration(SuperUserRequiredMixin, APIView):
if not updated["success"]:
message = updated["reason"]
message_class = "danger"
unreg = threshold.irc_get_unreg(net)
context = {
"net": net,
"unreg": unreg,
"message": message,
"class": message_class,
}
if net:
if net != "None":
context["net"] = net
return render(request, template_name, context)
@ -463,13 +466,19 @@ class ThresholdIRCActionsRegistrationAuth(SuperUserRequiredMixin, APIView):
if not updated["success"]:
message = updated["reason"]
message_class = "danger"
if "net" in request.data:
net = request.data["net"]
else:
net = None
unreg = threshold.irc_get_unreg(net)
context = {
"unreg": unreg,
"message": message,
"class": message_class,
}
if "net" in request.data:
context["net"] = request.data["net"]
if request.data["net"] != "None":
context["net"] = request.data["net"]
return render(request, self.template_name, context)

View File

@ -96,6 +96,13 @@ def drilldown_search(request, return_context=False, template=None):
context = {"sizes": sizes}
return render(request, template_name, context)
tmp_post = request.POST.dict()
tmp_get = request.GET.dict()
tmp_post = {k: v for k, v in tmp_post.items() if v and not v == "None"}
tmp_get = {k: v for k, v in tmp_get.items() if v and not v == "None"}
query_params.update(tmp_post)
query_params.update(tmp_get)
if "index" in query_params:
if not request.user.is_superuser:
message = "You can't use the index parameter"