Properly implement queries
This commit is contained in:
@@ -448,7 +448,7 @@ class ThresholdIRCSendMessage(SuperUserRequiredMixin, APIView):
|
||||
parser_classes = [FormParser]
|
||||
template_name = "partials/context-input.html"
|
||||
|
||||
def put(self, request, net, num, channel):
|
||||
def put(self, request, net, num, channel, nick=None):
|
||||
"""
|
||||
Send a message
|
||||
"""
|
||||
@@ -460,8 +460,15 @@ class ThresholdIRCSendMessage(SuperUserRequiredMixin, APIView):
|
||||
self.template_name,
|
||||
{"message": message, "class": message_class},
|
||||
)
|
||||
|
||||
messaged = threshold.send_irc_message(net, num, channel, request.data["msg"])
|
||||
print("IRC", nick)
|
||||
if nick:
|
||||
messaged = threshold.send_irc_message(
|
||||
net, num, channel, request.data["msg"], nick=nick
|
||||
)
|
||||
else:
|
||||
messaged = threshold.send_irc_message(
|
||||
net, num, channel, request.data["msg"]
|
||||
)
|
||||
if not messaged:
|
||||
message = "Failed to send message"
|
||||
message_class = "danger"
|
||||
@@ -471,6 +478,7 @@ class ThresholdIRCSendMessage(SuperUserRequiredMixin, APIView):
|
||||
else:
|
||||
message = messaged["reason"]
|
||||
message_class = "danger"
|
||||
print("ERROR", message)
|
||||
|
||||
context = {
|
||||
"net": net,
|
||||
|
||||
@@ -245,7 +245,7 @@ class DrilldownContextModal(APIView):
|
||||
|
||||
size = 20
|
||||
# Create the query params from the POST arguments
|
||||
mandatory = ["net", "channel", "num", "src", "index"]
|
||||
mandatory = ["net", "channel", "num", "src", "index", "nick"]
|
||||
invalid = [None, False, "—", "None"]
|
||||
query_params = {k: v for k, v in request.data.items() if v}
|
||||
for key in query_params:
|
||||
@@ -258,7 +258,11 @@ class DrilldownContextModal(APIView):
|
||||
if "mtype" not in query_params:
|
||||
query_params["mtype"] = None
|
||||
query_params["sorting"] = "desc"
|
||||
if query_params["index"] == "int" and query_params["mtype"] == "msg":
|
||||
if (
|
||||
query_params["index"] == "int"
|
||||
and query_params["mtype"] == "msg"
|
||||
and not query_params["type"] == "query"
|
||||
):
|
||||
query_params["index"] = "main"
|
||||
# Create the query with the context helper
|
||||
search_query = construct_query(
|
||||
@@ -292,6 +296,7 @@ class DrilldownContextModal(APIView):
|
||||
"num": query_params["num"],
|
||||
"type": query_params["type"],
|
||||
"mtype": query_params["mtype"],
|
||||
"nick": query_params["nick"],
|
||||
}
|
||||
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
Reference in New Issue
Block a user