Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions async/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Migration(migrations.Migration):
('started', models.DateTimeField(null=True, blank=True)),
('executed', models.DateTimeField(null=True, blank=True)),
('cancelled', models.DateTimeField(null=True, blank=True)),
('group', models.ForeignKey(related_name='jobs', blank=True, to='async.Group', null=True)),
('group', models.ForeignKey(related_name='jobs', blank=True, to='async.Group', null=True, on_delete=models.SET_NULL)),
],
options={
},
Expand All @@ -59,13 +59,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='group',
name='final',
field=models.ForeignKey(related_name='ends', blank=True, to='async.Job', null=True),
field=models.ForeignKey(related_name='ends', blank=True, to='async.Job', null=True, on_delete=models.SET_NULL),
preserve_default=True,
),
migrations.AddField(
model_name='error',
name='job',
field=models.ForeignKey(related_name='errors', to='async.Job'),
field=models.ForeignKey(related_name='errors', to='async.Job', on_delete=models.CASCADE),
preserve_default=True,
),
]
16 changes: 11 additions & 5 deletions async/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ class Group(models.Model):
reference = models.CharField(max_length=100)
description = models.TextField(blank=True, null=True)
created = models.DateTimeField(auto_now_add=True)
final = models.ForeignKey('Job', blank=True, null=True,
related_name='ends')
final = models.ForeignKey('Job',
on_delete=models.SET_NULL,
blank=True, null=True,
related_name='ends')

def __unicode__(self):
return u'%s' % self.reference
Expand Down Expand Up @@ -156,8 +158,10 @@ class Job(models.Model):
executed = models.DateTimeField(null=True, blank=True)
cancelled = models.DateTimeField(null=True, blank=True)

group = models.ForeignKey(Group, related_name='jobs',
null=True, blank=True)
group = models.ForeignKey(Group,
on_delete=models.SET_NULL,
related_name='jobs',
null=True, blank=True)

def __unicode__(self):
# __unicode__: Instance of 'bool' has no 'items' member
Expand Down Expand Up @@ -246,7 +250,9 @@ class Error(models.Model):
"""
Recorded when an error happens during execution of a job.
"""
job = models.ForeignKey(Job, related_name='errors')
job = models.ForeignKey(Job,
on_delete=models.CASCADE,
related_name='errors')
executed = models.DateTimeField(auto_now_add=True)
exception = models.TextField()
traceback = models.TextField()
Expand Down