Phasing out Product model

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-09-28 20:59:08 +02:00
commit c6bacab35a
12 changed files with 227 additions and 26 deletions

View file

@ -0,0 +1,65 @@
# Generated by Django 3.1 on 2020-09-28 18:58
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('uncloud_pay', '0015_auto_20200928_1844'),
]
operations = [
migrations.RemoveField(
model_name='sampleonetimeproduct',
name='extra_data',
),
migrations.RemoveField(
model_name='sampleonetimeproduct',
name='owner',
),
migrations.RemoveField(
model_name='sampleonetimeproduct',
name='status',
),
migrations.RemoveField(
model_name='samplerecurringproduct',
name='extra_data',
),
migrations.RemoveField(
model_name='samplerecurringproduct',
name='owner',
),
migrations.RemoveField(
model_name='samplerecurringproduct',
name='status',
),
migrations.RemoveField(
model_name='samplerecurringproductonetimefee',
name='extra_data',
),
migrations.RemoveField(
model_name='samplerecurringproductonetimefee',
name='owner',
),
migrations.RemoveField(
model_name='samplerecurringproductonetimefee',
name='status',
),
migrations.CreateModel(
name='Product',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('extra_data', models.JSONField(blank=True, editable=False, null=True)),
('status', models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('SCHEDULED', 'Scheduled'), ('ACTIVE', 'Active'), ('MODIFYING', 'Modifying'), ('DELETED', 'Deleted'), ('DISABLED', 'Disabled'), ('UNUSABLE', 'Unusable')], default='AWAITING_PAYMENT', max_length=32)),
('config', models.JSONField()),
('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]

View file

@ -876,7 +876,7 @@ class Product(UncloudModel):
choices=UncloudStatus.choices,
default=UncloudStatus.AWAITING_PAYMENT)
# config = models.JSONField()
config = models.JSONField()
# Default period for all products
default_recurring_period = RecurringPeriod.PER_30D
@ -996,8 +996,8 @@ class Product(UncloudModel):
def allowed_recurring_periods():
return RecurringPeriod.choices
class Meta:
abstract = True
# class Meta:
# abstract = True
def discounted_price_by_period(self, requested_period):
"""
@ -1082,7 +1082,7 @@ class Product(UncloudModel):
# Sample products included into uncloud
class SampleOneTimeProduct(Product):
class SampleOneTimeProduct(models.Model):
"""
Products are usually more complex, but this product shows how easy
it can be to create your own one time product.
@ -1096,7 +1096,7 @@ class SampleOneTimeProduct(Product):
def one_time_price(self):
return self.ot_price
class SampleRecurringProduct(Product):
class SampleRecurringProduct(models.Model):
"""
Products are usually more complex, but this product shows how easy
it can be to create your own recurring fee product.
@ -1110,7 +1110,7 @@ class SampleRecurringProduct(Product):
def recurring_price(self):
return self.rc_price
class SampleRecurringProductOneTimeFee(Product):
class SampleRecurringProductOneTimeFee(models.Model):
"""
Products are usually more complex, but this product shows how easy
it can be to create your own one time + recurring fee product.