merged /search into /quest

This commit is contained in:
iou1name 2018-10-03 12:41:38 -04:00
parent ed97ce41fd
commit 672e1fff1d
14 changed files with 25 additions and 66 deletions

@ -9,7 +9,7 @@
<input type="text" name="title" placeholder="Search">
<input type="submit">
</form>
<a href="{{ url('search:index') }}">Advanced</a><br>
<a href="{{ url('quest:index') }}">Advanced</a><br>
<br>
<a href="./quest/1">Unga Bunga Quest</a><br />
{% if request.user.is_authenticated %}

@ -1,10 +1,10 @@
{% extends "base.html" %}
{% block title %}Search{% endblock %}
{% block title %}Quest{% endblock %}
{% block head %}
<link rel="stylesheet" type="text/css" href="{{ static('search.css') }}">
<link rel="stylesheet" type="text/css" href="{{ static('quest_index.css') }}">
{% endblock %}
{% block content %}
<form method="get" action="{{ url('search:index') }}">
<form method="get" action="{{ url('quest:index') }}">
Author: <input type="text" name="author"><br>
Title: <input type="text" name="title"><br>
Tags: <input type="text" name="tags"><br>

@ -48,7 +48,7 @@
<div id="questPane" style="width:{% if request.session.get("hide_chat") == True %}100%{% else %}70%{% endif %};">
<center><h1>{{ quest.title }}</h1></center>
<div id="tags">
Tags: {% for tag in quest.tags.names() %}<a href="{{ url('search:index') + '?tags=' + tag }}">{{ tag }}</a>{% if not loop.last %}, {% endif %}{% endfor %}
Tags: {% for tag in quest.tags.names() %}<a href="{{ url('quest:index') + '?tags=' + tag }}">{{ tag }}</a>{% if not loop.last %}, {% endif %}{% endfor %}
</div>
{% if request.user == quest.owner %}
<form method="post" action="{{ url('quest:new_tag', kwargs={'quest_id': quest_id}) }}">

@ -7,17 +7,32 @@ from datetime import timedelta, datetime, timezone
import bleach
from django.views.decorators.http import require_POST
from django.contrib import messages
from django.http import HttpResponse
from django.shortcuts import render, redirect
from .models import Quest, DiceRoll, PollOption, PollVote, Page, Post
from .forms import EditQuestForm, QuestForm, PostForm
from user.models import User
def index(request):
"""
/quest page index. Possibly not needed.
"""
return HttpResponse("Hello, world. You're at the quest index.")
"""The quest page index."""
if request.GET:
author = request.GET.get('author')
title = request.GET.get('title')
tags = request.GET.get('tags')
if not any((author, title, tags)):
return
results = Quest.objects.all()
if author:
results = results.filter(
owner__username__unaccent__icontains=author)
if title:
results = results.filter(title__unaccent__icontains=title)
if tags:
results = results.filter(tags__name__in=tags.split())
results = results.distinct()
context = locals()
return render(request, 'quest/index.html', context)
def quest(request, quest_id, page_num='0'):

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

@ -1,5 +0,0 @@
from django.apps import AppConfig
class SearchConfig(AppConfig):
name = 'search'

@ -1,3 +0,0 @@
from django.db import models
# Create your models here.

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

@ -1,12 +0,0 @@
#!/usr/bin/env python3
"""
Search URL configuration.
"""
from django.urls import path
from . import views
app_name = 'search'
urlpatterns = [
path('', views.index, name='index'),
]

@ -1,29 +0,0 @@
#!/usr/bin/env python3
"""
/search app views.
"""
from django.shortcuts import render
from quest.models import Quest
from user.models import User
def index(request):
"""The search page index."""
if request.GET:
author = request.GET.get('author')
title = request.GET.get('title')
tags = request.GET.get('tags')
if not any((author, title, tags)):
return
results = Quest.objects.all()
if author:
results = results.filter(
owner__username__unaccent__icontains=author)
if title:
results = results.filter(title__unaccent__icontains=title)
if tags:
results = results.filter(tags__name__in=tags.split())
results = results.distinct()
context = locals()
return render(request, 'search/index.html', context)

@ -39,7 +39,6 @@ INSTALLED_APPS = [
'quest.apps.QuestConfig',
'login.apps.LoginConfig',
'signup.apps.SignupConfig',
'search.apps.SearchConfig',
]
MIDDLEWARE = [