Set foreign key relationship to on cascade delete for Person
This commit is contained in:
parent
61ffae3899
commit
a7362a1310
2 changed files with 59 additions and 8 deletions
49
app/migrations/0051_auto_20220104_1608.py
Normal file
49
app/migrations/0051_auto_20220104_1608.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# Generated by Django 3.2.5 on 2022-01-04 16:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('app', '0050_alter_mountainrange_range_name_map'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='peoplefunction',
|
||||||
|
name='person',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.person'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='peoplerange',
|
||||||
|
name='person',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.person'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='peopleresource',
|
||||||
|
name='person',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.person'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='rangespeople',
|
||||||
|
name='person',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.person'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='resourcespeople',
|
||||||
|
name='person',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.person'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='resourcespeople',
|
||||||
|
name='resource',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.resource'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='taxapeople',
|
||||||
|
name='person',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='app.person'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -673,7 +673,9 @@ Involved scientist''')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def fullname(self):
|
def fullname(self):
|
||||||
return " ".join([self.title, self.first_name, self.last_name])
|
return " ".join([self.title if self.title else '',
|
||||||
|
self.first_name if self.first_name else '',
|
||||||
|
self.last_name if self.last_name else ''])
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.fullname() if self.fullname() else ""
|
return self.fullname() if self.fullname() else ""
|
||||||
|
@ -693,7 +695,7 @@ Involved scientist''')
|
||||||
|
|
||||||
class TaxaPeople(models.Model):
|
class TaxaPeople(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True)
|
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
|
||||||
taxon = models.ForeignKey('Taxon', models.DO_NOTHING, blank=True, null=True)
|
taxon = models.ForeignKey('Taxon', models.DO_NOTHING, blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -705,7 +707,7 @@ class TaxaPeople(models.Model):
|
||||||
|
|
||||||
class RangesPeople(models.Model):
|
class RangesPeople(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True)
|
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
|
||||||
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
|
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -717,8 +719,8 @@ class RangesPeople(models.Model):
|
||||||
|
|
||||||
class ResourcesPeople(models.Model):
|
class ResourcesPeople(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True)
|
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
|
||||||
resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
|
resource = models.ForeignKey(Resource, models.CASCADE, blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'resources_people'
|
db_table = 'resources_people'
|
||||||
|
@ -752,7 +754,7 @@ class Species(models.Model):
|
||||||
|
|
||||||
class PeopleFunction(models.Model):
|
class PeopleFunction(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True)
|
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
|
||||||
function = models.ForeignKey(GMBA_function, models.DO_NOTHING, blank=True, null=True)
|
function = models.ForeignKey(GMBA_function, models.DO_NOTHING, blank=True, null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -772,7 +774,7 @@ class SpeciesRange(models.Model):
|
||||||
|
|
||||||
class PeopleRange(models.Model):
|
class PeopleRange(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True)
|
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
|
||||||
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
|
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -811,7 +813,7 @@ class PeopleResource(models.Model):
|
||||||
('SSC', 'SSC'),
|
('SSC', 'SSC'),
|
||||||
)
|
)
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True)
|
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
|
||||||
resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
|
resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
|
||||||
role = models.TextField(blank=True, null=True, choices=ROLES_CHOICES)
|
role = models.TextField(blank=True, null=True, choices=ROLES_CHOICES)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue