Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Fix bug with state = 1

Daoud Clarkea111d0ffbca7
diff --git a/mwmbl/templates/result.html b/mwmbl/templates/result.html
index b496a08..229c9ba 100644
--- a/mwmbl/templates/result.html
+++ b/mwmbl/templates/result.html
@@ -14,22 +14,16 @@
<p class='extract'>{{result.extract|format_for_query:query}}</p>
</div>
<div class="curation-buttons">
- {% if result.state.value >= 7 %}
- <button class="button move-up">↑</button>
- <button class="button move-down">↓</button>
- {% endif %}
<button class="button curate-approve{% if result.state >= 7 %} validated{% endif %}"
hx-post="/app/approve/"
hx-target=".main"
hx-include=".result"
hx-vals='{"approveUrl": "{{ result.url }}", "query": "{{ query }}"}'
- hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
+ hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>✓</button>
{% if result.state.value >= 7 %}
- ✓ Approved
- {% else %}
- ✓ Approve
+ <button class="button move-up">↑</button>
+ <button class="button move-down">↓</button>
{% endif %}
- </button>
</div>
</div>
</li>
diff --git a/mwmbl/tinysearchengine/indexer.py b/mwmbl/tinysearchengine/indexer.py
index e859638..2b6418c 100644
--- a/mwmbl/tinysearchengine/indexer.py
+++ b/mwmbl/tinysearchengine/indexer.py
@@ -34,8 +34,6 @@ class DocumentState(IntEnum):
"""
The state of the document in the index. A value of None indicates an organic search result.
"""
- # Needed to prevent Django from mangling the values
- do_not_call_in_templates = True
DELETED = -1
FROM_USER = 2
FROM_GOOGLE = 3
diff --git a/mwmbl/views.py b/mwmbl/views.py
index fe95e4b..aad11b4 100644
--- a/mwmbl/views.py
+++ b/mwmbl/views.py
@@ -158,6 +158,7 @@ def switch_state(state: Optional[DocumentState]) -> Optional[DocumentState]:
return DocumentState.FROM_USER
if state == DocumentState.ORGANIC_APPROVED:
return None
+ raise ValueError(f"Unexpected state {repr(state)}")
@require_http_methods(["POST"])
@@ -173,8 +174,6 @@ def approve(request):
assert len(urls) == len(titles) == len(extracts) == len(states) == len(scores)
- print("Got approve request", approve_url, urls, titles, extracts, states, scores)
-
documents = {}
for url, title, extract, state, score in zip(urls, titles, extracts, states, scores):
try: