Skip to content

Commit a7badaa

Browse files
committed
add ABSTRACT_ONLY setting
1 parent e3ba4d5 commit a7badaa

3 files changed

Lines changed: 42 additions & 26 deletions

File tree

affiliate/app_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
SAVE_IN_SESSION = getattr(settings, 'AFFILIATE_SAVE_IN_SESSION', True)
1515
SESSION_AGE = getattr(settings, 'AFFILIATE_SESSION_AGE', 5 * 24 * 60 * 60)
1616
DEFAULT_LINK = getattr(settings, 'AFFILIATE_DEFAULT_LINK', '/')
17+
ABSTRACT_ONLY = getattr(settings, 'AFFILIATE_ABSTRACT_ONLY', False)
1718
# deprecated
1819
BANNER_FOLDER = getattr(settings, 'AFFILIATE_BANNER_PATH', 'affiliate')
1920
START_AID = getattr(settings, 'AFFILIATE_START_AID', "1000")

affiliate/migrations/0001_initial.py

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,42 @@
33

44
from django.db import models, migrations
55
from django.conf import settings
6+
from affiliate import app_settings
67

78

8-
class Migration(migrations.Migration):
9-
10-
dependencies = [
11-
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12-
]
13-
14-
operations = [
15-
migrations.CreateModel(
16-
name='Affiliate',
17-
fields=[
18-
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
19-
('reward_amount', models.DecimalField(default=10, verbose_name='reward amount', max_digits=5, decimal_places=2)),
20-
('reward_percentage', models.BooleanField(default=True, verbose_name='in percent')),
21-
('is_active', models.BooleanField(default=True, verbose_name='active')),
22-
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
23-
('user', models.OneToOneField(verbose_name='User', to=settings.AUTH_USER_MODEL)),
24-
],
25-
options={
26-
'swappable': 'AFFILIATE_AFFILIATE_MODEL',
27-
},
28-
bases=(models.Model,),
29-
),
30-
]
9+
if app_settings.ABSTRACT_ONLY:
10+
11+
class Migration(migrations.Migration):
12+
"""
13+
Empty migration
14+
"""
15+
16+
dependencies = []
17+
18+
operations = []
19+
20+
else:
21+
22+
class Migration(migrations.Migration):
23+
24+
dependencies = [
25+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
26+
]
27+
28+
operations = [
29+
migrations.CreateModel(
30+
name='Affiliate',
31+
fields=[
32+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
33+
('reward_amount', models.DecimalField(default=10, verbose_name='reward amount', max_digits=5, decimal_places=2)),
34+
('reward_percentage', models.BooleanField(default=True, verbose_name='in percent')),
35+
('is_active', models.BooleanField(default=True, verbose_name='active')),
36+
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
37+
('user', models.OneToOneField(verbose_name='User', to=settings.AUTH_USER_MODEL)),
38+
],
39+
options={
40+
'swappable': 'AFFILIATE_AFFILIATE_MODEL',
41+
},
42+
bases=(models.Model,),
43+
),
44+
]

affiliate/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ class NoAffiliate(object):
6767
def exists(self):
6868
return False
6969

70+
if not app_settings.ABSTRACT_ONLY:
7071

71-
class Affiliate(AbstractAffiliate):
72+
class Affiliate(AbstractAffiliate):
7273

73-
class Meta:
74-
swappable = 'AFFILIATE_AFFILIATE_MODEL'
74+
class Meta:
75+
swappable = 'AFFILIATE_AFFILIATE_MODEL'

0 commit comments

Comments
 (0)