Skip to content

Commit

Permalink
set on_delete on ForeignKeys, OneToOneFields and TreeForeignKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
shagi committed Nov 18, 2019
1 parent f1d20b2 commit 71c6544
Show file tree
Hide file tree
Showing 28 changed files with 1,364 additions and 1,363 deletions.
12 changes: 6 additions & 6 deletions account/migrations/0001_initial.py

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class Account(models.Model):

user = models.OneToOneField(User, related_name="account", verbose_name=_("user"))
user = models.OneToOneField(User, related_name="account", verbose_name=_("user"), on_delete=models.CASCADE)
timezone = TimeZoneField(_("timezone"))
language = models.CharField(_("language"),
max_length=10,
Expand Down Expand Up @@ -127,7 +127,7 @@ class InvalidCode(Exception):
code = models.CharField(max_length=64, unique=True)
max_uses = models.PositiveIntegerField(default=0)
expiry = models.DateTimeField(null=True, blank=True)
inviter = models.ForeignKey(User, null=True, blank=True)
inviter = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL)
email = models.EmailField(blank=True)
notes = models.TextField(blank=True)
sent = models.DateTimeField(null=True, blank=True)
Expand Down Expand Up @@ -221,8 +221,8 @@ def send(self, **kwargs):

class SignupCodeResult(models.Model):

signup_code = models.ForeignKey(SignupCode)
user = models.ForeignKey(User)
signup_code = models.ForeignKey(SignupCode, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
timestamp = models.DateTimeField(default=datetime.datetime.now)

def save(self, **kwargs):
Expand All @@ -232,7 +232,7 @@ def save(self, **kwargs):

class EmailAddress(models.Model):

user = models.ForeignKey(User)
user = models.ForeignKey(User, on_delete=models.CASCADE)
email = models.EmailField(unique=settings.ACCOUNT_EMAIL_UNIQUE)
verified = models.BooleanField(default=False)
primary = models.BooleanField(default=False)
Expand Down Expand Up @@ -285,7 +285,7 @@ def change(self, new_email, confirm=True):

class EmailConfirmation(models.Model):

email_address = models.ForeignKey(EmailAddress)
email_address = models.ForeignKey(EmailAddress, on_delete=models.CASCADE)
created = models.DateTimeField(default=timezone.now)
sent = models.DateTimeField(null=True)
key = models.CharField(max_length=64, unique=True)
Expand Down
204 changes: 102 additions & 102 deletions general/migrations/0001_initial.py

Large diffs are not rendered by default.

106 changes: 53 additions & 53 deletions general/migrations/0002_auto_20161130_1145.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions general/migrations/0004_auto_20161201_1831.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='rel_human_jobs',
name='job',
field=mptt.fields.TreeForeignKey(verbose_name='Job', to='general.Job'),
field=mptt.fields.TreeForeignKey(verbose_name='Job', to='general.Job', on_delete=models.CASCADE),
),
migrations.AlterField(
model_name='rel_human_jobs',
name='relation',
field=mptt.fields.TreeForeignKey(related_name='hu_job+', verbose_name='relation', blank=True, to='general.Relation', null=True),
field=mptt.fields.TreeForeignKey(related_name='hu_job+', verbose_name='relation', blank=True, to='general.Relation', null=True, on_delete=models.SET_NULL),
),
]
1,572 changes: 786 additions & 786 deletions general/models.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions validation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class Validation(models.Model):
event = models.ForeignKey(EconomicEvent,
related_name="validations")
related_name="validations", on_delete=models.CASCADE)
validated_by = models.ForeignKey(EconomicAgent,
related_name="validations")
related_name="validations", on_delete=models.CASCADE)
validation_date = models.DateField(auto_now_add=True, blank=True, null=True, editable=False)
note = models.TextField(blank=True, null=True)

Expand Down
4 changes: 2 additions & 2 deletions valuenetwork/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def formatAgentList(agent_list):
class QuantityValue(models.Model):
numeric_value = models.DecimalField(max_digits=8, decimal_places=2,
default=Decimal("0.00"))
unit = models.ForeignKey(Unit, blank=True, null=True,
unit = models.ForeignKey(Unit, blank=True, null=True, on_delete=models.SET_NULL,
related_name="quantity_value_units")

class Meta:
Expand Down Expand Up @@ -88,7 +88,7 @@ class Fulfillment(models.Model):
on_delete=models.DO_NOTHING)
fulfills = models.ForeignKey(Commitment,
related_name="fulfillments",
on_delete=models.DO_NOTHING)
on_delete=models.DO_NOTHING)
fulfilled_quantity = models.ForeignKey(QuantityValue,
related_name="fulfillments",
on_delete=models.DO_NOTHING)
Expand Down
356 changes: 178 additions & 178 deletions valuenetwork/valueaccounting/migrations/0001_initial.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='agenttype',
name='parent',
field=models.ForeignKey(related_name='sub_agents', blank=True, editable=False, to='valueaccounting.AgentType', null=True, verbose_name='parent'),
field=models.ForeignKey(related_name='sub_agents', blank=True, editable=False, to='valueaccounting.AgentType', null=True, verbose_name='parent', on_delete=models.SET_NULL),
preserve_default=True,
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='economicresourcetype',
name='context_agent',
field=models.ForeignKey(related_name='context_resource_types', verbose_name='context agent', blank=True, to='valueaccounting.EconomicAgent', null=True),
field=models.ForeignKey(related_name='context_resource_types', verbose_name='context agent', blank=True, to='valueaccounting.EconomicAgent', null=True, on_delete=models.SET_NULL),
),
migrations.AddField(
model_name='exchangetype',
name='context_agent',
field=models.ForeignKey(related_name='exchange_types', verbose_name='context agent', blank=True, to='valueaccounting.EconomicAgent', null=True),
field=models.ForeignKey(related_name='exchange_types', verbose_name='context agent', blank=True, to='valueaccounting.EconomicAgent', null=True, on_delete=models.SET_NULL),
),
migrations.AddField(
model_name='processpattern',
name='context_agent',
field=models.ForeignKey(related_name='process_patterns', verbose_name='context agent', blank=True, to='valueaccounting.EconomicAgent', null=True),
field=models.ForeignKey(related_name='process_patterns', verbose_name='context agent', blank=True, to='valueaccounting.EconomicAgent', null=True, on_delete=models.SET_NULL),
),
]
Loading

0 comments on commit 71c6544

Please sign in to comment.