Remove some debug code
This commit is contained in:
parent
4b4b8bfe72
commit
79b1f7676e
|
@ -56,13 +56,10 @@ def update_customer_fields(stripe_id, email=None, first_name=None, last_name=Non
|
||||||
"""
|
"""
|
||||||
Update the customer fields in Stripe.
|
Update the customer fields in Stripe.
|
||||||
"""
|
"""
|
||||||
print("Update customer fields called")
|
|
||||||
if email:
|
if email:
|
||||||
print("Email modified")
|
|
||||||
stripe.Customer.modify(stripe_id, email=email)
|
stripe.Customer.modify(stripe_id, email=email)
|
||||||
logger.info(f"Modified Stripe customer {stripe_id} to have email {email}")
|
logger.info(f"Modified Stripe customer {stripe_id} to have email {email}")
|
||||||
if first_name or last_name:
|
if first_name or last_name:
|
||||||
print("Name modified")
|
|
||||||
name = expand_name(first_name, last_name)
|
name = expand_name(first_name, last_name)
|
||||||
stripe.Customer.modify(stripe_id, name=name)
|
stripe.Customer.modify(stripe_id, name=name)
|
||||||
logger.info(f"Modified Stripe customer {stripe_id} to have email {name}")
|
logger.info(f"Modified Stripe customer {stripe_id} to have email {name}")
|
||||||
|
|
|
@ -1,182 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% load static %}
|
|
||||||
{% block content %}
|
|
||||||
<div class="box">
|
|
||||||
<form method="POST">
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="field">
|
|
||||||
<label class="label">Search</label>
|
|
||||||
<div class="field-body">
|
|
||||||
<div class="field">
|
|
||||||
<div class="control is-expanded has-icons-left">
|
|
||||||
<input name="query" class="input" type="text" placeholder="Query">
|
|
||||||
<span class="icon is-small is-left">
|
|
||||||
<i class="fas fa-magnifying-glass"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column">
|
|
||||||
<label class="label">Timescale</label>
|
|
||||||
<div class="field-body">
|
|
||||||
<div class="field">
|
|
||||||
<div class="control is-expanded has-icons-left">
|
|
||||||
<div class="select is-fullwidth">
|
|
||||||
<select name="timescale">
|
|
||||||
{% for timescale in timescales %}
|
|
||||||
<option value="{{ timescale }}">{{ timescale }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
<span class="icon is-small is-left">
|
|
||||||
<i class="fas fa-magnifying-glass"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<label class="label">Fields</label>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<div class="control is-expanded has-icons-left">
|
|
||||||
<div class="select is-fullwidth is-multiple">
|
|
||||||
<select multiple name="fields">
|
|
||||||
{% for field in fields %}
|
|
||||||
<option value="{{ field }}">{{ field }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
<span class="icon is-small is-left">
|
|
||||||
<i class="fas fa-magnifying-glass"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<label class="label">Results</label>
|
|
||||||
<div class="field">
|
|
||||||
<div class="control is-expanded has-icons-left">
|
|
||||||
<div class="select is-fullwidth">
|
|
||||||
<select name="size">
|
|
||||||
{% for size in sizes %}
|
|
||||||
<option value="{{ size }}">{{ size }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
<span class="icon is-small is-left">
|
|
||||||
<i class="fas fa-magnifying-glass"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<div class="control">
|
|
||||||
<button class="button is-primary is-fullwidth">
|
|
||||||
Search
|
|
||||||
</button>
|
|
||||||
<button hx-post="{% url 'search' %}"
|
|
||||||
hx-trigger="click"
|
|
||||||
hx-target="#parent-div"
|
|
||||||
hx-swap="outerHTML">
|
|
||||||
Click Me!
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
{% if results is not None %}
|
|
||||||
<div class="box">
|
|
||||||
<div class="table-container">
|
|
||||||
<table class="table is-striped is-hoverable is-fullwidth">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>TS</th>
|
|
||||||
<th>msg</th>
|
|
||||||
<th>host</th>
|
|
||||||
<th>nick</th>
|
|
||||||
<th>channel</th>
|
|
||||||
<th>net</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
{% for item in results %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ item.ts }}</td>
|
|
||||||
<td>{{ item.msg }}</td>
|
|
||||||
<td>{{ item.host }}</td>
|
|
||||||
<td>{{ item.nick }}</td>
|
|
||||||
<td>{{ item.channel }}</td>
|
|
||||||
<td>{{ item.net }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="box">
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column">
|
|
||||||
<p>{{ card }} hits</p>
|
|
||||||
</div>
|
|
||||||
{% if redacted != 0 %}
|
|
||||||
<div class="column">
|
|
||||||
<p>{{ redacted }} redacted</p>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if exemption is not None %}
|
|
||||||
<div class="column">
|
|
||||||
<p>god mode</p>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="column">
|
|
||||||
<p>{{ took }}ms</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column is-half">
|
|
||||||
<div class="box">
|
|
||||||
<label class="label">Volume</label>
|
|
||||||
<canvas id="volumeChart"></canvas>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$.post('{% url "chart_volume_json" %}', function(data) {
|
|
||||||
var ctx = $("#volumeChart").get(0).getContext("2d");
|
|
||||||
new Chart(ctx, {
|
|
||||||
type: 'line', data: data
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<div class="box">
|
|
||||||
<label class="label">Sentiment</label>
|
|
||||||
<canvas id="sentimentChart"></canvas>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$.post('{% url "chart_sentiment_json" %}', function(data) {
|
|
||||||
var ctx = $("#sentimentChart").get(0).getContext("2d");
|
|
||||||
new Chart(ctx, {
|
|
||||||
type: 'line', data: data
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
|
@ -1,11 +0,0 @@
|
||||||
{% load static %}
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,16 +1,12 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
<div id="results">
|
<div id="results">
|
||||||
{% if results is not None %}
|
{% if results is not None %}
|
||||||
<div style="display: none" id="jsonData" data-json="{{ data }}"></div>
|
<div style="display: none" id="jsonData" data-json="{{ data }}">
|
||||||
<div class="columns">
|
</div>
|
||||||
<div class="column">
|
<div class="box">
|
||||||
<div class="box">
|
<canvas id="volume"></canvas>
|
||||||
<label class="label">Sentiment</label>
|
<script src="{% static 'chart.js' %}"></script>
|
||||||
<canvas id="volume"></canvas>
|
|
||||||
<script src="{% static 'chart.js' %}"></script>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import logging
|
import logging
|
||||||
import pprint
|
|
||||||
|
|
||||||
import stripe
|
import stripe
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -15,7 +14,6 @@ from core.lib.products import assemble_plan_map
|
||||||
from core.models import ContentBlock, Plan, Session
|
from core.models import ContentBlock, Plan, Session
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
|
||||||
|
|
||||||
# Create your views here
|
# Create your views here
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
from rest_framework.views import APIView
|
|
||||||
import logging
|
|
||||||
from django.conf import settings
|
|
||||||
from django.shortcuts import render
|
|
||||||
from django.http import HttpResponse, JsonResponse
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
||||||
import json
|
import json
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.http import HttpResponse, JsonResponse
|
||||||
|
from django.shortcuts import render
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from rest_framework.parsers import JSONParser
|
|
||||||
from core.lib.opensearch import initialise_opensearch, run_main_query
|
from core.lib.opensearch import initialise_opensearch, run_main_query
|
||||||
|
|
||||||
client = initialise_opensearch()
|
client = initialise_opensearch()
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ def query_results(request, post_params, api=False):
|
||||||
results = run_main_query(client, request.user, query, fields, size)
|
results = run_main_query(client, request.user, query, fields, size)
|
||||||
if not results:
|
if not results:
|
||||||
return False
|
return False
|
||||||
# pp.pprint(results)
|
|
||||||
results_parsed = []
|
results_parsed = []
|
||||||
if "hits" in results.keys():
|
if "hits" in results.keys():
|
||||||
if "hits" in results["hits"]:
|
if "hits" in results["hits"]:
|
||||||
|
@ -42,8 +40,9 @@ def query_results(request, post_params, api=False):
|
||||||
}
|
}
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class Search(LoginRequiredMixin, View):
|
class Search(LoginRequiredMixin, View):
|
||||||
#parser_classes = [JSONParser]
|
# parser_classes = [JSONParser]
|
||||||
template_name = "ui/results.html"
|
template_name = "ui/results.html"
|
||||||
plan_name = "drilldown"
|
plan_name = "drilldown"
|
||||||
|
|
||||||
|
@ -52,35 +51,30 @@ class Search(LoginRequiredMixin, View):
|
||||||
return render(request, "denied.html")
|
return render(request, "denied.html")
|
||||||
|
|
||||||
context = query_results(request, request.POST)
|
context = query_results(request, request.POST)
|
||||||
print("context: ", context)
|
context["data"] = json.dumps(
|
||||||
context['data'] = json.dumps(
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
'id': item.get('id'),
|
"id": item.get("id"),
|
||||||
'value': item.get("sentiment", 0),
|
"value": item.get("sentiment", 0),
|
||||||
'date': item.get("ts"),
|
"date": item.get("ts"),
|
||||||
}
|
}
|
||||||
for item in context["results"]
|
for item in context["results"]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
print("context['data']: ", context['data'])
|
|
||||||
if context:
|
if context:
|
||||||
print("OGING TO RENDER")
|
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
else:
|
else:
|
||||||
return HttpResponse("No results")
|
return HttpResponse("No results")
|
||||||
|
|
||||||
|
|
||||||
class APISearch(LoginRequiredMixin, View):
|
class APISearch(LoginRequiredMixin, View):
|
||||||
#parser_classes = [JSONParser]
|
# parser_classes = [JSONParser]
|
||||||
template_name = "ui/results.html"
|
template_name = "ui/results.html"
|
||||||
plan_name = "drilldown"
|
plan_name = "drilldown"
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
print("POST")
|
|
||||||
if not request.user.has_plan(self.plan_name):
|
if not request.user.has_plan(self.plan_name):
|
||||||
return JsonResponse({"success": False})
|
return JsonResponse({"success": False})
|
||||||
print("PERMS")
|
|
||||||
|
|
||||||
context = query_results(request, request.POST)
|
context = query_results(request, request.POST)
|
||||||
print("CONTEXT", context)
|
|
||||||
return JsonResponse(context)
|
return JsonResponse(context)
|
||||||
|
|
Loading…
Reference in New Issue