django-sales is a Django app for displaying different contact details based on query parameter (with cookie). It provides sales, partners and affiliates custom links to send out to the public. It gives sales, partners and affiliates their opportunity to convert every contact detail on the website to their own. It thus encourages sales, partners and affiliates to promote the website and the business.
Use the package manager pip to install django-sales.
pip install django-sales
INSTALLED_APPS = [
'...',
'django.contrib.staticfiles',
'sales', # here
'myapp',
'...',
]
Make sure sales app is before all custom apps. Otherwise, Django will not recognize the 'sales' template tag.
MIDDLEWARE = [
'sales.middleware.sales.SalesMiddleware', # here
'django.middleware.security.SecurityMiddleware',
'...'
]
TEMPLATES = [
{
'OPTIONS': {
'context_processors': [
'...',
'django.contrib.messages.context_processors.messages',
'sales.context_processors.sales', # here
],
},
},
]
The defaults are:
SALES_LINK_PARAMETER = 'sales'
SALES_DEFAULT_ID = 1 # ?sales=1
SALES_COOKIE_NAME = 'sales'
SALES_COOKIE_MAX_AGE = 3600 # 1 hour
SALES_MODEL_FROM = 'django.contrib.auth.models'
SALES_MODEL_IMPORT = 'User' # from SALES_MODEL_FROM import SALES_MODEL_IMPORT
In version 0.0.1, django-sales makes use of django.contrib.auth.models.User model, which can be easily extended according to your needs. (e.g. Add a phone number field) From version 0.1.0, django-sales allows developer to specify the Sales model to lookup sales, partners and affiliates.
{% load static %}
{% load sales %} # here
<a href="{% sales '/' %}">Home</a>
<a href="{% sales '/contact' %}">Contact</a>
<a href="mailto:{{ sales.email }}">Email</a>
<p>{{ sales.first_name }} {{ sales.last_name }}</p>
Pull requests are welcome.