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'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# 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"
|
||||
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
|
||||
|
||||
from app.local_settings import * # noqa
|
||||
|
|
|
@ -16,8 +16,8 @@ Including another URLconf
|
|||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
from core.views import Home, Profile, Signup
|
||||
from core.ui.views.drilldown import Drilldown
|
||||
from core.views import Home, Profile, Signup
|
||||
|
||||
urlpatterns = [
|
||||
path("", Home.as_view(), name="home"),
|
||||
|
|
|
@ -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,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)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
django
|
||||
pre-commit
|
||||
django-crispy-forms
|
||||
opensearch-py
|
Loading…
Reference in New Issue