Skip to main content

Abstract Django referral library: models registry, attribution service, reward ledger helpers

Project description

referral-system (abstract referral package)

This wheel ships only the Django app package referral: abstract referral models, referral.model_registry, ReferralAttributionService, and related helpers.

It does not include referral_program or any product-specific InstaMoney glue (loan, user, etc.). Host projects must define concrete models subclassing referral.models abstracts and point settings.REFERRAL_MODELS at those models.


Install (private index)

Build locally:

pip install build twine
python -m build

Upload to your private PyPI-compatible registry (GitHub Packages, CodeArtifact, Devpi, etc.):

twine upload --repository-url https://YOUR_REGISTRY/simple dist/*

Consumers:

pip install referral-system --extra-index-url https://TOKEN@YOUR_REGISTRY/simple

Django settings

INSTALLED_APPS

Add referral before any app that defines concrete referral models registered via REFERRAL_MODELS:

INSTALLED_APPS = [
    # ...
    "referral",
    "your_app_with_concrete_referral_models",
]

REFERRAL_MODELS

Map logical roles to your concrete models (app_label + model_name):

REFERRAL_MODELS = {
    "attribution": {
        "app_label": "your_app_with_concrete_referral_models",
        "model_name": "ReferralAttribution",
    },
    "scheme": {
        "app_label": "your_app_with_concrete_referral_models",
        "model_name": "ReferralScheme",
    },
    "code_map": {
        "app_label": "your_app_with_concrete_referral_models",
        "model_name": "ReferralCodeMap",
    },
    "reward_transaction": {
        "app_label": "your_app_with_concrete_referral_models",
        "model_name": "ReferralRewardTransaction",
    },
}

Concrete classes must subclass:

  • referral.models.AbstractReferralAttribution
  • referral.models.AbstractReferralScheme
  • referral.models.AbstractReferralCodeMap
  • referral.models.AbstractReferralRewardTransaction

Run migrate in the host app that owns those tables.

Reward transaction entity fields (0.2.0+)

AbstractReferralRewardTransaction includes generic ledger reference columns:

Field Purpose
transaction_context_type Business context (e.g. REFERRAL_ATTRIBUTION, CAMPAIGN_REWARD)
transaction_context_id PK of that context object
transaction_party Party within the context (e.g. referrer, referee, winner)

Status lifecycle includes INITIATED, PENDING, COMPLETED, FAILED, TIMEOUT, REVERSED.

Use referral.services.referral_reward_transaction_helper for inserts and entity-scoped queries.


Dependencies

Declared in pyproject.toml: Django, djangorestframework, pydantic (used by optional schema paths).

The referral package imports shared.helper.shared_models (DefaultTimeStamp on abstracts). Either:

  • vendor a compatible DefaultTimeStamp base in your project and adjust forked abstracts, or
  • keep shared on PYTHONPATH / install your internal shared package alongside this wheel.

Same applies if you copy code that referenced other internal modules—this PyPI distribution contains only referral/.


Versioning

Bump version in pyproject.toml before each release; rebuild and re-upload the wheel.


Publishing to PyPI.org

Step-by-step (tokens, TestPyPI, production upload, GitHub Actions): PYPI_PUBLISH.md.

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

referral_system-0.2.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

referral_system-0.2.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file referral_system-0.2.2.tar.gz.

File metadata

  • Download URL: referral_system-0.2.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for referral_system-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2c632baa7cc5cdd50212d16429595c33ebf52fa5657c2b313b559ea8dac7228d
MD5 16cf6bcfe72e15644a20bc4f82403d3f
BLAKE2b-256 8a8132dbf66cc71a8feff852cecf88b71488d9223dc91ee0d452e7b70ce22477

See more details on using hashes here.

File details

Details for the file referral_system-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for referral_system-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6482b0b93c275372ccd8720b59f5dd94335292467db482e86d3eaaef2024513a
MD5 467bb93f0abcd5eacb555d95e350d81f
BLAKE2b-256 58dc994f8c2392aa78e21ef04856e257c4aebd52d391b8e39e73fd422270341b

See more details on using hashes here.

Supported by

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