Hey, I ve implemented this replacement. You may find the patch attached Cheers, Orestis
From 4847f66d6fdb38406a13a5bec165b3caa64d4ef4 Mon Sep 17 00:00:00 2001
From: Orestis Ioannou <orestis@oioannou.com>
Date: Thu, 20 Aug 2015 09:22:01 +0200
Subject: [PATCH] vendor/debian: Replace old PTS cgi script for codesearch
Closes: #779402
---
distro_tracker/core/views.py | 16 ++++++++++++++++
distro_tracker/project/urls.py | 5 ++++-
distro_tracker/vendor/debian/tracker_panels.py | 2 +-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/distro_tracker/core/views.py b/distro_tracker/core/views.py
index c6112a7..188da7e 100644
--- a/distro_tracker/core/views.py
+++ b/distro_tracker/core/views.py
@@ -15,6 +15,7 @@ from django.shortcuts import render, redirect
from django.shortcuts import get_object_or_404
from django.http import Http404
from django.utils.decorators import method_decorator
+from django.utils.http import urlencode
from django.views.generic import View
from django.views.generic.edit import FormView
from django.views.generic.edit import UpdateView
@@ -644,3 +645,18 @@ class IndexView(TemplateView):
pass
context['application_links'] = links
return context
+
+
+class CodeSearchView(View):
+
+ def get(self, request):
+ if 'q' not in self.request.GET:
+ raise Http404
+
+ q = self.request.GET.get('q')
+ package = self.request.GET.get('package')
+ cs = 'https://codesearch.debian.net/search?'
+ search = q + ' package:' + package
+
+ url = cs + urlencode({'q': search})
+ return redirect(url)
diff --git a/distro_tracker/project/urls.py b/distro_tracker/project/urls.py
index cbe1fe8..fe5a7f4 100644
--- a/distro_tracker/project/urls.py
+++ b/distro_tracker/project/urls.py
@@ -39,6 +39,7 @@ from distro_tracker.core.views import SetMuteTeamView
from distro_tracker.core.views import SetMembershipKeywords
from distro_tracker.core.views import EditMembershipView
from distro_tracker.core.views import IndexView
+from distro_tracker.core.views import CodeSearchView
from distro_tracker.core.news_feed import PackageNewsFeed
from distro_tracker.accounts.views import ConfirmAddAccountEmail
from distro_tracker.accounts.views import LoginView
@@ -213,7 +214,9 @@ urlpatterns = patterns(
url(r'^teams/(?P<slug>.+?)/$', TeamDetailsView.as_view(),
name='dtracker-team-page'),
-
+ # code search
+ url(r'^codesearch/', CodeSearchView.as_view(),
+ name='dtracker-code-search'),
# Dedicated package page
url(r'^pkg/(?P<package_name>[^/]+)/?$',
'distro_tracker.core.views.package_page',
diff --git a/distro_tracker/vendor/debian/tracker_panels.py b/distro_tracker/vendor/debian/tracker_panels.py
index a8d436a..69a7bb5 100644
--- a/distro_tracker/vendor/debian/tracker_panels.py
+++ b/distro_tracker/vendor/debian/tracker_panels.py
@@ -132,7 +132,7 @@ class SourceCodeSearchLinks(LinksPanel.ItemProvider):
SOURCES_URL_TEMPLATE = 'https://sources.debian.net/src/{package}/{suite}/'
SEARCH_FORM_TEMPLATE = (
'<form class="code-search-form"'
- ' action="https://packages.qa.debian.org/cgi-bin/codesearch.cgi"'
+ ' action="/codesearch/"'
' method="get" target="_blank">'
'<input type="hidden" name="package" value="{package}">'
'<input type="text" name="q" placeholder="search source code">'
--
2.1.4
Attachment:
signature.asc
Description: OpenPGP digital signature