Display different contact details based on query parameter and cookie
Project description
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.
Installation
Use the package manager pip to install django-sales.
pip install django-sales
Usage
Step 1. Add sales app (in settings.py file)
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.
Step 2. Add sales middleware (in settings.py file)
MIDDLEWARE = [
'sales.middleware.sales.SalesMiddleware', # here
'django.middleware.security.SecurityMiddleware',
'...'
]
Step 3. Add sales context processors (in settings.py file)
TEMPLATES = [
{
'OPTIONS': {
'context_processors': [
'...',
'django.contrib.messages.context_processors.messages',
'sales.context_processors.sales', # here
],
},
},
]
Step 4. Customize sales settings (in settings.py file) (optional)
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.
Step 4. Load sales tag (in any .html file)
{% load static %}
{% load sales %} # here
Step 5. Build sales links (in any .html file)
<a href="{% sales '/' %}">Home</a>
<a href="{% sales '/contact' %}">Contact</a>
Step 6. Display sales information (in any .html file)
<a href="mailto:{{ sales.email }}">Email</a>
<p>{{ sales.first_name }} {{ sales.last_name }}</p>
Contributing
Pull requests are welcome.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-sales-0.1.2.tar.gz
.
File metadata
- Download URL: django-sales-0.1.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba6dfbef9e31882bc7cedcb510d20b8d596bb59db05bf1ecd0b61855117e733c |
|
MD5 | cc6372e3afc4004bc20df40e0f96fe96 |
|
BLAKE2b-256 | 6f3742fdc66eaea67dd6aa4c4f36d377fe65630a3098a4fd6b1c11e79285cac8 |
File details
Details for the file django_sales-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: django_sales-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 556c7c70f72da32dff1e58f8a34c554159fb06eac56797626a2e5679f7596ffe |
|
MD5 | 0408bd3e99f2bb660eb2eb9011baec95 |
|
BLAKE2b-256 | a6f8813e7a9fcbd217af7fd3c8de5fd5e05ec6f83c86760b5ce182c27f0bd720 |