Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Minimum viable product

  • Loading branch information...
commit 65a0b60a1997e2f1b949b7eecf9d2bc20fd96f42 0 parents
David Winterbottom authored July 09, 2012
2  MANIFEST.in
... ...
@@ -0,0 +1,2 @@
  1
+include *.rst
  2
+recursive-include paypal/express/templates/paypal *.txt *.html
30  README.rst
Source Rendered
... ...
@@ -0,0 +1,30 @@
  1
+============================
  2
+Jirafe integration for Oscar
  3
+============================
  4
+
  5
+This is an extension for `django-oscar`_ that makes integration with the
  6
+`Jirafe`_ e-commerce tracking easy.
  7
+
  8
+.. _`django-oscar`: http://oscarcommerce.com
  9
+.. _`Jirafe`: http://jirafe.com/
  10
+
  11
+Installation
  12
+------------
  13
+
  14
+Install from Github (not on PyPi yet)::
  15
+
  16
+    pip install git+git://github.com/tangentlabs/django-oscar-jirafe.git#egg=django-oscar-jirafe
  17
+
  18
+Now add ``jirafe`` to your ``INSTALLED_APPS`` and update your
  19
+``TEMPLATE_CONTEXT_PROCESSORS`` to include ``jirafe.context_processors.jirafe``.
  20
+Also, set ``JIRAFE_ID`` to be your Jirafe ID.
  21
+
  22
+Finally, you need to include the tracking javascript in your templates.  You can
  23
+do this by including::
  24
+
  25
+    {% include 'jirafe/tracking.html' %} 
  26
+
  27
+within your ``base.html`` template.  An example ``base.html`` is included which
  28
+you can copy into place to get you started.
  29
+
  30
+That's it - the stats should start appearing in your Jirafe dashboard.
0  jirafe/__init__.py
No changes.
10  jirafe/context_processors.py
... ...
@@ -0,0 +1,10 @@
  1
+from django.conf import settings
  2
+
  3
+
  4
+def jirafe(request):
  5
+    """
  6
+    Add variables to indicate when to submit variables to Jirafe
  7
+    """
  8
+    return {
  9
+        'JIRAFE_ID': settings.JIRAFE_ID
  10
+    }
0  jirafe/models.py
No changes.
6  jirafe/templates/base.html
... ...
@@ -0,0 +1,6 @@
  1
+{% extends 'templates/base.html' %}
  2
+
  3
+{% block extrascripts %}
  4
+	{{ block.super }}
  5
+	{% include 'jirafe/tracking.html' %}
  6
+{% endblock %}
64  jirafe/templates/jirafe/tracking.html
... ...
@@ -0,0 +1,64 @@
  1
+<script type="text/javascript">
  2
+	var jirafe = { "id": {{ JIRAFE_ID }}};
  3
+
  4
+	{% if product %}
  5
+		jirafe.product = {
  6
+			"sku": "{{ product.stockrecord.partner_sku|escapejs }}",
  7
+			"name": "{{ product.get_title|escapejs }}",
  8
+			"price": "{{ product.stockrecord.price_incl_tax }}",
  9
+			"categories": [{% for category in product.categories.all %}"{{ category.name|escapejs }}",{% endfor %}]
  10
+		};
  11
+	{% endif %}
  12
+
  13
+	{% if category %}
  14
+		jirafe.category = {
  15
+			"name": "{{ category.name|escapejs }}"
  16
+		};
  17
+	{% endif %}
  18
+
  19
+	{# Using voucher_form as a proxy for when we're on the basket page #}
  20
+	{% if voucher_form %}
  21
+		jirafe.cart = {
  22
+			"total": "{{ basket.total_incl_tax }}",
  23
+			"products": [
  24
+				{% for line in basket.lines.all %}
  25
+				{
  26
+				"sku": "{{ line.product.stockrecord.partner_sku|escapejs }}",
  27
+				"name": "{{ line.product.get_title|escapejs }}",
  28
+				"qty": "{{ line.quantity }}",
  29
+				"price": "{{ line.product.stockrecord.price_incl_tax }}",
  30
+				"category": ""
  31
+				},
  32
+				{% endfor %}
  33
+			]
  34
+		};
  35
+	{% endif %}
  36
+
  37
+	{% if order %}
  38
+		jirafe.confirm = {
  39
+			"orderid": "{{ order.number|escapejs }}",
  40
+			"total": "{{ order.total_incl_tax }}",
  41
+			"shipping": "{{ order.shipping_incl_tax }}",
  42
+			"tax": "{{ order.total_tax }}",
  43
+			"discount": "0.00",
  44
+			"subtotal": "{{ order.basket_total_incl_tax }}",
  45
+			"products": [
  46
+			{% for line in order.lines.all %}
  47
+				{
  48
+				"sku": "{{ line.product.stockrecord.partner_sku|escapejs }}",
  49
+				"name": "{{ line.product.get_title|escapejs }}",
  50
+				"qty": "{{ line.quantity }}",
  51
+				"price": "{{ line.product.stockrecord.price_incl_tax }}",
  52
+				"category": ""
  53
+				},
  54
+			{% endfor %}
  55
+			]
  56
+		};
  57
+	{% endif %}
  58
+
  59
+	(function(){
  60
+		var d=document,g=d.createElement('script'),s=d.getElementsByTagName('script')[0];
  61
+		g.type='text/javascript';g.defer=g.async=true;g.src=d.location.protocol+'//c.jirafe.com/jirafe.js';
  62
+		s.parentNode.insertBefore(g, s);
  63
+	})();
  64
+</script>
10  sandbox/manage.py
... ...
@@ -0,0 +1,10 @@
  1
+#!/usr/bin/env python
  2
+import os
  3
+import sys
  4
+
  5
+if __name__ == "__main__":
  6
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
  7
+
  8
+    from django.core.management import execute_from_command_line
  9
+
  10
+    execute_from_command_line(sys.argv)
216  sandbox/settings.py
... ...
@@ -0,0 +1,216 @@
  1
+import os
  2
+
  3
+# Django settings for oscar project.
  4
+PROJECT_DIR = os.path.dirname(__file__)
  5
+location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
  6
+
  7
+DEBUG = True
  8
+TEMPLATE_DEBUG = True
  9
+SQL_DEBUG = True
  10
+
  11
+ADMINS = (
  12
+    # ('Your Name', 'your_email@domain.com'),
  13
+)
  14
+EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  15
+
  16
+MANAGERS = ADMINS
  17
+
  18
+DATABASES = {
  19
+    'default': {
  20
+        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
  21
+        'NAME': 'db.sqlite',                      # Or path to database file if using sqlite3.
  22
+        'USER': '',                      # Not used with sqlite3.
  23
+        'PASSWORD': '',                  # Not used with sqlite3.
  24
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
  25
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
  26
+    }
  27
+}
  28
+
  29
+# Local time zone for this installation. Choices can be found here:
  30
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  31
+# although not all choices may be available on all operating systems.
  32
+# On Unix systems, a value of None will cause Django to use the same
  33
+# timezone as the operating system.
  34
+# If running in a Windows environment this must be set to the same as your
  35
+# system time zone.
  36
+TIME_ZONE = 'Europe/London'
  37
+
  38
+# Language code for this installation. All choices can be found here:
  39
+# http://www.i18nguy.com/unicode/language-identifiers.html
  40
+LANGUAGE_CODE = 'en-us'
  41
+
  42
+SITE_ID = 1
  43
+
  44
+# If you set this to False, Django will make some optimizations so as not
  45
+# to load the internationalization machinery.
  46
+USE_I18N = True
  47
+
  48
+# If you set this to False, Django will not format dates, numbers and
  49
+# calendars according to the current locale
  50
+USE_L10N = True
  51
+
  52
+# Absolute path to the directory that holds media.
  53
+# Example: "/home/media/media.lawrence.com/"
  54
+MEDIA_ROOT = location("assets")
  55
+
  56
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
  57
+# trailing slash if there is a path component (optional in other cases).
  58
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
  59
+MEDIA_URL = '/media/'
  60
+
  61
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  62
+# trailing slash.
  63
+# Examples: "http://foo.com/media/", "/media/".
  64
+#ADMIN_MEDIA_PREFIX = '/media/admin/'
  65
+
  66
+STATIC_URL = '/static/'
  67
+STATICFILES_DIRS = (location('static/'),)
  68
+STATIC_ROOT = location('public')
  69
+
  70
+# Make this unique, and don't share it with anybody.
  71
+SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  72
+
  73
+# List of callables that know how to import templates from various sources.
  74
+TEMPLATE_LOADERS = (
  75
+    'django.template.loaders.filesystem.Loader',
  76
+    'django.template.loaders.app_directories.Loader',
  77
+#     'django.template.loaders.eggs.Loader',
  78
+)
  79
+
  80
+TEMPLATE_CONTEXT_PROCESSORS = (
  81
+    "django.contrib.auth.context_processors.auth",
  82
+    "django.core.context_processors.request",
  83
+    "django.core.context_processors.debug",
  84
+    "django.core.context_processors.i18n",
  85
+    "django.core.context_processors.media",
  86
+    "django.core.context_processors.static",
  87
+    "django.contrib.messages.context_processors.messages",
  88
+    # Oscar specific
  89
+    'oscar.apps.search.context_processors.search_form',
  90
+    'oscar.apps.promotions.context_processors.promotions',
  91
+    'oscar.apps.checkout.context_processors.checkout',
  92
+    'oscar.core.context_processors.metadata',
  93
+    'jirafe.context_processors.jirafe',
  94
+) 
  95
+
  96
+MIDDLEWARE_CLASSES = (
  97
+    'django.middleware.common.CommonMiddleware',
  98
+    'django.contrib.sessions.middleware.SessionMiddleware',
  99
+    'django.middleware.csrf.CsrfViewMiddleware',
  100
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
  101
+    'django.contrib.messages.middleware.MessageMiddleware',
  102
+    'django.middleware.transaction.TransactionMiddleware',
  103
+    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  104
+    'debug_toolbar.middleware.DebugToolbarMiddleware',
  105
+    'oscar.apps.basket.middleware.BasketMiddleware',
  106
+)
  107
+
  108
+INTERNAL_IPS = ('127.0.0.1',)
  109
+
  110
+ROOT_URLCONF = 'urls'
  111
+
  112
+from oscar import OSCAR_PARENT_TEMPLATE_DIR
  113
+TEMPLATE_DIRS = (
  114
+    location('templates'),
  115
+    os.path.join(OSCAR_PARENT_TEMPLATE_DIR, 'templates'),
  116
+    OSCAR_PARENT_TEMPLATE_DIR,
  117
+)
  118
+
  119
+# A sample logging configuration. The only tangible logging
  120
+# performed by this configuration is to send an email to
  121
+# the site admins on every HTTP 500 error.
  122
+# See http://docs.djangoproject.com/en/dev/topics/logging for
  123
+# more details on how to customize your logging configuration.
  124
+LOGGING = {
  125
+    'version': 1,
  126
+    'disable_existing_loggers': False,
  127
+    'formatters': {
  128
+        'verbose': {
  129
+            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
  130
+        },
  131
+        'simple': {
  132
+            'format': '%(levelname)s %(message)s'
  133
+        },
  134
+    },
  135
+    'handlers': {
  136
+        'null': {
  137
+            'level':'DEBUG',
  138
+            'class':'django.utils.log.NullHandler',
  139
+        },
  140
+        'console':{
  141
+            'level':'DEBUG',
  142
+            'class':'logging.StreamHandler',
  143
+            'formatter': 'verbose'
  144
+        },
  145
+        'mail_admins': {
  146
+            'level': 'ERROR',
  147
+            'class': 'django.utils.log.AdminEmailHandler',
  148
+        },
  149
+    },
  150
+    'loggers': {
  151
+        'django': {
  152
+            'handlers':['null'],
  153
+            'propagate': True,
  154
+            'level':'INFO',
  155
+        },
  156
+        'django.request': {
  157
+            'handlers': ['mail_admins'],
  158
+            'level': 'ERROR',
  159
+            'propagate': False,
  160
+        },
  161
+        'oscar.checkout': {
  162
+            'handlers': ['console'],
  163
+            'propagate': True,
  164
+            'level':'INFO',
  165
+        },
  166
+        'django.db.backends': {
  167
+            'handlers':['null'],
  168
+            'propagate': False,
  169
+            'level':'DEBUG',
  170
+        },
  171
+    }
  172
+}
  173
+
  174
+
  175
+INSTALLED_APPS = [
  176
+    'django.contrib.auth',
  177
+    'django.contrib.contenttypes',
  178
+    'django.contrib.sessions',
  179
+    'django.contrib.sites',
  180
+    'django.contrib.messages',
  181
+    'django.contrib.admin',
  182
+    'django.contrib.flatpages',
  183
+    'django.contrib.staticfiles',
  184
+    # External apps
  185
+    'django_extensions',
  186
+    'debug_toolbar',
  187
+    'haystack',
  188
+    'sorl.thumbnail',
  189
+    'south',
  190
+    'jirafe',
  191
+]
  192
+
  193
+from oscar import get_core_apps
  194
+INSTALLED_APPS += get_core_apps()
  195
+
  196
+AUTHENTICATION_BACKENDS = (
  197
+    'oscar.apps.customer.auth_backends.Emailbackend',
  198
+    'django.contrib.auth.backends.ModelBackend',
  199
+)
  200
+
  201
+LOGIN_REDIRECT_URL = '/accounts/'
  202
+APPEND_SLASH = True
  203
+
  204
+DEBUG_TOOLBAR_CONFIG = {
  205
+    'INTERCEPT_REDIRECTS': False
  206
+}
  207
+
  208
+# Oscar settings
  209
+from oscar.defaults import *
  210
+OSCAR_ALLOW_ANON_CHECKOUT = True
  211
+
  212
+# Haystack settings
  213
+HAYSTACK_SITECONF = 'oscar.search_sites'
  214
+HAYSTACK_SEARCH_ENGINE = 'dummy'
  215
+
  216
+JIRAFE_ID = '40854'
6  sandbox/templates/base.html
... ...
@@ -0,0 +1,6 @@
  1
+{% extends 'templates/base.html' %}
  2
+
  3
+{% block extrascripts %}
  4
+	{{ block.super }}
  5
+	{% include 'jirafe/tracking.html' %}
  6
+{% endblock %}
22  sandbox/urls.py
... ...
@@ -0,0 +1,22 @@
  1
+from django.conf.urls.defaults import *
  2
+from django.conf import settings
  3
+from django.contrib import admin
  4
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  5
+from django.conf.urls.static import static
  6
+from django.views.generic import TemplateView
  7
+
  8
+from oscar.app import shop
  9
+
  10
+admin.autodiscover()
  11
+
  12
+urlpatterns = patterns('',
  13
+    (r'^admin/', include(admin.site.urls)),
  14
+    (r'', include(shop.urls)),
  15
+)
  16
+if settings.DEBUG:
  17
+    urlpatterns += staticfiles_urlpatterns()
  18
+    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  19
+    urlpatterns += patterns('',
  20
+        url(r'^404$', TemplateView.as_view(template_name='404.html')),
  21
+        url(r'^500$', TemplateView.as_view(template_name='500.html')),
  22
+    )
23  setup.py
... ...
@@ -0,0 +1,23 @@
  1
+#!/usr/bin/env python
  2
+from setuptools import setup, find_packages
  3
+
  4
+setup(name='django-oscar-jirafe',
  5
+      version='0.1',
  6
+      url='https://github.com/tangentlabs/django-oscar-jirafe',
  7
+      author="David Winterbottom",
  8
+      author_email="david.winterbottom@tangentlabs.co.uk",
  9
+      description="Jirafe module for django-oscar",
  10
+      long_description=open('README.rst').read(),
  11
+      keywords="Payment, Jirafe",
  12
+      license='BSD',
  13
+      packages=find_packages(),
  14
+      include_package_data = True,
  15
+      # See http://pypi.python.org/pypi?%3Aaction=list_classifiers
  16
+      classifiers=['Environment :: Web Environment',
  17
+                   'Framework :: Django',
  18
+                   'Intended Audience :: Developers',
  19
+                   'License :: OSI Approved :: BSD License',
  20
+                   'Operating System :: Unix',
  21
+                   'Programming Language :: Python'],
  22
+      install_requires=['django-oscar>=0.2']
  23
+     )

0 notes on commit 65a0b60

Krzysztof Szularz

Are you sure last semicolon won't blow up IE?

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