added on_delete parameter to foreign_key and oneToOne fields

changes made to fix issues with quality
This commit is contained in:
aarif
2019-12-27 19:08:39 +05:00
parent 1cbe81f747
commit 02350e0fee
5 changed files with 11 additions and 8 deletions

View File

@@ -21,7 +21,8 @@ class Migration(migrations.Migration):
('possible_all_override', models.FloatField(null=True, blank=True)),
('earned_graded_override', models.FloatField(null=True, blank=True)),
('possible_graded_override', models.FloatField(null=True, blank=True)),
('grade', models.OneToOneField(related_name='override', to='grades.PersistentSubsectionGrade')),
('grade', models.OneToOneField(related_name='override', to='grades.PersistentSubsectionGrade',
on_delete=models.CASCADE)),
],
),
]

View File

@@ -655,7 +655,7 @@ class PersistentSubsectionGradeOverride(models.Model):
class Meta(object):
app_label = "grades"
grade = models.OneToOneField(PersistentSubsectionGrade, related_name='override')
grade = models.OneToOneField(PersistentSubsectionGrade, related_name='override', on_delete=models.CASCADE)
# Created/modified timestamps prevent race-conditions when using with async rescoring tasks
created = models.DateTimeField(auto_now_add=True, db_index=True)
@@ -806,7 +806,7 @@ class PersistentSubsectionGradeOverrideHistory(models.Model):
choices=OVERRIDE_ACTIONS,
default=CREATE_OR_UPDATE
)
user = models.ForeignKey(User, blank=True, null=True)
user = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
comments = models.CharField(max_length=300, blank=True, null=True)
created = models.DateTimeField(auto_now_add=True, db_index=True)

View File

@@ -40,7 +40,7 @@ class ProgramEnrollment(TimeStampedModel): # pylint: disable=model-missing-unic
user = models.ForeignKey(
User,
null=True,
blank=True
blank=True, on_delete=models.CASCADE
)
external_user_key = models.CharField(
db_index=True,

View File

@@ -69,7 +69,8 @@ class ApplicationAccess(models.Model):
.. no_pii:
"""
application = models.OneToOneField(oauth2_settings.APPLICATION_MODEL, related_name='access')
application = models.OneToOneField(oauth2_settings.APPLICATION_MODEL, related_name='access',
on_delete=models.CASCADE)
scopes = ListCharField(
base_field=models.CharField(max_length=32),
size=25,
@@ -109,8 +110,9 @@ class ApplicationOrganization(models.Model):
(RELATION_TYPE_CONTENT_ORG, _('Content Provider')),
)
application = models.ForeignKey(oauth2_settings.APPLICATION_MODEL, related_name='organizations')
organization = models.ForeignKey(Organization)
application = models.ForeignKey(oauth2_settings.APPLICATION_MODEL, related_name='organizations',
on_delete=models.CASCADE)
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
relation_type = models.CharField(
max_length=32,
choices=RELATION_TYPES,

View File

@@ -204,7 +204,7 @@ class UserRetirementPartnerReportingStatus(TimeStampedModel):
.. pii_types: name, username, email_address
.. pii_retirement: local_api
"""
user = models.OneToOneField(User)
user = models.OneToOneField(User, on_delete=models.CASCADE)
original_username = models.CharField(max_length=150, db_index=True)
original_email = models.EmailField(db_index=True)
original_name = models.CharField(max_length=255, blank=True, db_index=True)