Skip to content

Commit

Permalink
change in the file view.py and util.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tchagau committed Dec 16, 2020
1 parent cf581a8 commit 78ca072
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Binary file modified encyclopedia/__pycache__/util.cpython-38.pyc
Binary file not shown.
Binary file modified encyclopedia/__pycache__/views.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion encyclopedia/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def get_entry(title):
f = default_storage.open(f"entries/{title}.md")
return f.read().decode("utf-8")
except FileNotFoundError:
raise Http404("File not Found")
raise Http404("File not Found")
13 changes: 7 additions & 6 deletions encyclopedia/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import markdown2
import random
import re

from . import util

Expand Down Expand Up @@ -37,16 +38,16 @@ def search(request):
query = request.GET.get('q')
entries = util.list_entries()
for title in entries:
if query == title:
r = detail(request,title)
if (query.upper() == title or query.lower() == title or query.capitalize() == title):
return detail(request,title)
break
elif query in title:
r = render(request, "encyclopedia/search.html", { "entries": entries, "query": query})
return render(request, "encyclopedia/search.html", { "entries": entries, "query": query})
break
#else:
# return HttpResponse ("Entry not found")

return r
# r = HttpResponse ("Entry not found")
# break
return HttpResponse ("Entry not found")

# view to create new pages
def new(request):
Expand Down

0 comments on commit 78ca072

Please sign in to comment.