An open source, non-profit web search engine
Disable curation for non-logged in users
Daoud Clarke0e0b8b49195b
diff --git a/mwmbl/templates/result.html b/mwmbl/templates/result.htmlindex 7d4f49d..65064b3 100644--- a/mwmbl/templates/result.html+++ b/mwmbl/templates/result.html@@ -13,12 +13,14 @@</a><p class='extract'>{{result.extract|format_for_query:query}}</p></div>- <div class="curation-buttons">- <button class="button curate-approve{% if result.state >= 7 %} validated{% endif %}"- hx-post="/app/approve/"- hx-target=".main"- hx-include=".result,[name='csrfmiddlewaretoken']"- hx-vals='{"approve_url": "{{ result.url }}", "query": "{{ query }}"{% if curation %}, "curation_id": {{ curation.id }}{% endif %}}'>✓</button>+ {% if user.is_authenticated %}+ <div class="curation-buttons">+ <button class="button curate-approve{% if result.state >= 7 %} validated{% endif %}"+ hx-post="/app/approve/"+ hx-target=".main"+ hx-include=".result,[name='csrfmiddlewaretoken']"+ hx-vals='{"approve_url": "{{ result.url }}", "query": "{{ query }}"{% if curation %}, "curation_id": {{ curation.id }}{% endif %}}'>✓</button>+ </div></div>- </div>+ {% endif %}</li>diff --git a/mwmbl/views.py b/mwmbl/views.pyindex 33a2402..36202a2 100644--- a/mwmbl/views.py+++ b/mwmbl/views.py@@ -7,6 +7,7 @@ from urllib.parse import urlencodeimport justextimport requestsfrom django.conf import settings+from django.contrib.auth.decorators import login_requiredfrom django.http import HttpResponseBadRequestfrom django.shortcuts import renderfrom django.views.decorators.http import require_http_methods@@ -110,6 +111,7 @@ def _get_results_and_activity(request):return activity, query, results+@login_required@require_http_methods(["POST"])def add_url(request):new_url = request.POST["new_url"]@@ -160,6 +162,7 @@ def switch_state(state: Optional[DocumentState]) -> Optional[DocumentState]:raise ValueError(f"Unexpected state {repr(state)}")+@login_required@require_http_methods(["POST"])def approve(request):approve_url = request.POST.get("approve_url")@@ -196,6 +199,7 @@ def approve(request):return response+@login_required@require_http_methods(["POST"])def revert_current_curation(request):curation_id = request.POST.get("curation_id")