Quellcode durchsuchen

A single search result ends in a redirect to the page

master
Dirk Alders vor 1 Monat
Ursprung
Commit
a6277fc1e2
1 geänderte Dateien mit 12 neuen und 9 gelöschten Zeilen
  1. 12
    9
      pages/views.py

+ 12
- 9
pages/views.py Datei anzeigen

@@ -270,15 +270,18 @@ def search(request):
270 270
     if sr is None:
271 271
         django_messages.error(request, _('Invalid search pattern: %s') % repr(search_txt))
272 272
         sr = []
273
-    pl = page_list([PikiPage.objects.get(rel_path=rel_path) for rel_path in set(sr)])
274
-    #
275
-    context_adaption(
276
-        context,
277
-        request,
278
-        title=_("Searchresults"),
279
-        page_content=mycreole.render_simple(pl.creole_list())
280
-    )
281
-    return render(request, 'pages/page.html', context=context)
273
+    if len(sr) == 1:
274
+        return HttpResponseRedirect(url_page(sr[0]))
275
+    else:
276
+        pl = page_list([PikiPage.objects.get(rel_path=rel_path) for rel_path in set(sr)])
277
+        #
278
+        context_adaption(
279
+            context,
280
+            request,
281
+            title=_("Searchresults"),
282
+            page_content=mycreole.render_simple(pl.creole_list())
283
+        )
284
+        return render(request, 'pages/page.html', context=context)
282 285
 
283 286
 
284 287
 def helpview(request, page='main'):

Laden…
Abbrechen
Speichern