Begin implementing Drilldown functionality
This commit is contained in:
parent
e047a986e9
commit
e866277f52
|
@ -16,7 +16,6 @@ from pathlib import Path
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
||||||
|
|
||||||
|
@ -126,3 +125,6 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||||
AUTH_USER_MODEL = "core.User"
|
AUTH_USER_MODEL = "core.User"
|
||||||
|
|
||||||
LOGIN_REDIRECT_URL = "/"
|
LOGIN_REDIRECT_URL = "/"
|
||||||
|
|
||||||
|
|
||||||
|
from app.local_settings import * # noqa
|
||||||
|
|
|
@ -16,8 +16,8 @@ Including another URLconf
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
|
||||||
from core.views import Home, Profile, Signup
|
|
||||||
from core.ui.views.drilldown import Drilldown
|
from core.ui.views.drilldown import Drilldown
|
||||||
|
from core.views import Home, Profile, Signup
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", Home.as_view(), name="home"),
|
path("", Home.as_view(), name="home"),
|
||||||
|
|
|
@ -25,5 +25,7 @@ class User(AbstractUser):
|
||||||
plans = models.ManyToManyField(Plan, blank=True)
|
plans = models.ManyToManyField(Plan, blank=True)
|
||||||
|
|
||||||
def has_plan(self, plan):
|
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()]
|
plan_list = [plan.name for plan in self.plans.all()]
|
||||||
return plan in plan_list
|
return plan in plan_list
|
||||||
|
|
|
@ -114,6 +114,11 @@ h5 {
|
||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
padding-bottom: 3px;
|
padding-bottom: 3px;
|
||||||
}
|
}
|
||||||
|
.search-box {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
.profile-info p {
|
.profile-info p {
|
||||||
align-items: left;
|
align-items: left;
|
||||||
justify-content: left;
|
justify-content: left;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<title>Pathogen - {{ request.path_info }}</title>
|
<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 href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
|
||||||
<link rel="stylesheet" href="{% static 'style.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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<section class="hero is-primary is-fullheight">
|
<section class="hero is-primary is-fullheight">
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li><a href="{% url 'profile' %}">Profile</a></li>
|
<li><a href="{% url 'profile' %}">Profile</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.plan == "drilldown" and user.paid %}
|
{% if user.paid %}
|
||||||
<li><a href="{% url 'drilldown' %}">Drilldown</a></li>
|
<li><a href="{% url 'drilldown' %}">Drilldown</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not user.is_authenticated %}
|
{% if not user.is_authenticated %}
|
||||||
|
|
|
@ -1,25 +1,30 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
{% block content %}
|
{% 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="container">
|
||||||
<div class="row">
|
<div class="row vertical-offset-100">
|
||||||
<div class="col">
|
<div class="col-md-4 col-md-offset-4">
|
||||||
<div class="profile-info">
|
<div class="panel panel-default">
|
||||||
<p>PROFILE INFO</p>
|
<div class="panel-heading">
|
||||||
</div>
|
{% if query is not None %}
|
||||||
<div class="update-info">
|
<h3 class="panel-title">Searching for {{ query }}</h3>
|
||||||
{% if user.seti %}
|
|
||||||
{% if user.plan == None %}
|
|
||||||
{% include 'checkout.html' %}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<form>
|
<h3 class="panel-title">Search our database</h3>
|
||||||
<button id="button" formaction="/portal">Customer portal</button>
|
{% 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>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
</div>
|
||||||
<button id="setup-button">Setup payment mandate</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,28 @@
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.views import View
|
|
||||||
from django.shortcuts import render
|
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):
|
class Drilldown(LoginRequiredMixin, View):
|
||||||
template_name = "ui/drilldown.html"
|
template_name = "ui/drilldown.html"
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request):
|
||||||
if not request.user.has_plan("drilldown"):
|
if not request.user.has_plan("drilldown"):
|
||||||
return render(request, "denied.html")
|
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
|
# Create your views here
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Home(View):
|
class Home(View):
|
||||||
template_name = "index.html"
|
template_name = "index.html"
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request):
|
||||||
return render(request, self.template_name)
|
return render(request, self.template_name)
|
||||||
|
|
||||||
|
|
||||||
class Profile(LoginRequiredMixin, View):
|
class Profile(LoginRequiredMixin, View):
|
||||||
template_name = "profile.html"
|
template_name = "profile.html"
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request):
|
||||||
return render(request, self.template_name)
|
return render(request, self.template_name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
django
|
django
|
||||||
pre-commit
|
pre-commit
|
||||||
|
django-crispy-forms
|
||||||
|
opensearch-py
|
Loading…
Reference in New Issue