django-referral-system 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django-referral-system-0.1/LICENSE +20 -0
- django-referral-system-0.1/MANIFEST.in +7 -0
- django-referral-system-0.1/PKG-INFO +30 -0
- django-referral-system-0.1/README.md +27 -0
- django-referral-system-0.1/django_referral_system.egg-info/PKG-INFO +30 -0
- django-referral-system-0.1/django_referral_system.egg-info/SOURCES.txt +43 -0
- django-referral-system-0.1/django_referral_system.egg-info/dependency_links.txt +1 -0
- django-referral-system-0.1/django_referral_system.egg-info/requires.txt +5 -0
- django-referral-system-0.1/django_referral_system.egg-info/top_level.txt +1 -0
- django-referral-system-0.1/pyproject.toml +3 -0
- django-referral-system-0.1/referrals/__init__.py +0 -0
- django-referral-system-0.1/referrals/admin.py +52 -0
- django-referral-system-0.1/referrals/apps.py +7 -0
- django-referral-system-0.1/referrals/choices.py +19 -0
- django-referral-system-0.1/referrals/config.py +13 -0
- django-referral-system-0.1/referrals/dtos/__init__.py +0 -0
- django-referral-system-0.1/referrals/dtos/base_dto.py +6 -0
- django-referral-system-0.1/referrals/dtos/promoters_dtos.py +66 -0
- django-referral-system-0.1/referrals/enums.py +17 -0
- django-referral-system-0.1/referrals/exceptions.py +16 -0
- django-referral-system-0.1/referrals/helpers.py +9 -0
- django-referral-system-0.1/referrals/migrations/0001_initial.py +107 -0
- django-referral-system-0.1/referrals/migrations/0002_alter_payoutmethod_method_and_more.py +28 -0
- django-referral-system-0.1/referrals/migrations/__init__.py +0 -0
- django-referral-system-0.1/referrals/migrations/__pycache__/0001_initial.cpython-310.pyc +0 -0
- django-referral-system-0.1/referrals/migrations/__pycache__/__init__.cpython-310.pyc +0 -0
- django-referral-system-0.1/referrals/models.py +138 -0
- django-referral-system-0.1/referrals/repositories/__init__.py +11 -0
- django-referral-system-0.1/referrals/repositories/base_repository.py +79 -0
- django-referral-system-0.1/referrals/repositories/promoter_commission_repository.py +31 -0
- django-referral-system-0.1/referrals/repositories/promoter_payout_repository.py +19 -0
- django-referral-system-0.1/referrals/repositories/promoter_repository.py +27 -0
- django-referral-system-0.1/referrals/repositories/referral_repository.py +16 -0
- django-referral-system-0.1/referrals/serializers.py +116 -0
- django-referral-system-0.1/referrals/services/__init__.py +7 -0
- django-referral-system-0.1/referrals/services/promoter_payout_service.py +201 -0
- django-referral-system-0.1/referrals/services/promoter_service.py +41 -0
- django-referral-system-0.1/referrals/services/referral_service.py +227 -0
- django-referral-system-0.1/referrals/tests.py +420 -0
- django-referral-system-0.1/referrals/urls.py +10 -0
- django-referral-system-0.1/referrals/utils.py +28 -0
- django-referral-system-0.1/referrals/views.py +174 -0
- django-referral-system-0.1/setup.cfg +41 -0
- django-referral-system-0.1/setup.py +3 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2012-2024 Serhii Soldatov and others
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: django-referral-system
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A Django app for managing referral programs, promoters, referrals, and tracking referral performance with advanced features like commission setting, invitation management, and Wise payouts.
|
|
5
|
+
Home-page: https://github.com/soldatov-ss/django-referral-system.git
|
|
6
|
+
Author: Soldatov Serhii
|
|
7
|
+
Author-email: soldatov.own@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Environment :: Web Environment
|
|
10
|
+
Classifier: Framework :: Django
|
|
11
|
+
Classifier: Framework :: Django :: 4
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: Django>=4.1
|
|
27
|
+
Requires-Dist: djangorestframework>=3.14
|
|
28
|
+
Requires-Dist: pandas>=2.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0
|
|
30
|
+
Requires-Dist: python-dotenv>=1.0
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
============
|
|
2
|
+
django-referrals
|
|
3
|
+
============
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Detailed documentation is in the "docs" directory.
|
|
8
|
+
|
|
9
|
+
Quick start
|
|
10
|
+
-----------
|
|
11
|
+
|
|
12
|
+
1. Add "referrals" to your INSTALLED_APPS setting like this::
|
|
13
|
+
|
|
14
|
+
INSTALLED_APPS = [
|
|
15
|
+
...,
|
|
16
|
+
"referrals",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
2. Include the polls URLconf in your project urls.py like this::
|
|
20
|
+
|
|
21
|
+
path("referrals/", include("django-referrals.urls")),
|
|
22
|
+
|
|
23
|
+
3. Run ``python manage.py migrate`` to create the models.
|
|
24
|
+
|
|
25
|
+
4. Start the development server and visit the admin to create a poll.
|
|
26
|
+
|
|
27
|
+
5. Visit the ``/referrals/`` URL to participate in the poll.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: django-referral-system
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A Django app for managing referral programs, promoters, referrals, and tracking referral performance with advanced features like commission setting, invitation management, and Wise payouts.
|
|
5
|
+
Home-page: https://github.com/soldatov-ss/django-referral-system.git
|
|
6
|
+
Author: Soldatov Serhii
|
|
7
|
+
Author-email: soldatov.own@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Environment :: Web Environment
|
|
10
|
+
Classifier: Framework :: Django
|
|
11
|
+
Classifier: Framework :: Django :: 4
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: Django>=4.1
|
|
27
|
+
Requires-Dist: djangorestframework>=3.14
|
|
28
|
+
Requires-Dist: pandas>=2.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0
|
|
30
|
+
Requires-Dist: python-dotenv>=1.0
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.cfg
|
|
6
|
+
setup.py
|
|
7
|
+
django_referral_system.egg-info/PKG-INFO
|
|
8
|
+
django_referral_system.egg-info/SOURCES.txt
|
|
9
|
+
django_referral_system.egg-info/dependency_links.txt
|
|
10
|
+
django_referral_system.egg-info/requires.txt
|
|
11
|
+
django_referral_system.egg-info/top_level.txt
|
|
12
|
+
referrals/__init__.py
|
|
13
|
+
referrals/admin.py
|
|
14
|
+
referrals/apps.py
|
|
15
|
+
referrals/choices.py
|
|
16
|
+
referrals/config.py
|
|
17
|
+
referrals/enums.py
|
|
18
|
+
referrals/exceptions.py
|
|
19
|
+
referrals/helpers.py
|
|
20
|
+
referrals/models.py
|
|
21
|
+
referrals/serializers.py
|
|
22
|
+
referrals/tests.py
|
|
23
|
+
referrals/urls.py
|
|
24
|
+
referrals/utils.py
|
|
25
|
+
referrals/views.py
|
|
26
|
+
referrals/dtos/__init__.py
|
|
27
|
+
referrals/dtos/base_dto.py
|
|
28
|
+
referrals/dtos/promoters_dtos.py
|
|
29
|
+
referrals/migrations/0001_initial.py
|
|
30
|
+
referrals/migrations/0002_alter_payoutmethod_method_and_more.py
|
|
31
|
+
referrals/migrations/__init__.py
|
|
32
|
+
referrals/migrations/__pycache__/0001_initial.cpython-310.pyc
|
|
33
|
+
referrals/migrations/__pycache__/__init__.cpython-310.pyc
|
|
34
|
+
referrals/repositories/__init__.py
|
|
35
|
+
referrals/repositories/base_repository.py
|
|
36
|
+
referrals/repositories/promoter_commission_repository.py
|
|
37
|
+
referrals/repositories/promoter_payout_repository.py
|
|
38
|
+
referrals/repositories/promoter_repository.py
|
|
39
|
+
referrals/repositories/referral_repository.py
|
|
40
|
+
referrals/services/__init__.py
|
|
41
|
+
referrals/services/promoter_payout_service.py
|
|
42
|
+
referrals/services/promoter_service.py
|
|
43
|
+
referrals/services/referral_service.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
referrals
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
|
|
3
|
+
from referrals.models import ReferralProgram, PayoutMethod, Referral, Promoter, PromoterCommission, \
|
|
4
|
+
PromoterPayout
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@admin.register(ReferralProgram)
|
|
8
|
+
class ReferralProgramAdmin(admin.ModelAdmin):
|
|
9
|
+
list_display = ("name", "commission_rate", "is_active", "id")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@admin.register(PayoutMethod)
|
|
13
|
+
class PayoutMethodAdmin(admin.ModelAdmin):
|
|
14
|
+
list_display = ("method", "payment_address")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@admin.register(Referral)
|
|
18
|
+
class ReferralAdmin(admin.ModelAdmin):
|
|
19
|
+
autocomplete_fields = (
|
|
20
|
+
"user",
|
|
21
|
+
"promoter",
|
|
22
|
+
)
|
|
23
|
+
list_display = (
|
|
24
|
+
"id",
|
|
25
|
+
"user",
|
|
26
|
+
"promoter",
|
|
27
|
+
"invitation_method",
|
|
28
|
+
"status",
|
|
29
|
+
)
|
|
30
|
+
search_fields = ("id",)
|
|
31
|
+
list_filter = ("status", "invitation_method", "id")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@admin.register(Promoter)
|
|
35
|
+
class PromoterAdmin(admin.ModelAdmin):
|
|
36
|
+
autocomplete_fields = ("user",)
|
|
37
|
+
search_fields = ("user__email",)
|
|
38
|
+
list_display = ("referral_link", "referral_token", "user", "id")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@admin.register(PromoterCommission)
|
|
42
|
+
class PromoterCommissionAdmin(admin.ModelAdmin):
|
|
43
|
+
search_fields = ("promoter__user__email",)
|
|
44
|
+
list_display = ("promoter", "referral", "amount", "status")
|
|
45
|
+
list_filter = ("status", "amount")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@admin.register(PromoterPayout)
|
|
49
|
+
class PromoterPayoutsAdmin(admin.ModelAdmin):
|
|
50
|
+
search_fields = ("promoter_user_email",)
|
|
51
|
+
list_display = ("promoter", "amount", "payout_method", "created")
|
|
52
|
+
list_filter = ("payout_method",)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ReferralStateChoices(models.TextChoices):
|
|
5
|
+
SIGNUP = "signup"
|
|
6
|
+
ACTIVE = "active"
|
|
7
|
+
REFUND = "refund"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InvitationMethodChoices(models.TextChoices):
|
|
11
|
+
EMAIL = "email"
|
|
12
|
+
LINK = "link"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PromoterCommissionStatusChoices(models.TextChoices):
|
|
16
|
+
PENDING = "pending"
|
|
17
|
+
PAID = "paid"
|
|
18
|
+
FAILED = "failed"
|
|
19
|
+
REFUND = "refund"
|
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from referrals.dtos.base_dto import BaseModelDTO
|
|
7
|
+
from referrals.enums import PayoutStatusEnum
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PromotionDTO(BaseModelDTO):
|
|
11
|
+
id: int
|
|
12
|
+
ref_id: str = Field(alias="refId")
|
|
13
|
+
promoter_id: int = Field(alias="promoterId")
|
|
14
|
+
referral_link: str = Field(alias="referralLink")
|
|
15
|
+
visitors_count: int = Field(alias="visitorsCount")
|
|
16
|
+
leads_count: int = Field(alias="leadsCount")
|
|
17
|
+
customers_count: int = Field(alias="customersCount")
|
|
18
|
+
refunds_count: int = Field(alias="refundsCount")
|
|
19
|
+
cancellations_count: int = Field(alias="cancellationsCount")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class BalanceDTO(BaseModelDTO):
|
|
23
|
+
cash: int
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class PromoterDTO(BaseModelDTO):
|
|
27
|
+
id: int
|
|
28
|
+
status: str
|
|
29
|
+
cust_id: Optional[str] = Field(alias="custId")
|
|
30
|
+
email: str
|
|
31
|
+
created_at: datetime = Field(alias="createdAt")
|
|
32
|
+
promotions: List[PromotionDTO]
|
|
33
|
+
earnings_balance: Optional[BalanceDTO] = Field(alias="earningsBalance")
|
|
34
|
+
current_balance: Optional[BalanceDTO] = Field(alias="currentBalance")
|
|
35
|
+
paid_balance: Optional[BalanceDTO] = Field(alias="paidBalance")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ReferralDTO(BaseModelDTO):
|
|
39
|
+
id: int
|
|
40
|
+
state: str
|
|
41
|
+
email: str
|
|
42
|
+
promotion: PromotionDTO
|
|
43
|
+
promoter: PromoterDTO
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ReferralListDTO(BaseModelDTO):
|
|
47
|
+
count: int | None
|
|
48
|
+
page_size: int
|
|
49
|
+
page: int
|
|
50
|
+
results: List[ReferralDTO]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class PromoterPayoutDTO(BaseModelDTO):
|
|
54
|
+
status: PayoutStatusEnum
|
|
55
|
+
amount: int
|
|
56
|
+
unit: str
|
|
57
|
+
created_at: str = Field(alias="createdAt")
|
|
58
|
+
date_paid: str | None = Field(default=None, alias="datePaid")
|
|
59
|
+
due_date: str | None = Field(default=None, alias="dueDate")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class PromoterCryptoPayoutDataRow(BaseModelDTO):
|
|
63
|
+
name: str
|
|
64
|
+
email: str
|
|
65
|
+
address: str
|
|
66
|
+
amount: float
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ReferralStateEnum(Enum):
|
|
5
|
+
SIGNUP = "signup"
|
|
6
|
+
INVITED = "invited"
|
|
7
|
+
ACTIVE = "active"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PayoutStatusEnum(Enum):
|
|
11
|
+
PENDING = "pending"
|
|
12
|
+
COMPLETED = "completed"
|
|
13
|
+
PROCESSING = "processing"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CryptoPayoutTokenIdsEnum(Enum):
|
|
17
|
+
USDC = "usd-coin"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class BaseAPIException(Exception):
|
|
5
|
+
"""
|
|
6
|
+
Base API exception.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def __init__(self, error_message: Union[str, dict], status_code: int):
|
|
10
|
+
self.error_message = error_message
|
|
11
|
+
self.status_code = status_code
|
|
12
|
+
super().__init__(self.error_message)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ViewException(BaseAPIException):
|
|
16
|
+
"""Base view exception."""
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Generated by Django 5.1 on 2024-08-17 19:32
|
|
2
|
+
|
|
3
|
+
import django.core.validators
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
from decimal import Decimal
|
|
6
|
+
from django.conf import settings
|
|
7
|
+
from django.db import migrations, models
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Migration(migrations.Migration):
|
|
11
|
+
|
|
12
|
+
initial = True
|
|
13
|
+
|
|
14
|
+
dependencies = [
|
|
15
|
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
operations = [
|
|
19
|
+
migrations.CreateModel(
|
|
20
|
+
name='PayoutMethod',
|
|
21
|
+
fields=[
|
|
22
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
23
|
+
('method', models.CharField(choices=[('wise', 'Wise'), ('crypto', 'Crypto')], max_length=10)),
|
|
24
|
+
('payment_address', models.CharField(help_text='Payment address (email or solana wallet)', max_length=100)),
|
|
25
|
+
],
|
|
26
|
+
),
|
|
27
|
+
migrations.CreateModel(
|
|
28
|
+
name='ReferralProgram',
|
|
29
|
+
fields=[
|
|
30
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
31
|
+
('created', models.DateTimeField(auto_now_add=True)),
|
|
32
|
+
('updated', models.DateTimeField(auto_now=True)),
|
|
33
|
+
('name', models.CharField(max_length=255, unique=True)),
|
|
34
|
+
('commission_rate', models.DecimalField(decimal_places=2, help_text='Commission rate as a percentage', max_digits=5, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))])),
|
|
35
|
+
('is_active', models.BooleanField(default=True, help_text='Indicates if this is the currently active referral program')),
|
|
36
|
+
('min_withdrawal_balance', models.DecimalField(decimal_places=2, default=0.0, help_text='Minimum balance required to withdraw earnings', max_digits=10)),
|
|
37
|
+
],
|
|
38
|
+
options={
|
|
39
|
+
'abstract': False,
|
|
40
|
+
},
|
|
41
|
+
),
|
|
42
|
+
migrations.CreateModel(
|
|
43
|
+
name='Promoter',
|
|
44
|
+
fields=[
|
|
45
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
46
|
+
('created', models.DateTimeField(auto_now_add=True)),
|
|
47
|
+
('updated', models.DateTimeField(auto_now=True)),
|
|
48
|
+
('referral_token', models.CharField(blank=True, help_text='Referral token', max_length=256, null=True, unique=True)),
|
|
49
|
+
('referral_link', models.CharField(blank=True, help_text='Referral link', max_length=256, null=True, unique=True)),
|
|
50
|
+
('link_clicked', models.IntegerField(default=0)),
|
|
51
|
+
('min_withdrawal_balance', models.DecimalField(decimal_places=2, default=0.0, help_text='Custom minimum balance required to withdraw earnings', max_digits=10)),
|
|
52
|
+
('active_payout_method', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='referrals.payoutmethod')),
|
|
53
|
+
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='promoter', to=settings.AUTH_USER_MODEL)),
|
|
54
|
+
],
|
|
55
|
+
options={
|
|
56
|
+
'abstract': False,
|
|
57
|
+
},
|
|
58
|
+
),
|
|
59
|
+
migrations.CreateModel(
|
|
60
|
+
name='PromoterPayout',
|
|
61
|
+
fields=[
|
|
62
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
63
|
+
('created', models.DateTimeField(auto_now_add=True)),
|
|
64
|
+
('updated', models.DateTimeField(auto_now=True)),
|
|
65
|
+
('amount', models.IntegerField()),
|
|
66
|
+
('payout_method', models.CharField(choices=[('wise', 'Wise'), ('crypto', 'Crypto')], max_length=10)),
|
|
67
|
+
('tx_signature', models.CharField(blank=True, max_length=255, null=True)),
|
|
68
|
+
('promoter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='promoter_payouts', to='referrals.promoter')),
|
|
69
|
+
],
|
|
70
|
+
options={
|
|
71
|
+
'abstract': False,
|
|
72
|
+
},
|
|
73
|
+
),
|
|
74
|
+
migrations.CreateModel(
|
|
75
|
+
name='Referral',
|
|
76
|
+
fields=[
|
|
77
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
78
|
+
('created', models.DateTimeField(auto_now_add=True)),
|
|
79
|
+
('updated', models.DateTimeField(auto_now=True)),
|
|
80
|
+
('invitation_method', models.CharField(choices=[('email', 'Email'), ('link', 'Link')], max_length=10)),
|
|
81
|
+
('status', models.CharField(choices=[('signup', 'Signup'), ('active', 'Active'), ('refund', 'Refund')], max_length=10)),
|
|
82
|
+
('commission_rate', models.DecimalField(decimal_places=2, default=0.0, help_text='Commission rate at the moment of creating the referral', max_digits=5)),
|
|
83
|
+
('promoter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='referrals', to='referrals.promoter')),
|
|
84
|
+
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='referral', to=settings.AUTH_USER_MODEL)),
|
|
85
|
+
],
|
|
86
|
+
options={
|
|
87
|
+
'abstract': False,
|
|
88
|
+
},
|
|
89
|
+
),
|
|
90
|
+
migrations.CreateModel(
|
|
91
|
+
name='PromoterCommission',
|
|
92
|
+
fields=[
|
|
93
|
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
94
|
+
('created', models.DateTimeField(auto_now_add=True)),
|
|
95
|
+
('updated', models.DateTimeField(auto_now=True)),
|
|
96
|
+
('amount', models.IntegerField(null=True)),
|
|
97
|
+
('status', models.CharField(choices=[('pending', 'Pending'), ('paid', 'Paid'), ('failed', 'Failed'), ('refund', 'Refund')], default='pending', max_length=10)),
|
|
98
|
+
('failure_reason', models.TextField(blank=True, null=True)),
|
|
99
|
+
('invoice_external_id', models.CharField(blank=True, help_text='Chargebee invoice ID', max_length=255, null=True)),
|
|
100
|
+
('promoter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='promoter_commission', to='referrals.promoter')),
|
|
101
|
+
('referral', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='referral_commission', to='referrals.referral')),
|
|
102
|
+
],
|
|
103
|
+
options={
|
|
104
|
+
'abstract': False,
|
|
105
|
+
},
|
|
106
|
+
),
|
|
107
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Generated by Django 5.1 on 2024-08-24 14:32
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('referrals', '0001_initial'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name='payoutmethod',
|
|
15
|
+
name='method',
|
|
16
|
+
field=models.CharField(help_text='Payout method (e.g., wise, crypto, etc.)', max_length=20),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name='promotercommission',
|
|
20
|
+
name='invoice_external_id',
|
|
21
|
+
field=models.CharField(blank=True, help_text='e.g. Chargebee invoice ID', max_length=255, null=True),
|
|
22
|
+
),
|
|
23
|
+
migrations.AlterField(
|
|
24
|
+
model_name='promoterpayout',
|
|
25
|
+
name='payout_method',
|
|
26
|
+
field=models.CharField(help_text='Payout method (e.g., wise, crypto, etc.)', max_length=20),
|
|
27
|
+
),
|
|
28
|
+
]
|
|
File without changes
|
|
Binary file
|