Skip to content
Browse files

refactor to drop use of preferences

  • Loading branch information...
1 parent 98829d1 commit c85986b535802aa02348858ea78f6776f0f35fe5 Shaun Sephton committed
View
19 README.rst
@@ -8,8 +8,23 @@ Django Google Search
Installation
------------
-#. Install ``django-preferences`` as described `here <http://pypi.python.org/pypi/django-preferences#id6>`_.
-
#. Install or add ``django-googlesearch`` to your Python path.
#. Add ``googlesearch`` to your ``INSTALLED_APPS`` setting.
+
+#. Add a ``GOOGLE_SEARCH_PARTNER_ID`` setting to your project's ``settings.py`` file. This setting specifies the Google Custom Search Engine ID to use when rendering the Google search box, as provided by Google, i.e.::
+
+ GOOGLE_SEARCH_PARTNER_ID = 'partner-pub-329847239847234:xcvx-3kasd'
+
+#. Add googlesearch url include to your project's ``urls.py`` file::
+
+ (r'^search/', include('googlesearch.urls')),
+
+#. Optionally add ``"django.core.context_processors.request",`` to your ``TEMPLATE_CONTEXT_PROCESSORS`` setting, i.e.::
+
+ TEMPLATE_CONTEXT_PROCESSORS = (
+ ...other processors...
+ "django.core.context_processors.request",
+ )
+
+
View
5 googlesearch/admin.py
@@ -1,5 +0,0 @@
-from django.contrib import admin
-
-from googlesearch.models import GoogleSearchPreferences
-
-admin.site.register(GoogleSearchPreferences)
View
17 googlesearch/models.py
@@ -1,17 +0,0 @@
-from django.db import models
-
-from preferences.models import Preferences
-
-class GoogleSearchPreferences(Preferences):
- __module__ = 'preferences.models'
-
- partner_id = models.CharField(
- max_length=128,
- help_text="Google custom search partner ID, i.e. partner-pub-324234324:dsfhk3dskf.",
- blank=True,
- null=True,
- )
-
- class Meta():
- verbose_name = "Google search preferences"
- verbose_name_plural = "Google search preferences"
View
4 googlesearch/templates/googlesearch/inclusion_tags/googlesearch_input.html
@@ -1,7 +1,7 @@
-{% if preferences.GoogleSearchPreferences.partner_id %}
+{% if google_search_partner_id %}
<form id="frmSearch" action="{% url googlesearch_results %}" id="cref_iframe" class="search">
<p>
- <input name="cx" value="{{ preferences.GoogleSearchPreferences.partner_id }}" type="hidden">
+ <input name="cx" value="{{ google_search_partner_id }}" type="hidden">
<input name="cof" value="FORID:11" type="hidden">
<input name="ie" value="ISO-8859-1" type="hidden">
<input type="text" name="q" value="{% if request.GET.q %}{{ request.GET.q }}{% else %}Search{% endif %}" class="search_txt" onfocus="if (this.value == '{% if request.GET.q %}{{ request.GET.q }}{% else %}Search{% endif %}') {this.value = '';}" onblur="if (this.value == '') {this.value = '{% if request.GET.q %}{{ request.GET.q }}{% else %}Search{% endif %}';}" />
View
6 googlesearch/templatetags/googlesearch_inclusion_tags.py
@@ -1,11 +1,13 @@
from django import template
-
-from preferences import preferences
+from django.conf import settings
register = template.Library()
@register.inclusion_tag('googlesearch/inclusion_tags/googlesearch_input.html', takes_context=True)
def googlesearch_input(context):
+ context.update({
+ 'google_search_partner_id': settings.GOOGLE_SEARCH_PARTNER_ID
+ })
return context
@register.inclusion_tag('googlesearch/inclusion_tags/googlesearch_results.html')
View
3 setup.py
@@ -10,9 +10,6 @@
license='BSD',
url='http://github.com/praekelt/django-googlesearch',
packages = find_packages(),
- install_requires = [
- 'django-preferences',
- ],
include_package_data=True,
classifiers = [
"Programming Language :: Python",

0 comments on commit c85986b

Please sign in to comment.
Something went wrong with that request. Please try again.