Begin implementing Drilldown functionality
This commit is contained in:
@@ -25,5 +25,7 @@ class User(AbstractUser):
|
||||
plans = models.ManyToManyField(Plan, blank=True)
|
||||
|
||||
def has_plan(self, plan):
|
||||
if not self.paid: # We can't have any plans if we haven't paid
|
||||
return False
|
||||
plan_list = [plan.name for plan in self.plans.all()]
|
||||
return plan in plan_list
|
||||
|
||||
@@ -114,6 +114,11 @@ h5 {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
.search-box {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.profile-info p {
|
||||
align-items: left;
|
||||
justify-content: left;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<title>Pathogen - {{ request.path_info }}</title>
|
||||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
|
||||
<link rel="stylesheet" href="{% static 'style.css' %}" />
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
{# <script src="https://js.stripe.com/v3/"></script> #}
|
||||
</head>
|
||||
<body>
|
||||
<section class="hero is-primary is-fullheight">
|
||||
@@ -28,7 +28,7 @@
|
||||
{% if user.is_authenticated %}
|
||||
<li><a href="{% url 'profile' %}">Profile</a></li>
|
||||
{% endif %}
|
||||
{% if user.plan == "drilldown" and user.paid %}
|
||||
{% if user.paid %}
|
||||
<li><a href="{% url 'drilldown' %}">Drilldown</a></li>
|
||||
{% endif %}
|
||||
{% if not user.is_authenticated %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load static %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
@@ -1,25 +1,30 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<h1 class="title">Welcome to search, {{ name }}!</h1>
|
||||
<h1 class="title">Welcome to search, {{ user.first_name }}!</h1>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="profile-info">
|
||||
<p>PROFILE INFO</p>
|
||||
</div>
|
||||
<div class="update-info">
|
||||
{% if user.seti %}
|
||||
{% if user.plan == None %}
|
||||
{% include 'checkout.html' %}
|
||||
<div class="row vertical-offset-100">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{% if query is not None %}
|
||||
<h3 class="panel-title">Searching for {{ query }}</h3>
|
||||
{% else %}
|
||||
<form>
|
||||
<button id="button" formaction="/portal">Customer portal</button>
|
||||
<h3 class="panel-title">Search our database</h3>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if query is None %}
|
||||
<form method="POST">
|
||||
<fieldset>
|
||||
{% csrf_token %}
|
||||
<input class="textinput textInput form-control" type="text" name="query">
|
||||
<input class="btn btn-lg btn-dark btn-block" type="submit" value="Search">
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<button id="setup-button">Setup payment mandate</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views import View
|
||||
from django.shortcuts import render
|
||||
from django.views import View
|
||||
|
||||
from core.lib.opensearch import initialise_opensearch, run_main_query
|
||||
|
||||
client = initialise_opensearch()
|
||||
|
||||
|
||||
class Drilldown(LoginRequiredMixin, View):
|
||||
template_name = "ui/drilldown.html"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
def get(self, request):
|
||||
if not request.user.has_plan("drilldown"):
|
||||
return render(request, "denied.html")
|
||||
return render(request, self.template_name)
|
||||
return render(request, self.template_name)
|
||||
|
||||
def post(self, request):
|
||||
if not request.user.has_plan("drilldown"):
|
||||
return render(request, "denied.html")
|
||||
if "query" in request.POST:
|
||||
query = request.POST["query"]
|
||||
results = run_main_query(client, query)
|
||||
print("RESULTS", results)
|
||||
context = {"query": query}
|
||||
print("CONTEXT", context)
|
||||
return render(request, self.template_name, context)
|
||||
return render(request, self.template_name)
|
||||
|
||||
@@ -9,20 +9,17 @@ from core.forms import NewUserForm
|
||||
# Create your views here
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Home(View):
|
||||
template_name = "index.html"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
def get(self, request):
|
||||
return render(request, self.template_name)
|
||||
|
||||
|
||||
class Profile(LoginRequiredMixin, View):
|
||||
template_name = "profile.html"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
def get(self, request):
|
||||
return render(request, self.template_name)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user