From ce0b75ae2d96d735cda05178700cf8fc9e69b6cf Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 11 Feb 2023 18:18:07 +0000 Subject: [PATCH] Make account on AssetGroup optional --- .../0057_alter_assetgroup_account_and_more.py | 24 +++++++++++++++++++ core/models.py | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 core/migrations/0057_alter_assetgroup_account_and_more.py diff --git a/core/migrations/0057_alter_assetgroup_account_and_more.py b/core/migrations/0057_alter_assetgroup_account_and_more.py new file mode 100644 index 0000000..b0afd61 --- /dev/null +++ b/core/migrations/0057_alter_assetgroup_account_and_more.py @@ -0,0 +1,24 @@ +# Generated by Django 4.1.6 on 2023-02-11 18:17 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0056_alter_assetrestriction_pairs_parsed'), + ] + + operations = [ + migrations.AlterField( + model_name='assetgroup', + name='account', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='core.account'), + ), + migrations.AlterField( + model_name='assetrestriction', + name='pairs_parsed', + field=models.JSONField(blank=True, default=list, null=True), + ), + ] diff --git a/core/models.py b/core/models.py index dbff30f..09a50dc 100644 --- a/core/models.py +++ b/core/models.py @@ -412,7 +412,7 @@ class AssetGroup(models.Model): description = models.TextField(null=True, blank=True) # Account for checking pairs on children if specified - account = models.ForeignKey(Account, on_delete=models.CASCADE) + account = models.ForeignKey(Account, on_delete=models.PROTECT, null=True, blank=True) # Dict like {"RUB": True, "USD": False} allowed = models.JSONField(null=True, blank=True, default=dict)