From 1e68539ed833f5e5c7b7455153f374455b6fe5a5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 Jun 2020 14:35:12 +0200 Subject: [PATCH] remove uuid primary key Signed-off-by: Nico Schottelius --- opennebula/migrations/0001_initial.py | 4 +- .../migrations/0002_auto_20200225_1335.py | 27 ------ .../migrations/0003_auto_20200225_1428.py | 19 ---- .../migrations/0004_auto_20200225_1816.py | 23 ----- uncloud_auth/migrations/0001_initial.py | 4 +- .../migrations/0002_auto_20200318_1343.py | 25 ----- .../migrations/0003_auto_20200318_1345.py | 23 ----- .../0004_user_primary_billing_address.py | 20 ---- .../migrations/0005_auto_20200510_1736.py | 20 ---- uncloud_auth/models.py | 7 +- uncloud_net/migrations/0001_initial.py | 11 ++- .../migrations/0002_auto_20200409_1225.py | 24 ----- .../migrations/0003_auto_20200417_0551.py | 18 ---- uncloud_pay/migrations/0001_initial.py | 95 +++++++++++++++---- .../migrations/0002_auto_20200305_1524.py | 27 ------ .../migrations/0003_auto_20200305_1354.py | 18 ---- .../migrations/0004_auto_20200409_1225.py | 23 ----- .../migrations/0005_auto_20200413_0924.py | 18 ---- .../migrations/0006_auto_20200415_1003.py | 31 ------ uncloud_pay/migrations/0006_billingaddress.py | 29 ------ .../migrations/0007_auto_20200418_0737.py | 42 -------- .../migrations/0008_auto_20200502_1921.py | 19 ---- .../migrations/0009_auto_20200502_2047.py | 47 --------- .../migrations/0010_order_description.py | 19 ---- .../0011_billingaddress_organization.py | 19 ---- uncloud_pay/migrations/0012_billnico.py | 29 ------ .../migrations/0013_auto_20200508_1446.py | 24 ----- .../migrations/0014_paymentsettings.py | 25 ----- .../migrations/0015_auto_20200523_2132.py | 26 ----- .../migrations/0016_auto_20200523_2138.py | 23 ----- .../migrations/0017_auto_20200621_1110.py | 55 ----------- .../migrations/0018_auto_20200621_1140.py | 25 ----- .../migrations/0019_auto_20200621_1144.py | 23 ----- uncloud_pay/models.py | 58 +++++------ uncloud_service/migrations/0001_initial.py | 28 ++++-- .../migrations/0002_auto_20200418_0641.py | 41 -------- uncloud_vm/migrations/0001_initial.py | 77 ++++++++++----- .../migrations/0002_auto_20200305_1321.py | 23 ----- .../migrations/0003_remove_vmhost_vms.py | 17 ---- .../migrations/0004_remove_vmproduct_vmid.py | 17 ---- .../migrations/0004_vmproduct_primary_disk.py | 19 ---- .../migrations/0005_auto_20200309_1258.py | 25 ----- .../migrations/0005_auto_20200321_1058.py | 50 ---------- .../migrations/0006_auto_20200322_1758.py | 57 ----------- .../migrations/0007_vmhost_vmcluster.py | 19 ---- .../migrations/0008_auto_20200403_1727.py | 33 ------- .../migrations/0009_auto_20200417_0551.py | 23 ----- .../migrations/0009_merge_20200413_0857.py | 14 --- .../migrations/0010_auto_20200413_0924.py | 24 ----- .../migrations/0011_merge_20200418_0641.py | 14 --- .../migrations/0012_auto_20200418_0641.py | 18 ---- .../0013_remove_vmproduct_primary_disk.py | 17 ---- .../0014_vmwithosproduct_primary_disk.py | 19 ---- 53 files changed, 186 insertions(+), 1249 deletions(-) delete mode 100644 opennebula/migrations/0002_auto_20200225_1335.py delete mode 100644 opennebula/migrations/0003_auto_20200225_1428.py delete mode 100644 opennebula/migrations/0004_auto_20200225_1816.py delete mode 100644 uncloud_auth/migrations/0002_auto_20200318_1343.py delete mode 100644 uncloud_auth/migrations/0003_auto_20200318_1345.py delete mode 100644 uncloud_auth/migrations/0004_user_primary_billing_address.py delete mode 100644 uncloud_auth/migrations/0005_auto_20200510_1736.py delete mode 100644 uncloud_net/migrations/0002_auto_20200409_1225.py delete mode 100644 uncloud_net/migrations/0003_auto_20200417_0551.py delete mode 100644 uncloud_pay/migrations/0002_auto_20200305_1524.py delete mode 100644 uncloud_pay/migrations/0003_auto_20200305_1354.py delete mode 100644 uncloud_pay/migrations/0004_auto_20200409_1225.py delete mode 100644 uncloud_pay/migrations/0005_auto_20200413_0924.py delete mode 100644 uncloud_pay/migrations/0006_auto_20200415_1003.py delete mode 100644 uncloud_pay/migrations/0006_billingaddress.py delete mode 100644 uncloud_pay/migrations/0007_auto_20200418_0737.py delete mode 100644 uncloud_pay/migrations/0008_auto_20200502_1921.py delete mode 100644 uncloud_pay/migrations/0009_auto_20200502_2047.py delete mode 100644 uncloud_pay/migrations/0010_order_description.py delete mode 100644 uncloud_pay/migrations/0011_billingaddress_organization.py delete mode 100644 uncloud_pay/migrations/0012_billnico.py delete mode 100644 uncloud_pay/migrations/0013_auto_20200508_1446.py delete mode 100644 uncloud_pay/migrations/0014_paymentsettings.py delete mode 100644 uncloud_pay/migrations/0015_auto_20200523_2132.py delete mode 100644 uncloud_pay/migrations/0016_auto_20200523_2138.py delete mode 100644 uncloud_pay/migrations/0017_auto_20200621_1110.py delete mode 100644 uncloud_pay/migrations/0018_auto_20200621_1140.py delete mode 100644 uncloud_pay/migrations/0019_auto_20200621_1144.py delete mode 100644 uncloud_service/migrations/0002_auto_20200418_0641.py delete mode 100644 uncloud_vm/migrations/0002_auto_20200305_1321.py delete mode 100644 uncloud_vm/migrations/0003_remove_vmhost_vms.py delete mode 100644 uncloud_vm/migrations/0004_remove_vmproduct_vmid.py delete mode 100644 uncloud_vm/migrations/0004_vmproduct_primary_disk.py delete mode 100644 uncloud_vm/migrations/0005_auto_20200309_1258.py delete mode 100644 uncloud_vm/migrations/0005_auto_20200321_1058.py delete mode 100644 uncloud_vm/migrations/0006_auto_20200322_1758.py delete mode 100644 uncloud_vm/migrations/0007_vmhost_vmcluster.py delete mode 100644 uncloud_vm/migrations/0008_auto_20200403_1727.py delete mode 100644 uncloud_vm/migrations/0009_auto_20200417_0551.py delete mode 100644 uncloud_vm/migrations/0009_merge_20200413_0857.py delete mode 100644 uncloud_vm/migrations/0010_auto_20200413_0924.py delete mode 100644 uncloud_vm/migrations/0011_merge_20200418_0641.py delete mode 100644 uncloud_vm/migrations/0012_auto_20200418_0641.py delete mode 100644 uncloud_vm/migrations/0013_remove_vmproduct_primary_disk.py delete mode 100644 uncloud_vm/migrations/0014_vmwithosproduct_primary_disk.py diff --git a/opennebula/migrations/0001_initial.py b/opennebula/migrations/0001_initial.py index 4c0527a..6c1a0e7 100644 --- a/opennebula/migrations/0001_initial.py +++ b/opennebula/migrations/0001_initial.py @@ -1,10 +1,9 @@ -# Generated by Django 3.0.3 on 2020-02-23 17:12 +# Generated by Django 3.0.6 on 2020-06-21 12:34 from django.conf import settings import django.contrib.postgres.fields.jsonb from django.db import migrations, models import django.db.models.deletion -import uuid class Migration(migrations.Migration): @@ -20,7 +19,6 @@ class Migration(migrations.Migration): name='VM', fields=[ ('vmid', models.IntegerField(primary_key=True, serialize=False)), - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)), ('data', django.contrib.postgres.fields.jsonb.JSONField()), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], diff --git a/opennebula/migrations/0002_auto_20200225_1335.py b/opennebula/migrations/0002_auto_20200225_1335.py deleted file mode 100644 index 1554aa6..0000000 --- a/opennebula/migrations/0002_auto_20200225_1335.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 3.0.3 on 2020-02-25 13:35 - -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - ('opennebula', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='vm', - name='uuid', - ), - migrations.RemoveField( - model_name='vm', - name='vmid', - ), - migrations.AddField( - model_name='vm', - name='id', - field=models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False, unique=True), - ), - ] diff --git a/opennebula/migrations/0003_auto_20200225_1428.py b/opennebula/migrations/0003_auto_20200225_1428.py deleted file mode 100644 index 8bb3d8d..0000000 --- a/opennebula/migrations/0003_auto_20200225_1428.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.3 on 2020-02-25 14:28 - -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - ('opennebula', '0002_auto_20200225_1335'), - ] - - operations = [ - migrations.AlterField( - model_name='vm', - name='id', - field=models.CharField(default=uuid.uuid4, max_length=64, primary_key=True, serialize=False, unique=True), - ), - ] diff --git a/opennebula/migrations/0004_auto_20200225_1816.py b/opennebula/migrations/0004_auto_20200225_1816.py deleted file mode 100644 index 5b39f26..0000000 --- a/opennebula/migrations/0004_auto_20200225_1816.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.0.3 on 2020-02-25 18:16 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('opennebula', '0003_auto_20200225_1428'), - ] - - operations = [ - migrations.RemoveField( - model_name='vm', - name='id', - ), - migrations.AddField( - model_name='vm', - name='vmid', - field=models.IntegerField(default=42, primary_key=True, serialize=False), - preserve_default=False, - ), - ] diff --git a/uncloud_auth/migrations/0001_initial.py b/uncloud_auth/migrations/0001_initial.py index a1f8d00..6779be2 100644 --- a/uncloud_auth/migrations/0001_initial.py +++ b/uncloud_auth/migrations/0001_initial.py @@ -1,7 +1,8 @@ -# Generated by Django 3.0.3 on 2020-03-03 16:49 +# Generated by Django 3.0.6 on 2020-06-21 12:34 import django.contrib.auth.models import django.contrib.auth.validators +import django.core.validators from django.db import migrations, models import django.utils.timezone @@ -29,6 +30,7 @@ class Migration(migrations.Migration): ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('maximum_credit', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])), ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], diff --git a/uncloud_auth/migrations/0002_auto_20200318_1343.py b/uncloud_auth/migrations/0002_auto_20200318_1343.py deleted file mode 100644 index ad2654f..0000000 --- a/uncloud_auth/migrations/0002_auto_20200318_1343.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-18 13:43 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_auth', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='amount', - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)]), - ), - migrations.AddField( - model_name='user', - name='maximum_credit', - field=models.FloatField(default=0), - preserve_default=False, - ), - ] diff --git a/uncloud_auth/migrations/0003_auto_20200318_1345.py b/uncloud_auth/migrations/0003_auto_20200318_1345.py deleted file mode 100644 index 31b1717..0000000 --- a/uncloud_auth/migrations/0003_auto_20200318_1345.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-18 13:45 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_auth', '0002_auto_20200318_1343'), - ] - - operations = [ - migrations.RemoveField( - model_name='user', - name='amount', - ), - migrations.AlterField( - model_name='user', - name='maximum_credit', - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)]), - ), - ] diff --git a/uncloud_auth/migrations/0004_user_primary_billing_address.py b/uncloud_auth/migrations/0004_user_primary_billing_address.py deleted file mode 100644 index 640c9c5..0000000 --- a/uncloud_auth/migrations/0004_user_primary_billing_address.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-10 17:31 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0014_paymentsettings'), - ('uncloud_auth', '0003_auto_20200318_1345'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='primary_billing_address', - field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='uncloud_pay.BillingAddress'), - ), - ] diff --git a/uncloud_auth/migrations/0005_auto_20200510_1736.py b/uncloud_auth/migrations/0005_auto_20200510_1736.py deleted file mode 100644 index 38c303e..0000000 --- a/uncloud_auth/migrations/0005_auto_20200510_1736.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-10 17:36 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0014_paymentsettings'), - ('uncloud_auth', '0004_user_primary_billing_address'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='primary_billing_address', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='uncloud_pay.BillingAddress'), - ), - ] diff --git a/uncloud_auth/models.py b/uncloud_auth/models.py index c456648..9132f96 100644 --- a/uncloud_auth/models.py +++ b/uncloud_auth/models.py @@ -17,11 +17,8 @@ class User(AbstractUser): decimal_places=AMOUNT_DECIMALS, validators=[MinValueValidator(0)]) - # Need to use the string here to prevent a circular import - primary_billing_address = models.ForeignKey('uncloud_pay.BillingAddress', - on_delete=models.PROTECT, - blank=True, - null=True) + # @property + # def primary_billing_address(self): @property def balance(self): diff --git a/uncloud_net/migrations/0001_initial.py b/uncloud_net/migrations/0001_initial.py index 940d63f..98714c9 100644 --- a/uncloud_net/migrations/0001_initial.py +++ b/uncloud_net/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.5 on 2020-04-06 21:38 +# Generated by Django 3.0.6 on 2020-06-21 12:34 from django.conf import settings import django.contrib.postgres.fields.jsonb @@ -14,7 +14,7 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('uncloud_pay', '0001_initial'), + ('uncloud_pay', '__first__'), ] operations = [ @@ -44,6 +44,7 @@ class Migration(migrations.Migration): fields=[ ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), ('address', models.GenericIPAddressField(primary_key=True, serialize=False)), + ('status', models.CharField(choices=[('used', 'used'), ('free', 'free')], default='used', max_length=256)), ('vpnpool', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_net.VPNPool')), ], options={ @@ -53,11 +54,11 @@ class Migration(migrations.Migration): migrations.CreateModel( name='VPNNetwork', fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('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='PENDING', max_length=32)), + ('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)), ('wireguard_public_key', models.CharField(max_length=48)), - ('network', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_net.VPNNetworkReservation')), + ('network', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='uncloud_net.VPNNetworkReservation')), ('order', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], diff --git a/uncloud_net/migrations/0002_auto_20200409_1225.py b/uncloud_net/migrations/0002_auto_20200409_1225.py deleted file mode 100644 index fcc2374..0000000 --- a/uncloud_net/migrations/0002_auto_20200409_1225.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-09 12:25 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_net', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='vpnnetworkreservation', - name='status', - field=models.CharField(choices=[('used', 'used'), ('free', 'free')], default='used', max_length=256), - ), - migrations.AlterField( - model_name='vpnnetwork', - name='network', - field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='uncloud_net.VPNNetworkReservation'), - ), - ] diff --git a/uncloud_net/migrations/0003_auto_20200417_0551.py b/uncloud_net/migrations/0003_auto_20200417_0551.py deleted file mode 100644 index 24f4a7f..0000000 --- a/uncloud_net/migrations/0003_auto_20200417_0551.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-17 05:51 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_net', '0002_auto_20200409_1225'), - ] - - operations = [ - migrations.AlterField( - model_name='vpnnetwork', - name='status', - field=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), - ), - ] diff --git a/uncloud_pay/migrations/0001_initial.py b/uncloud_pay/migrations/0001_initial.py index 89fa586..faa4b26 100644 --- a/uncloud_pay/migrations/0001_initial.py +++ b/uncloud_pay/migrations/0001_initial.py @@ -1,10 +1,11 @@ -# Generated by Django 3.0.3 on 2020-03-05 10:17 +# Generated by Django 3.0.6 on 2020-06-21 12:34 from django.conf import settings import django.core.validators from django.db import migrations, models import django.db.models.deletion -import uuid +import django.utils.timezone +import uncloud_pay.models class Migration(migrations.Migration): @@ -12,33 +13,50 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('uncloud_auth', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Bill', fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('creation_date', models.DateTimeField(auto_now_add=True)), ('starting_date', models.DateTimeField()), ('ending_date', models.DateTimeField()), ('due_date', models.DateField()), ('valid', models.BooleanField(default=True)), + ], + ), + migrations.CreateModel( + name='BillingAddress', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('organization', models.CharField(max_length=100)), + ('name', models.CharField(max_length=100)), + ('street', models.CharField(max_length=100)), + ('city', models.CharField(max_length=50)), + ('postal_code', models.CharField(max_length=50)), + ('country', uncloud_pay.models.CountryField(blank=True, choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabia'), ('SB', 'Solomon Islands'), ('SC', 'Seychelles'), ('SD', 'Sudan'), ('SE', 'Sweden'), ('SG', 'Singapore'), ('SH', 'St. Helena'), ('SI', 'Slovenia'), ('SJ', 'Svalbard & Jan Mayen Islands'), ('SK', 'Slovakia'), ('SL', 'Sierra Leone'), ('SM', 'San Marino'), ('SN', 'Senegal'), ('SO', 'Somalia'), ('SR', 'Suriname'), ('ST', 'Sao Tome & Principe'), ('SV', 'El Salvador'), ('SY', 'Syrian Arab Republic'), ('SZ', 'Swaziland'), ('TC', 'Turks & Caicos Islands'), ('TD', 'Chad'), ('TF', 'French Southern Territories'), ('TG', 'Togo'), ('TH', 'Thailand'), ('TJ', 'Tajikistan'), ('TK', 'Tokelau'), ('TM', 'Turkmenistan'), ('TN', 'Tunisia'), ('TO', 'Tonga'), ('TP', 'East Timor'), ('TR', 'Turkey'), ('TT', 'Trinidad & Tobago'), ('TV', 'Tuvalu'), ('TW', 'Taiwan, Province of China'), ('TZ', 'Tanzania, United Republic of'), ('UA', 'Ukraine'), ('UG', 'Uganda'), ('UM', 'United States Minor Outlying Islands'), ('US', 'United States of America'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistan'), ('VA', 'Vatican City State (Holy See)'), ('VC', 'St. Vincent & the Grenadines'), ('VE', 'Venezuela'), ('VG', 'British Virgin Islands'), ('VI', 'United States Virgin Islands'), ('VN', 'Viet Nam'), ('VU', 'Vanuatu'), ('WF', 'Wallis & Futuna Islands'), ('WS', 'Samoa'), ('YE', 'Yemen'), ('YT', 'Mayotte'), ('YU', 'Yugoslavia'), ('ZA', 'South Africa'), ('ZM', 'Zambia'), ('ZR', 'Zaire'), ('ZW', 'Zimbabwe')], default='CH', max_length=2)), + ('vat_number', models.CharField(blank=True, default='', max_length=100)), + ('active', models.BooleanField(default=False)), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), migrations.CreateModel( name='Order', fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.TextField()), ('creation_date', models.DateTimeField(auto_now_add=True)), - ('starting_date', models.DateTimeField(auto_now_add=True)), + ('starting_date', models.DateTimeField(default=django.utils.timezone.now)), ('ending_date', models.DateTimeField(blank=True, null=True)), - ('recurring_period', models.CharField(choices=[('ONCE', 'Onetime'), ('YEAR', 'Per Year'), ('MONTH', 'Per Month'), ('MINUTE', 'Per Minute'), ('DAY', 'Per Day'), ('HOUR', 'Per Hour'), ('SECOND', 'Per Second')], default='MONTH', max_length=32)), - ('bill', models.ManyToManyField(blank=True, editable=False, to='uncloud_pay.Bill')), - ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('recurring_period', models.IntegerField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000)), + ('billing_address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.BillingAddress')), + ('depends_on', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='parent_of', to='uncloud_pay.Order')), + ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('replaced_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='supersede', to='uncloud_pay.Order')), ], ), migrations.CreateModel( @@ -48,10 +66,35 @@ class Migration(migrations.Migration): ('stripe_id', models.CharField(max_length=32)), ], ), + migrations.CreateModel( + name='VATRate', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('start_date', models.DateField(blank=True, null=True)), + ('stop_date', models.DateField(blank=True, null=True)), + ('territory_codes', models.TextField(blank=True, default='')), + ('currency_code', models.CharField(max_length=10)), + ('rate', models.FloatField()), + ('rate_type', models.TextField(blank=True, default='')), + ('description', models.TextField(blank=True, default='')), + ], + ), + migrations.CreateModel( + name='PaymentMethod', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('source', models.CharField(choices=[('stripe', 'Stripe'), ('unknown', 'Unknown')], default='stripe', max_length=256)), + ('description', models.TextField()), + ('primary', models.BooleanField(default=False, editable=False)), + ('stripe_payment_method_id', models.CharField(blank=True, max_length=32, null=True)), + ('stripe_setup_intent_id', models.CharField(blank=True, max_length=32, null=True)), + ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), migrations.CreateModel( name='Payment', fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('amount', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])), ('source', models.CharField(choices=[('wire', 'Wire Transfer'), ('stripe', 'Stripe'), ('voucher', 'Voucher'), ('referral', 'Referral'), ('unknown', 'Unknown')], default='unknown', max_length=256)), ('timestamp', models.DateTimeField(auto_now_add=True)), @@ -69,17 +112,29 @@ class Migration(migrations.Migration): ], ), migrations.CreateModel( - name='PaymentMethod', + name='BillRecord', fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('source', models.CharField(choices=[('stripe', 'Stripe'), ('unknown', 'Unknown')], default='stripe', max_length=256)), - ('description', models.TextField()), - ('primary', models.BooleanField(default=True)), - ('stripe_card_id', models.CharField(blank=True, max_length=32, null=True)), - ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('usage_count', models.IntegerField(default=1)), + ('creation_date', models.DateTimeField(auto_now_add=True)), + ('starting_date', models.DateTimeField()), + ('ending_date', models.DateTimeField()), + ('bill', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Bill')), + ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), ], - options={ - 'unique_together': {('owner', 'primary')}, - }, + ), + migrations.AddField( + model_name='bill', + name='bill_records', + field=models.ManyToManyField(through='uncloud_pay.BillRecord', to='uncloud_pay.Order'), + ), + migrations.AddField( + model_name='bill', + name='owner', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddConstraint( + model_name='billingaddress', + constraint=models.UniqueConstraint(condition=models.Q(primary=True), fields=('owner',), name='one_active_billing_address_per_user'), ), ] diff --git a/uncloud_pay/migrations/0002_auto_20200305_1524.py b/uncloud_pay/migrations/0002_auto_20200305_1524.py deleted file mode 100644 index 0768dd0..0000000 --- a/uncloud_pay/migrations/0002_auto_20200305_1524.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-05 15:24 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0001_initial'), - ] - - operations = [ - migrations.RenameField( - model_name='paymentmethod', - old_name='stripe_card_id', - new_name='stripe_payment_method_id', - ), - migrations.AddField( - model_name='paymentmethod', - name='stripe_setup_intent_id', - field=models.CharField(blank=True, max_length=32, null=True), - ), - migrations.AlterUniqueTogether( - name='paymentmethod', - unique_together=set(), - ), - ] diff --git a/uncloud_pay/migrations/0003_auto_20200305_1354.py b/uncloud_pay/migrations/0003_auto_20200305_1354.py deleted file mode 100644 index 4157732..0000000 --- a/uncloud_pay/migrations/0003_auto_20200305_1354.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-05 13:54 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0002_auto_20200305_1524'), - ] - - operations = [ - migrations.AlterField( - model_name='paymentmethod', - name='primary', - field=models.BooleanField(default=False, editable=False), - ), - ] diff --git a/uncloud_pay/migrations/0004_auto_20200409_1225.py b/uncloud_pay/migrations/0004_auto_20200409_1225.py deleted file mode 100644 index 32aac87..0000000 --- a/uncloud_pay/migrations/0004_auto_20200409_1225.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-09 12:25 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0003_auto_20200305_1354'), - ] - - operations = [ - migrations.AlterField( - model_name='order', - name='recurring_period', - field=models.CharField(choices=[('ONCE', 'Onetime'), ('YEAR', 'Per Year'), ('MONTH', 'Per Month'), ('MINUTE', 'Per Minute'), ('WEEK', 'Per Week'), ('DAY', 'Per Day'), ('HOUR', 'Per Hour'), ('SECOND', 'Per Second')], default='MONTH', max_length=32), - ), - migrations.AlterField( - model_name='order', - name='starting_date', - field=models.DateTimeField(), - ), - ] diff --git a/uncloud_pay/migrations/0005_auto_20200413_0924.py b/uncloud_pay/migrations/0005_auto_20200413_0924.py deleted file mode 100644 index 3f6a646..0000000 --- a/uncloud_pay/migrations/0005_auto_20200413_0924.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-13 09:24 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0004_auto_20200409_1225'), - ] - - operations = [ - migrations.AlterField( - model_name='order', - name='recurring_period', - field=models.CharField(choices=[('ONCE', 'Onetime'), ('YEAR', 'Per Year'), ('MONTH', 'Per Month'), ('WEEK', 'Per Week'), ('DAY', 'Per Day'), ('HOUR', 'Per Hour'), ('MINUTE', 'Per Minute'), ('SECOND', 'Per Second')], default='MONTH', max_length=32), - ), - ] diff --git a/uncloud_pay/migrations/0006_auto_20200415_1003.py b/uncloud_pay/migrations/0006_auto_20200415_1003.py deleted file mode 100644 index 1f37eae..0000000 --- a/uncloud_pay/migrations/0006_auto_20200415_1003.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-15 10:03 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0005_auto_20200413_0924'), - ] - - operations = [ - migrations.CreateModel( - name='VATRate', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('start_date', models.DateField(blank=True, null=True)), - ('stop_date', models.DateField(blank=True, null=True)), - ('territory_codes', models.TextField(blank=True, default='')), - ('currency_code', models.CharField(max_length=10)), - ('rate', models.FloatField()), - ('rate_type', models.TextField(blank=True, default='')), - ('description', models.TextField(blank=True, default='')), - ], - ), - migrations.AlterField( - model_name='order', - name='recurring_period', - field=models.CharField(choices=[('ONCE', 'Onetime'), ('YEAR', 'Per Year'), ('MONTH', 'Per Month'), ('WEEK', 'Per Week'), ('DAY', 'Per Day'), ('HOUR', 'Per Hour'), ('MINUTE', 'Per Minute'), ('SECOND', 'Per Second')], default='MONTH', max_length=32), - ), - ] diff --git a/uncloud_pay/migrations/0006_billingaddress.py b/uncloud_pay/migrations/0006_billingaddress.py deleted file mode 100644 index 79b25ab..0000000 --- a/uncloud_pay/migrations/0006_billingaddress.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-15 12:29 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import uncloud_pay.models - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('uncloud_pay', '0006_auto_20200415_1003'), - ] - - operations = [ - migrations.CreateModel( - name='BillingAddress', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('street', models.CharField(max_length=100)), - ('city', models.CharField(max_length=50)), - ('postal_code', models.CharField(max_length=50)), - ('country', uncloud_pay.models.CountryField(choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabia'), ('SB', 'Solomon Islands'), ('SC', 'Seychelles'), ('SD', 'Sudan'), ('SE', 'Sweden'), ('SG', 'Singapore'), ('SH', 'St. Helena'), ('SI', 'Slovenia'), ('SJ', 'Svalbard & Jan Mayen Islands'), ('SK', 'Slovakia'), ('SL', 'Sierra Leone'), ('SM', 'San Marino'), ('SN', 'Senegal'), ('SO', 'Somalia'), ('SR', 'Suriname'), ('ST', 'Sao Tome & Principe'), ('SV', 'El Salvador'), ('SY', 'Syrian Arab Republic'), ('SZ', 'Swaziland'), ('TC', 'Turks & Caicos Islands'), ('TD', 'Chad'), ('TF', 'French Southern Territories'), ('TG', 'Togo'), ('TH', 'Thailand'), ('TJ', 'Tajikistan'), ('TK', 'Tokelau'), ('TM', 'Turkmenistan'), ('TN', 'Tunisia'), ('TO', 'Tonga'), ('TP', 'East Timor'), ('TR', 'Turkey'), ('TT', 'Trinidad & Tobago'), ('TV', 'Tuvalu'), ('TW', 'Taiwan, Province of China'), ('TZ', 'Tanzania, United Republic of'), ('UA', 'Ukraine'), ('UG', 'Uganda'), ('UM', 'United States Minor Outlying Islands'), ('US', 'United States of America'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistan'), ('VA', 'Vatican City State (Holy See)'), ('VC', 'St. Vincent & the Grenadines'), ('VE', 'Venezuela'), ('VG', 'British Virgin Islands'), ('VI', 'United States Virgin Islands'), ('VN', 'Viet Nam'), ('VU', 'Vanuatu'), ('WF', 'Wallis & Futuna Islands'), ('WS', 'Samoa'), ('YE', 'Yemen'), ('YT', 'Mayotte'), ('YU', 'Yugoslavia'), ('ZA', 'South Africa'), ('ZM', 'Zambia'), ('ZR', 'Zaire'), ('ZW', 'Zimbabwe')], default='CH', max_length=2)), - ('vat_number', models.CharField(blank=True, default='', max_length=100)), - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/uncloud_pay/migrations/0007_auto_20200418_0737.py b/uncloud_pay/migrations/0007_auto_20200418_0737.py deleted file mode 100644 index c9c2342..0000000 --- a/uncloud_pay/migrations/0007_auto_20200418_0737.py +++ /dev/null @@ -1,42 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-18 07:37 - -from django.db import migrations, models -import django.db.models.deletion -import uncloud_pay.models -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0006_billingaddress'), - ] - - operations = [ - migrations.RemoveField( - model_name='billingaddress', - name='id', - ), - migrations.AddField( - model_name='billingaddress', - name='name', - field=models.CharField(default='unknown', max_length=100), - preserve_default=False, - ), - migrations.AddField( - model_name='billingaddress', - name='uuid', - field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False), - ), - migrations.AddField( - model_name='order', - name='billing_address', - field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.BillingAddress'), - preserve_default=False, - ), - migrations.AlterField( - model_name='billingaddress', - name='country', - field=uncloud_pay.models.CountryField(blank=True, choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabia'), ('SB', 'Solomon Islands'), ('SC', 'Seychelles'), ('SD', 'Sudan'), ('SE', 'Sweden'), ('SG', 'Singapore'), ('SH', 'St. Helena'), ('SI', 'Slovenia'), ('SJ', 'Svalbard & Jan Mayen Islands'), ('SK', 'Slovakia'), ('SL', 'Sierra Leone'), ('SM', 'San Marino'), ('SN', 'Senegal'), ('SO', 'Somalia'), ('SR', 'Suriname'), ('ST', 'Sao Tome & Principe'), ('SV', 'El Salvador'), ('SY', 'Syrian Arab Republic'), ('SZ', 'Swaziland'), ('TC', 'Turks & Caicos Islands'), ('TD', 'Chad'), ('TF', 'French Southern Territories'), ('TG', 'Togo'), ('TH', 'Thailand'), ('TJ', 'Tajikistan'), ('TK', 'Tokelau'), ('TM', 'Turkmenistan'), ('TN', 'Tunisia'), ('TO', 'Tonga'), ('TP', 'East Timor'), ('TR', 'Turkey'), ('TT', 'Trinidad & Tobago'), ('TV', 'Tuvalu'), ('TW', 'Taiwan, Province of China'), ('TZ', 'Tanzania, United Republic of'), ('UA', 'Ukraine'), ('UG', 'Uganda'), ('UM', 'United States Minor Outlying Islands'), ('US', 'United States of America'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistan'), ('VA', 'Vatican City State (Holy See)'), ('VC', 'St. Vincent & the Grenadines'), ('VE', 'Venezuela'), ('VG', 'British Virgin Islands'), ('VI', 'United States Virgin Islands'), ('VN', 'Viet Nam'), ('VU', 'Vanuatu'), ('WF', 'Wallis & Futuna Islands'), ('WS', 'Samoa'), ('YE', 'Yemen'), ('YT', 'Mayotte'), ('YU', 'Yugoslavia'), ('ZA', 'South Africa'), ('ZM', 'Zambia'), ('ZR', 'Zaire'), ('ZW', 'Zimbabwe')], default='CH', max_length=2), - ), - ] diff --git a/uncloud_pay/migrations/0008_auto_20200502_1921.py b/uncloud_pay/migrations/0008_auto_20200502_1921.py deleted file mode 100644 index c244357..0000000 --- a/uncloud_pay/migrations/0008_auto_20200502_1921.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.5 on 2020-05-02 19:21 - -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0007_auto_20200418_0737'), - ] - - operations = [ - migrations.AlterField( - model_name='order', - name='starting_date', - field=models.DateTimeField(default=django.utils.timezone.now), - ), - ] diff --git a/uncloud_pay/migrations/0009_auto_20200502_2047.py b/uncloud_pay/migrations/0009_auto_20200502_2047.py deleted file mode 100644 index cb9cd78..0000000 --- a/uncloud_pay/migrations/0009_auto_20200502_2047.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by Django 3.0.5 on 2020-05-02 20:47 - -from django.conf import settings -import django.core.validators -from django.db import migrations, models -import django.db.models.deletion -import django.utils.timezone -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('uncloud_pay', '0008_auto_20200502_1921'), - ] - - operations = [ - migrations.AddField( - model_name='order', - name='one_time_price', - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)]), - ), - migrations.AddField( - model_name='order', - name='recurring_price', - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)]), - ), - migrations.AddField( - model_name='order', - name='replaced_by', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='uncloud_pay.Order'), - ), - migrations.CreateModel( - name='OrderTimothee', - fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('creation_date', models.DateTimeField(auto_now_add=True)), - ('starting_date', models.DateTimeField(default=django.utils.timezone.now)), - ('ending_date', models.DateTimeField(blank=True, null=True)), - ('recurring_period', models.CharField(choices=[('ONCE', 'Onetime'), ('YEAR', 'Per Year'), ('MONTH', 'Per Month'), ('WEEK', 'Per Week'), ('DAY', 'Per Day'), ('HOUR', 'Per Hour'), ('MINUTE', 'Per Minute'), ('SECOND', 'Per Second')], default='MONTH', max_length=32)), - ('bill', models.ManyToManyField(blank=True, editable=False, to='uncloud_pay.Bill')), - ('billing_address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.BillingAddress')), - ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/uncloud_pay/migrations/0010_order_description.py b/uncloud_pay/migrations/0010_order_description.py deleted file mode 100644 index 2613bff..0000000 --- a/uncloud_pay/migrations/0010_order_description.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-07 10:07 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0009_auto_20200502_2047'), - ] - - operations = [ - migrations.AddField( - model_name='order', - name='description', - field=models.TextField(default=''), - preserve_default=False, - ), - ] diff --git a/uncloud_pay/migrations/0011_billingaddress_organization.py b/uncloud_pay/migrations/0011_billingaddress_organization.py deleted file mode 100644 index ac36eee..0000000 --- a/uncloud_pay/migrations/0011_billingaddress_organization.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-07 13:07 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0010_order_description'), - ] - - operations = [ - migrations.AddField( - model_name='billingaddress', - name='organization', - field=models.CharField(default='', max_length=100), - preserve_default=False, - ), - ] diff --git a/uncloud_pay/migrations/0012_billnico.py b/uncloud_pay/migrations/0012_billnico.py deleted file mode 100644 index f69241d..0000000 --- a/uncloud_pay/migrations/0012_billnico.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-08 07:06 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('uncloud_pay', '0011_billingaddress_organization'), - ] - - operations = [ - migrations.CreateModel( - name='BillNico', - fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('creation_date', models.DateTimeField(auto_now_add=True)), - ('starting_date', models.DateTimeField()), - ('ending_date', models.DateTimeField()), - ('due_date', models.DateField()), - ('valid', models.BooleanField(default=True)), - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/uncloud_pay/migrations/0013_auto_20200508_1446.py b/uncloud_pay/migrations/0013_auto_20200508_1446.py deleted file mode 100644 index dcf7675..0000000 --- a/uncloud_pay/migrations/0013_auto_20200508_1446.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-08 14:46 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0012_billnico'), - ] - - operations = [ - migrations.AddField( - model_name='order', - name='depends_on', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='parent_of', to='uncloud_pay.Order'), - ), - migrations.AlterField( - model_name='order', - name='replaced_by', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='supersede', to='uncloud_pay.Order'), - ), - ] diff --git a/uncloud_pay/migrations/0014_paymentsettings.py b/uncloud_pay/migrations/0014_paymentsettings.py deleted file mode 100644 index 2a4f9a0..0000000 --- a/uncloud_pay/migrations/0014_paymentsettings.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-10 13:53 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('uncloud_pay', '0013_auto_20200508_1446'), - ] - - operations = [ - migrations.CreateModel( - name='PaymentSettings', - fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('owner', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ('primary_billing_address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.BillingAddress')), - ], - ), - ] diff --git a/uncloud_pay/migrations/0015_auto_20200523_2132.py b/uncloud_pay/migrations/0015_auto_20200523_2132.py deleted file mode 100644 index 90a241d..0000000 --- a/uncloud_pay/migrations/0015_auto_20200523_2132.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-23 21:32 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0014_paymentsettings'), - ] - - operations = [ - migrations.AlterField( - model_name='order', - name='recurring_period', - field=models.CharField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000, max_length=32), - ), - migrations.AlterField( - model_name='ordertimothee', - name='recurring_period', - field=models.CharField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000, max_length=32), - ), - migrations.DeleteModel( - name='PaymentSettings', - ), - ] diff --git a/uncloud_pay/migrations/0016_auto_20200523_2138.py b/uncloud_pay/migrations/0016_auto_20200523_2138.py deleted file mode 100644 index bcfdd3c..0000000 --- a/uncloud_pay/migrations/0016_auto_20200523_2138.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-23 21:38 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0015_auto_20200523_2132'), - ] - - operations = [ - migrations.AlterField( - model_name='order', - name='recurring_period', - field=models.IntegerField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000), - ), - migrations.AlterField( - model_name='ordertimothee', - name='recurring_period', - field=models.IntegerField(choices=[(31536000, 'Per 365 days'), (2592000, 'Per 30 days'), (604800, 'Per Week'), (86400, 'Per Day'), (3600, 'Per Hour'), (60, 'Per Minute'), (1, 'Per Second'), (0, 'Onetime')], default=2592000), - ), - ] diff --git a/uncloud_pay/migrations/0017_auto_20200621_1110.py b/uncloud_pay/migrations/0017_auto_20200621_1110.py deleted file mode 100644 index 351e242..0000000 --- a/uncloud_pay/migrations/0017_auto_20200621_1110.py +++ /dev/null @@ -1,55 +0,0 @@ -# Generated by Django 3.0.6 on 2020-06-21 11:10 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0016_auto_20200523_2138'), - ] - - operations = [ - migrations.CreateModel( - name='BillRecord', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('usage_count', models.IntegerField(default=1)), - ('creation_date', models.DateTimeField(auto_now_add=True)), - ('starting_date', models.DateTimeField()), - ('ending_date', models.DateTimeField()), - ('bill', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Bill')), - ], - ), - migrations.RemoveField( - model_name='ordertimothee', - name='bill', - ), - migrations.RemoveField( - model_name='ordertimothee', - name='billing_address', - ), - migrations.RemoveField( - model_name='ordertimothee', - name='owner', - ), - migrations.RemoveField( - model_name='order', - name='bill', - ), - migrations.RemoveField( - model_name='order', - name='one_time_price', - ), - migrations.RemoveField( - model_name='order', - name='recurring_price', - ), - migrations.DeleteModel( - name='BillNico', - ), - migrations.DeleteModel( - name='OrderTimothee', - ), - ] diff --git a/uncloud_pay/migrations/0018_auto_20200621_1140.py b/uncloud_pay/migrations/0018_auto_20200621_1140.py deleted file mode 100644 index efc4ff5..0000000 --- a/uncloud_pay/migrations/0018_auto_20200621_1140.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 3.0.6 on 2020-06-21 11:40 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0017_auto_20200621_1110'), - ] - - operations = [ - migrations.AddField( - model_name='bill', - name='bill_records', - field=models.ManyToManyField(through='uncloud_pay.BillRecord', to='uncloud_pay.Order'), - ), - migrations.AddField( - model_name='billrecord', - name='order', - field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order'), - preserve_default=False, - ), - ] diff --git a/uncloud_pay/migrations/0019_auto_20200621_1144.py b/uncloud_pay/migrations/0019_auto_20200621_1144.py deleted file mode 100644 index 7d5fab9..0000000 --- a/uncloud_pay/migrations/0019_auto_20200621_1144.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.0.6 on 2020-06-21 11:44 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0018_auto_20200621_1140'), - ] - - operations = [ - migrations.RemoveField( - model_name='bill', - name='uuid', - ), - migrations.AddField( - model_name='bill', - name='id', - field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), - preserve_default=False, - ), - ] diff --git a/uncloud_pay/models.py b/uncloud_pay/models.py index cb1537b..08b9b21 100644 --- a/uncloud_pay/models.py +++ b/uncloud_pay/models.py @@ -6,7 +6,6 @@ from django.core.validators import MinValueValidator from django.utils import timezone from django.core.exceptions import ObjectDoesNotExist, ValidationError -import uuid import logging from functools import reduce import itertools @@ -77,8 +76,6 @@ class StripeCustomer(models.Model): # Payments and Payment Methods. class Payment(models.Model): - uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) - owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) @@ -115,7 +112,6 @@ class Payment(models.Model): class PaymentMethod(models.Model): - uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, editable=False) @@ -198,7 +194,6 @@ class PaymentMethod(models.Model): # Bills. class BillingAddress(models.Model): - uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) organization = models.CharField(max_length=100) @@ -208,6 +203,14 @@ class BillingAddress(models.Model): postal_code = models.CharField(max_length=50) country = CountryField(blank=True) vat_number = models.CharField(max_length=100, default="", blank=True) + active = models.BooleanField(default=False) + + class Meta: + constraints = [ + models.UniqueConstraint(fields=['owner'], + condition=Q(primary=True), + name='one_active_billing_address_per_user') + ] @staticmethod def get_addresses_for(user): @@ -262,13 +265,13 @@ class Order(models.Model): bills. Do **NOT** mutate then! """ - uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, - editable=False) - billing_address = models.ForeignKey(BillingAddress, on_delete=models.CASCADE) + editable=True) + + billing_address = models.ForeignKey(BillingAddress, + on_delete=models.CASCADE) description = models.TextField() - replaced_by = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True) # TODO: enforce ending_date - starting_date to be larger than recurring_period. creation_date = models.DateTimeField(auto_now_add=True) @@ -276,20 +279,6 @@ class Order(models.Model): ending_date = models.DateTimeField(blank=True, null=True) - # bill_records = models.ManyToManyField(BillRecord, - # editable=False, - # blank=True) - - @property - def count_billed(self): - """ - How many times this order was billed so far. - This logic is mainly thought to be for recurring bills, but also works for one time bills - """ - - return sum([ br.usage_count for br in self.bill_records.all() ]) - - recurring_period = models.IntegerField(choices = RecurringPeriod.choices, default = RecurringPeriod.PER_30D) @@ -315,6 +304,16 @@ class Order(models.Model): blank=True, null=True) + @property + def count_billed(self): + """ + How many times this order was billed so far. + This logic is mainly thought to be for recurring bills, but also works for one time bills + """ + + return sum([ br.usage_count for br in self.bill_records.all() ]) + + def active_before(self, ending_date): # Was this order started before the specified ending date? if self.starting_date <= ending_date: @@ -366,13 +365,6 @@ class Order(models.Model): owner=product.owner, **kwargs) - def __str__(self): - return "Order {} created at {}, {}->{}, recurring period {}. One time price {}, recurring price {}".format( - self.uuid, self.creation_date, - self.starting_date, self.ending_date, - self.recurring_period, - self.one_time_price, - self.recurring_price) @property def records(self): @@ -398,8 +390,8 @@ class Order(models.Model): description=description) def __str__(self): - return "Order {} created at {}, {}->{}, recurring period {}. Price one time {}, recurring {}".format( - self.uuid, self.creation_date, + return "{} created at {}, {}->{}, recurring period {}. One time price {}, recurring price {}".format( + self.id, self.creation_date, self.starting_date, self.ending_date, self.recurring_period, self.one_time_price, @@ -411,7 +403,6 @@ class Bill(models.Model): Bill needs to be unique in the triple (owner, year, month) """ -# uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) @@ -570,7 +561,6 @@ class OrderRecord(models.Model): # Abstract (= no database representation) class used as parent for products # (e.g. uncloud_vm.models.VMProduct). class Product(UncloudModel): - uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) owner = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, editable=False) diff --git a/uncloud_service/migrations/0001_initial.py b/uncloud_service/migrations/0001_initial.py index f0f5535..d718327 100644 --- a/uncloud_service/migrations/0001_initial.py +++ b/uncloud_service/migrations/0001_initial.py @@ -1,10 +1,10 @@ -# Generated by Django 3.0.5 on 2020-04-13 09:38 +# Generated by Django 3.0.6 on 2020-06-21 12:34 from django.conf import settings import django.contrib.postgres.fields.jsonb +import django.core.validators from django.db import migrations, models import django.db.models.deletion -import uuid class Migration(migrations.Migration): @@ -12,8 +12,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('uncloud_pay', '0005_auto_20200413_0924'), - ('uncloud_vm', '0010_auto_20200413_0924'), + ('uncloud_pay', '0001_initial'), + ('uncloud_vm', '__first__'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] @@ -21,9 +21,9 @@ class Migration(migrations.Migration): migrations.CreateModel( name='MatrixServiceProduct', fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('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='PENDING', max_length=32)), + ('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)), ('domain', models.CharField(default='domain.tld', max_length=255)), ('order', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), @@ -33,4 +33,20 @@ class Migration(migrations.Migration): 'abstract': False, }, ), + migrations.CreateModel( + name='GenericServiceProduct', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('extra_data', django.contrib.postgres.fields.jsonb.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)), + ('custom_description', models.TextField()), + ('custom_recurring_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])), + ('custom_one_time_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])), + ('order', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), + ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'abstract': False, + }, + ), ] diff --git a/uncloud_service/migrations/0002_auto_20200418_0641.py b/uncloud_service/migrations/0002_auto_20200418_0641.py deleted file mode 100644 index 717f163..0000000 --- a/uncloud_service/migrations/0002_auto_20200418_0641.py +++ /dev/null @@ -1,41 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-18 06:41 - -from django.conf import settings -import django.contrib.postgres.fields.jsonb -import django.core.validators -from django.db import migrations, models -import django.db.models.deletion -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('uncloud_pay', '0005_auto_20200413_0924'), - ('uncloud_service', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='matrixserviceproduct', - name='status', - field=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), - ), - migrations.CreateModel( - name='GenericServiceProduct', - fields=[ - ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('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)), - ('custom_description', models.TextField()), - ('custom_recurring_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])), - ('custom_one_time_price', models.DecimalField(decimal_places=2, default=0.0, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])), - ('order', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), - ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'abstract': False, - }, - ), - ] diff --git a/uncloud_vm/migrations/0001_initial.py b/uncloud_vm/migrations/0001_initial.py index f9f40d8..675a286 100644 --- a/uncloud_vm/migrations/0001_initial.py +++ b/uncloud_vm/migrations/0001_initial.py @@ -1,6 +1,7 @@ -# Generated by Django 3.0.3 on 2020-03-05 10:34 +# Generated by Django 3.0.6 on 2020-06-21 12:34 from django.conf import settings +import django.contrib.postgres.fields.jsonb from django.db import migrations, models import django.db.models.deletion import uuid @@ -16,71 +17,82 @@ class Migration(migrations.Migration): ] operations = [ + migrations.CreateModel( + name='VMCluster', + fields=[ + ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), + ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('name', models.CharField(max_length=128, unique=True)), + ], + options={ + 'abstract': False, + }, + ), migrations.CreateModel( name='VMDiskImageProduct', fields=[ + ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('name', models.CharField(max_length=256)), ('is_os_image', models.BooleanField(default=False)), - ('is_public', models.BooleanField(default=False)), + ('is_public', models.BooleanField(default=False, editable=False)), ('size_in_gb', models.FloatField(blank=True, null=True)), ('import_url', models.URLField(blank=True, null=True)), ('image_source', models.CharField(max_length=128, null=True)), ('image_source_type', models.CharField(max_length=128, null=True)), - ('storage_class', models.CharField(choices=[('hdd', 'HDD'), ('ssd', 'SSD')], default='ssd', max_length=32)), - ('status', models.CharField(choices=[('pending', 'Pending'), ('creating', 'Creating'), ('active', 'Active'), ('disabled', 'Disabled'), ('unusable', 'Unusable'), ('deleted', 'Deleted')], default='pending', max_length=32)), + ('storage_class', models.CharField(choices=[('HDD', 'HDD'), ('SSD', 'SSD')], default='SSD', max_length=32)), + ('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='PENDING', max_length=32)), ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], + options={ + 'abstract': False, + }, ), migrations.CreateModel( name='VMHost', fields=[ + ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('hostname', models.CharField(max_length=253, unique=True)), ('physical_cores', models.IntegerField(default=0)), ('usable_cores', models.IntegerField(default=0)), ('usable_ram_in_gb', models.FloatField(default=0)), - ('status', models.CharField(choices=[('pending', 'Pending'), ('creating', 'Creating'), ('active', 'Active'), ('disabled', 'Disabled'), ('unusable', 'Unusable'), ('deleted', 'Deleted')], default='pending', max_length=32)), - ('vms', models.TextField(default='')), + ('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='PENDING', max_length=32)), + ('vmcluster', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMCluster')), ], + options={ + 'abstract': False, + }, ), migrations.CreateModel( name='VMProduct', fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('status', models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('ACTIVE', 'Active'), ('DELETED', 'Deleted')], default='PENDING', max_length=32)), - ('name', models.CharField(max_length=32)), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('extra_data', django.contrib.postgres.fields.jsonb.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)), + ('name', models.CharField(blank=True, max_length=32, null=True)), ('cores', models.IntegerField()), ('ram_in_gb', models.FloatField()), - ('vmid', models.IntegerField(null=True)), ('order', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('vmcluster', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMCluster')), ('vmhost', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMHost')), ], options={ 'abstract': False, }, ), - migrations.CreateModel( - name='VMWithOSProduct', - fields=[ - ('vmproduct_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='uncloud_vm.VMProduct')), - ], - options={ - 'abstract': False, - }, - bases=('uncloud_vm.vmproduct',), - ), migrations.CreateModel( name='VMSnapshotProduct', fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('status', models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('ACTIVE', 'Active'), ('DELETED', 'Deleted')], default='PENDING', max_length=32)), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('extra_data', django.contrib.postgres.fields.jsonb.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)), ('gb_ssd', models.FloatField(editable=False)), ('gb_hdd', models.FloatField(editable=False)), ('order', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ('vm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMProduct')), + ('vm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='snapshots', to='uncloud_vm.VMProduct')), ], options={ 'abstract': False, @@ -98,11 +110,28 @@ class Migration(migrations.Migration): migrations.CreateModel( name='VMDiskProduct', fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('extra_data', django.contrib.postgres.fields.jsonb.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)), ('size_in_gb', models.FloatField(blank=True)), ('image', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMDiskImageProduct')), + ('order', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order')), ('owner', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ('vm', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMProduct')), ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='VMWithOSProduct', + fields=[ + ('vmproduct_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='uncloud_vm.VMProduct')), + ('primary_disk', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMDiskProduct')), + ], + options={ + 'abstract': False, + }, + bases=('uncloud_vm.vmproduct',), ), ] diff --git a/uncloud_vm/migrations/0002_auto_20200305_1321.py b/uncloud_vm/migrations/0002_auto_20200305_1321.py deleted file mode 100644 index 2711b33..0000000 --- a/uncloud_vm/migrations/0002_auto_20200305_1321.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-05 13:21 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='vmdiskimageproduct', - name='storage_class', - field=models.CharField(choices=[('HDD', 'HDD'), ('SSD', 'SSD')], default='SSD', max_length=32), - ), - migrations.AlterField( - model_name='vmproduct', - name='name', - field=models.CharField(blank=True, max_length=32, null=True), - ), - ] diff --git a/uncloud_vm/migrations/0003_remove_vmhost_vms.py b/uncloud_vm/migrations/0003_remove_vmhost_vms.py deleted file mode 100644 index 70ee863..0000000 --- a/uncloud_vm/migrations/0003_remove_vmhost_vms.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-05 13:58 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0002_auto_20200305_1321'), - ] - - operations = [ - migrations.RemoveField( - model_name='vmhost', - name='vms', - ), - ] diff --git a/uncloud_vm/migrations/0004_remove_vmproduct_vmid.py b/uncloud_vm/migrations/0004_remove_vmproduct_vmid.py deleted file mode 100644 index 5f44b57..0000000 --- a/uncloud_vm/migrations/0004_remove_vmproduct_vmid.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-17 14:40 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0003_remove_vmhost_vms'), - ] - - operations = [ - migrations.RemoveField( - model_name='vmproduct', - name='vmid', - ), - ] diff --git a/uncloud_vm/migrations/0004_vmproduct_primary_disk.py b/uncloud_vm/migrations/0004_vmproduct_primary_disk.py deleted file mode 100644 index c78acc1..0000000 --- a/uncloud_vm/migrations/0004_vmproduct_primary_disk.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-09 12:43 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0004_remove_vmproduct_vmid'), - ] - - operations = [ - migrations.AddField( - model_name='vmproduct', - name='primary_disk', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMDiskProduct'), - ), - ] diff --git a/uncloud_vm/migrations/0005_auto_20200309_1258.py b/uncloud_vm/migrations/0005_auto_20200309_1258.py deleted file mode 100644 index 0356558..0000000 --- a/uncloud_vm/migrations/0005_auto_20200309_1258.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-09 12:58 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_pay', '0001_initial'), - ('uncloud_vm', '0004_vmproduct_primary_disk'), - ] - - operations = [ - migrations.AddField( - model_name='vmdiskproduct', - name='order', - field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_pay.Order'), - ), - migrations.AddField( - model_name='vmdiskproduct', - name='status', - field=models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('ACTIVE', 'Active'), ('DELETED', 'Deleted')], default='PENDING', max_length=32), - ), - ] diff --git a/uncloud_vm/migrations/0005_auto_20200321_1058.py b/uncloud_vm/migrations/0005_auto_20200321_1058.py deleted file mode 100644 index 40eface..0000000 --- a/uncloud_vm/migrations/0005_auto_20200321_1058.py +++ /dev/null @@ -1,50 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-21 10:58 - -import django.contrib.postgres.fields.jsonb -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0005_auto_20200309_1258'), - ] - - operations = [ - migrations.AddField( - model_name='vmdiskimageproduct', - name='extra_data', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True), - ), - migrations.AddField( - model_name='vmdiskproduct', - name='extra_data', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True), - ), - migrations.AddField( - model_name='vmhost', - name='extra_data', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True), - ), - migrations.AddField( - model_name='vmproduct', - name='extra_data', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True), - ), - migrations.AddField( - model_name='vmsnapshotproduct', - name='extra_data', - field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True), - ), - migrations.AlterField( - model_name='vmdiskproduct', - name='vm', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='disks', to='uncloud_vm.VMProduct'), - ), - migrations.AlterField( - model_name='vmsnapshotproduct', - name='vm', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='snapshots', to='uncloud_vm.VMProduct'), - ), - ] diff --git a/uncloud_vm/migrations/0006_auto_20200322_1758.py b/uncloud_vm/migrations/0006_auto_20200322_1758.py deleted file mode 100644 index 7726c9b..0000000 --- a/uncloud_vm/migrations/0006_auto_20200322_1758.py +++ /dev/null @@ -1,57 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-22 17:58 - -import django.contrib.postgres.fields.jsonb -from django.db import migrations, models -import django.db.models.deletion -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0005_auto_20200321_1058'), - ] - - operations = [ - migrations.CreateModel( - name='VMCluster', - fields=[ - ('extra_data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, editable=False, null=True)), - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=128, unique=True)), - ], - options={ - 'abstract': False, - }, - ), - migrations.AlterField( - model_name='vmdiskimageproduct', - name='is_public', - field=models.BooleanField(default=False, editable=False), - ), - migrations.AlterField( - model_name='vmdiskimageproduct', - name='status', - field=models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('ACTIVE', 'Active'), ('DELETED', 'Deleted'), ('DISABLED', 'Disabled'), ('UNUSABLE', 'Unusable')], default='PENDING', max_length=32), - ), - migrations.AlterField( - model_name='vmhost', - name='status', - field=models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('ACTIVE', 'Active'), ('DELETED', 'Deleted'), ('DISABLED', 'Disabled'), ('UNUSABLE', 'Unusable')], default='PENDING', max_length=32), - ), - migrations.AlterField( - model_name='vmproduct', - name='status', - field=models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('ACTIVE', 'Active'), ('DELETED', 'Deleted'), ('DISABLED', 'Disabled'), ('UNUSABLE', 'Unusable')], default='PENDING', max_length=32), - ), - migrations.AlterField( - model_name='vmsnapshotproduct', - name='status', - field=models.CharField(choices=[('PENDING', 'Pending'), ('AWAITING_PAYMENT', 'Awaiting payment'), ('BEING_CREATED', 'Being created'), ('ACTIVE', 'Active'), ('DELETED', 'Deleted'), ('DISABLED', 'Disabled'), ('UNUSABLE', 'Unusable')], default='PENDING', max_length=32), - ), - migrations.AddField( - model_name='vmproduct', - name='vmcluster', - field=models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMCluster'), - ), - ] diff --git a/uncloud_vm/migrations/0007_vmhost_vmcluster.py b/uncloud_vm/migrations/0007_vmhost_vmcluster.py deleted file mode 100644 index 6766dd7..0000000 --- a/uncloud_vm/migrations/0007_vmhost_vmcluster.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.3 on 2020-03-22 18:09 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0006_auto_20200322_1758'), - ] - - operations = [ - migrations.AddField( - model_name='vmhost', - name='vmcluster', - field=models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMCluster'), - ), - ] diff --git a/uncloud_vm/migrations/0008_auto_20200403_1727.py b/uncloud_vm/migrations/0008_auto_20200403_1727.py deleted file mode 100644 index 5f4b494..0000000 --- a/uncloud_vm/migrations/0008_auto_20200403_1727.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-03 17:27 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0007_vmhost_vmcluster'), - ] - - operations = [ - migrations.AlterField( - model_name='vmdiskimageproduct', - name='status', - field=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='PENDING', max_length=32), - ), - migrations.AlterField( - model_name='vmhost', - name='status', - field=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='PENDING', max_length=32), - ), - migrations.AlterField( - model_name='vmproduct', - name='status', - field=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='PENDING', max_length=32), - ), - migrations.AlterField( - model_name='vmsnapshotproduct', - name='status', - field=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='PENDING', max_length=32), - ), - ] diff --git a/uncloud_vm/migrations/0009_auto_20200417_0551.py b/uncloud_vm/migrations/0009_auto_20200417_0551.py deleted file mode 100644 index 641f849..0000000 --- a/uncloud_vm/migrations/0009_auto_20200417_0551.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-17 05:51 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0008_auto_20200403_1727'), - ] - - operations = [ - migrations.AlterField( - model_name='vmproduct', - name='status', - field=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), - ), - migrations.AlterField( - model_name='vmsnapshotproduct', - name='status', - field=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), - ), - ] diff --git a/uncloud_vm/migrations/0009_merge_20200413_0857.py b/uncloud_vm/migrations/0009_merge_20200413_0857.py deleted file mode 100644 index 2a9d70c..0000000 --- a/uncloud_vm/migrations/0009_merge_20200413_0857.py +++ /dev/null @@ -1,14 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-13 08:57 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0004_remove_vmproduct_vmid'), - ('uncloud_vm', '0008_auto_20200403_1727'), - ] - - operations = [ - ] diff --git a/uncloud_vm/migrations/0010_auto_20200413_0924.py b/uncloud_vm/migrations/0010_auto_20200413_0924.py deleted file mode 100644 index 8883277..0000000 --- a/uncloud_vm/migrations/0010_auto_20200413_0924.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-13 09:24 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0009_merge_20200413_0857'), - ] - - operations = [ - migrations.AlterField( - model_name='vmdiskproduct', - name='status', - field=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='PENDING', max_length=32), - ), - migrations.AlterField( - model_name='vmdiskproduct', - name='vm', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMProduct'), - ), - ] diff --git a/uncloud_vm/migrations/0011_merge_20200418_0641.py b/uncloud_vm/migrations/0011_merge_20200418_0641.py deleted file mode 100644 index c0d4c32..0000000 --- a/uncloud_vm/migrations/0011_merge_20200418_0641.py +++ /dev/null @@ -1,14 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-18 06:41 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0009_auto_20200417_0551'), - ('uncloud_vm', '0010_auto_20200413_0924'), - ] - - operations = [ - ] diff --git a/uncloud_vm/migrations/0012_auto_20200418_0641.py b/uncloud_vm/migrations/0012_auto_20200418_0641.py deleted file mode 100644 index 9af8649..0000000 --- a/uncloud_vm/migrations/0012_auto_20200418_0641.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-18 06:41 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0011_merge_20200418_0641'), - ] - - operations = [ - migrations.AlterField( - model_name='vmdiskproduct', - name='status', - field=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), - ), - ] diff --git a/uncloud_vm/migrations/0013_remove_vmproduct_primary_disk.py b/uncloud_vm/migrations/0013_remove_vmproduct_primary_disk.py deleted file mode 100644 index 849012d..0000000 --- a/uncloud_vm/migrations/0013_remove_vmproduct_primary_disk.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 3.0.5 on 2020-05-02 19:21 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0012_auto_20200418_0641'), - ] - - operations = [ - migrations.RemoveField( - model_name='vmproduct', - name='primary_disk', - ), - ] diff --git a/uncloud_vm/migrations/0014_vmwithosproduct_primary_disk.py b/uncloud_vm/migrations/0014_vmwithosproduct_primary_disk.py deleted file mode 100644 index 4747f60..0000000 --- a/uncloud_vm/migrations/0014_vmwithosproduct_primary_disk.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.6 on 2020-05-08 14:01 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_vm', '0013_remove_vmproduct_primary_disk'), - ] - - operations = [ - migrations.AddField( - model_name='vmwithosproduct', - name='primary_disk', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='uncloud_vm.VMDiskProduct'), - ), - ]