1
0
Fork 0

Search is a view not an action

This commit is contained in:
Mouse Reeve 2020-05-03 21:13:43 -07:00
parent 07aab3806b
commit 7454fb7454
3 changed files with 23 additions and 21 deletions

View file

@ -1,6 +1,5 @@
''' views for actions you can take in the application '''
from io import BytesIO, TextIOWrapper
import re
from PIL import Image
from django.contrib.auth import authenticate, login, logout
@ -10,7 +9,7 @@ from django.http import HttpResponseBadRequest, HttpResponseNotFound
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from fedireads import forms, models, books_manager, outgoing
from fedireads import forms, models, outgoing
from fedireads import goodreads_import
from fedireads.settings import DOMAIN
from fedireads.views import get_user_from_username
@ -346,22 +345,6 @@ def unfollow(request):
return redirect('/user/%s' % user_slug)
@login_required
def search(request):
''' that search bar up top '''
query = request.GET.get('q')
if re.match(r'\w+@\w+.\w+', query):
# if something looks like a username, search with webfinger
results = [outgoing.handle_account_search(query)]
template = 'user_results.html'
else:
# just send the question over to book search
results = books_manager.search(query)
template = 'book_results.html'
return TemplateResponse(request, template, {'results': results})
@login_required
def clear_notifications(request):
''' permanently delete notification for user '''