From 672e1fff1dd56e8959532847e383374cd61f803a Mon Sep 17 00:00:00 2001 From: iou1name Date: Wed, 3 Oct 2018 12:41:38 -0400 Subject: [PATCH] merged /search into /quest --- homepage/jinja2/homepage/index.html | 2 +- .../search => quest/jinja2/quest}/index.html | 6 ++-- quest/jinja2/quest/quest_homepage.html | 2 +- .../static/quest_index.css | 0 quest/views.py | 25 ++++++++++++---- search/__init__.py | 0 search/admin.py | 3 -- search/apps.py | 5 ---- search/migrations/__init__.py | 0 search/models.py | 3 -- search/tests.py | 3 -- search/urls.py | 12 -------- search/views.py | 29 ------------------- titivillus/settings.py | 1 - 14 files changed, 25 insertions(+), 66 deletions(-) rename {search/jinja2/search => quest/jinja2/quest}/index.html (78%) rename search/static/search.css => quest/static/quest_index.css (100%) delete mode 100644 search/__init__.py delete mode 100644 search/admin.py delete mode 100644 search/apps.py delete mode 100644 search/migrations/__init__.py delete mode 100644 search/models.py delete mode 100644 search/tests.py delete mode 100644 search/urls.py delete mode 100644 search/views.py diff --git a/homepage/jinja2/homepage/index.html b/homepage/jinja2/homepage/index.html index 881e95e..db2950e 100644 --- a/homepage/jinja2/homepage/index.html +++ b/homepage/jinja2/homepage/index.html @@ -9,7 +9,7 @@ - Advanced
+ Advanced

Unga Bunga Quest
{% if request.user.is_authenticated %} diff --git a/search/jinja2/search/index.html b/quest/jinja2/quest/index.html similarity index 78% rename from search/jinja2/search/index.html rename to quest/jinja2/quest/index.html index 1f04adf..c8cb032 100644 --- a/search/jinja2/search/index.html +++ b/quest/jinja2/quest/index.html @@ -1,10 +1,10 @@ {% extends "base.html" %} -{% block title %}Search{% endblock %} +{% block title %}Quest{% endblock %} {% block head %} - + {% endblock %} {% block content %} -
+ Author:
Title:
Tags:
diff --git a/quest/jinja2/quest/quest_homepage.html b/quest/jinja2/quest/quest_homepage.html index f72bab3..27ccc66 100644 --- a/quest/jinja2/quest/quest_homepage.html +++ b/quest/jinja2/quest/quest_homepage.html @@ -48,7 +48,7 @@

{{ quest.title }}

- Tags: {% for tag in quest.tags.names() %}{{ tag }}{% if not loop.last %}, {% endif %}{% endfor %} + Tags: {% for tag in quest.tags.names() %}{{ tag }}{% if not loop.last %}, {% endif %}{% endfor %}
{% if request.user == quest.owner %} diff --git a/search/static/search.css b/quest/static/quest_index.css similarity index 100% rename from search/static/search.css rename to quest/static/quest_index.css diff --git a/quest/views.py b/quest/views.py index b60af44..5fb1d8d 100644 --- a/quest/views.py +++ b/quest/views.py @@ -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'): diff --git a/search/__init__.py b/search/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/search/admin.py b/search/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/search/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/search/apps.py b/search/apps.py deleted file mode 100644 index 5726231..0000000 --- a/search/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class SearchConfig(AppConfig): - name = 'search' diff --git a/search/migrations/__init__.py b/search/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/search/models.py b/search/models.py deleted file mode 100644 index 71a8362..0000000 --- a/search/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/search/tests.py b/search/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/search/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/search/urls.py b/search/urls.py deleted file mode 100644 index b3164d8..0000000 --- a/search/urls.py +++ /dev/null @@ -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'), -] diff --git a/search/views.py b/search/views.py deleted file mode 100644 index 0623510..0000000 --- a/search/views.py +++ /dev/null @@ -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) diff --git a/titivillus/settings.py b/titivillus/settings.py index c96a5c1..58467f9 100644 --- a/titivillus/settings.py +++ b/titivillus/settings.py @@ -39,7 +39,6 @@ INSTALLED_APPS = [ 'quest.apps.QuestConfig', 'login.apps.LoginConfig', 'signup.apps.SignupConfig', - 'search.apps.SearchConfig', ] MIDDLEWARE = [