Skip to main content

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 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

MIT

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

django-sales-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

django_sales-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file django-sales-0.1.0.tar.gz.

File metadata

  • Download URL: django-sales-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 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

Hashes for django-sales-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e6f5ecfb3dd401504d56f21ee136225f1158408208dda9517c297e2f33c7e410
MD5 a9a0013128662e78ab67c322e44a70f2
BLAKE2b-256 758a4b0d67896686852f7940d858f31e1aeafc373d19cc226f9f4d6ea7ccdffa

See more details on using hashes here.

File details

Details for the file django_sales-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_sales-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 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

Hashes for django_sales-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d927e89a9916107b48a3cff1e12cc37a60e964f7ffd7c46b357dfbd0b179626
MD5 8a2c04d6ac093875eaa140ea6ae3f74c
BLAKE2b-256 66333bff5573fc22321fe54da567f82e2c56b4d7cde6c508f3d56d3599eb8bd6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page