.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
{% extends 'oef/base.html' %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>Search</h2>
|
||||
|
||||
<form action="" method="post">
|
||||
<textarea name="search" rows="10" cols="50"></textarea>
|
||||
<input type="button" value="Search"
|
||||
hx-post="{% url 'oef:format_search' %}"
|
||||
hx-target="#search-results"
|
||||
>
|
||||
</form>
|
||||
|
||||
<div id="search-results"></div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,10 @@
|
||||
<ul>
|
||||
{% for entry in entries %}
|
||||
|
||||
<li>
|
||||
{{ entry.exam_code}} - {{ entry.exam_name }} (<a href='{{entry.get_absolute_url}}'>view</a>)
|
||||
</li>
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<li class="question {% if format %}named{% else %}unnamed{% endif %}">
|
||||
<span class="format-name">
|
||||
{% if format %}
|
||||
<a href='{% url "oef:format_update" format.pk %}'>{{format.name}}</a>
|
||||
Name: <a href='{% url "oef:format_update" format.pk %}'>{{format.name}}</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
<pre class="pre-question" title="{{ question }}">{{ question }}</pre>
|
||||
|
||||
@@ -20,6 +20,9 @@ urlpatterns = [
|
||||
path(
|
||||
"formats/create", views.FormatsCreateView.as_view(), name="format_create"
|
||||
),
|
||||
path(
|
||||
"formats/search", views.format_search, name="format_search"
|
||||
),
|
||||
path(
|
||||
"entries/replace_questions", views.replace_questions, name="replace_questions"
|
||||
),
|
||||
|
||||
@@ -95,6 +95,17 @@ def entries(request):
|
||||
entries = Entry.objects.all().order_by("exam_code")
|
||||
return render(request, "oef/entries.html", {"entries": entries})
|
||||
|
||||
def format_search(request):
|
||||
if request.method == "POST":
|
||||
search = request.POST.get("search")
|
||||
|
||||
entries = Entry.objects.filter(questions__icontains=search)
|
||||
|
||||
|
||||
|
||||
return render(request, "oef/format_search_results.html", {"entries": entries})
|
||||
return render(request, "oef/format_search.html",)
|
||||
|
||||
|
||||
def questions(request):
|
||||
questions = set(Entry.objects.filter(inactive=False).values_list("questions", flat=True))
|
||||
|
||||
Reference in New Issue
Block a user