@python_2_unicode_compatible
class DelegationRule(models.Model):
- project = models.ForeignKey(Project)
+ project = models.ForeignKey(Project, on_delete=models.CASCADE)
user = models.ForeignKey(
User,
+ on_delete=models.CASCADE,
help_text='A user to delegate the patch to.')
path = models.CharField(
max_length=255,
@python_2_unicode_compatible
class UserProfile(models.Model):
- user = models.OneToOneField(User, unique=True, related_name='profile')
+ user = models.OneToOneField(User, unique=True, related_name='profile',
+ on_delete=models.CASCADE)
# projects
class PatchTag(models.Model):
- patch = models.ForeignKey('Patch')
- tag = models.ForeignKey('Tag')
+ patch = models.ForeignKey('Patch', on_delete=models.CASCADE)
+ tag = models.ForeignKey('Tag', on_delete=models.CASCADE)
count = models.IntegerField(default=1)
class Meta:
# content
- submitter = models.ForeignKey(Person)
+ submitter = models.ForeignKey(Person, on_delete=models.CASCADE)
content = models.TextField(null=True, blank=True)
response_re = re.compile(
class Submission(EmailMixin, models.Model):
# parent
- project = models.ForeignKey(Project)
+ project = models.ForeignKey(Project, on_delete=models.CASCADE)
# submission metadata
# patchwork metadata
- delegate = models.ForeignKey(User, blank=True, null=True)
- state = models.ForeignKey(State, null=True)
+ delegate = models.ForeignKey(User, blank=True, null=True,
+ on_delete=models.CASCADE)
+ state = models.ForeignKey(State, null=True, on_delete=models.CASCADE)
archived = models.BooleanField(default=False)
hash = HashField(null=True, blank=True)
# parent
submission = models.ForeignKey(Submission, related_name='comments',
- related_query_name='comment')
+ related_query_name='comment',
+ on_delete=models.CASCADE)
def save(self, *args, **kwargs):
super(Comment, self).save(*args, **kwargs)
# parent
project = models.ForeignKey(Project, related_name='series', null=True,
- blank=True)
+ blank=True, on_delete=models.CASCADE)
# content
cover_letter = models.ForeignKey(CoverLetter,
related_name='series',
- null=True, blank=True)
+ null=True, blank=True,
+ on_delete=models.CASCADE)
patches = models.ManyToManyField(Patch, through='SeriesPatch',
related_name='series')
help_text='An optional name to associate with '
'the series, e.g. "John\'s PCI series".')
date = models.DateTimeField()
- submitter = models.ForeignKey(Person)
+ submitter = models.ForeignKey(Person, on_delete=models.CASCADE)
version = models.IntegerField(default=1,
help_text='Version of series as indicated '
'by the subject prefix(es)')
Patches can belong to many series. This allows for things like
auto-completion of partial series.
"""
- patch = models.ForeignKey(Patch)
- series = models.ForeignKey(Series)
+ patch = models.ForeignKey(Patch, on_delete=models.CASCADE)
+ series = models.ForeignKey(Series, on_delete=models.CASCADE)
number = models.PositiveSmallIntegerField(
help_text='The number assigned to this patch in the series')
received before the cover letter.
"""
series = models.ForeignKey(Series, related_name='references',
- related_query_name='reference')
+ related_query_name='reference',
+ on_delete=models.CASCADE)
msgid = models.CharField(max_length=255)
def __str__(self):
class Bundle(models.Model):
- owner = models.ForeignKey(User)
- project = models.ForeignKey(Project)
+ owner = models.ForeignKey(User, on_delete=models.CASCADE)
+ project = models.ForeignKey(Project, on_delete=models.CASCADE)
name = models.CharField(max_length=50, null=False, blank=False)
patches = models.ManyToManyField(Patch, through='BundlePatch')
public = models.BooleanField(default=False)
class BundlePatch(models.Model):
- patch = models.ForeignKey(Patch)
- bundle = models.ForeignKey(Bundle)
+ patch = models.ForeignKey(Patch, on_delete=models.CASCADE)
+ bundle = models.ForeignKey(Bundle, on_delete=models.CASCADE)
order = models.IntegerField()
class Meta:
(STATE_FAIL, 'fail'),
)
- patch = models.ForeignKey(Patch)
- user = models.ForeignKey(User)
+ patch = models.ForeignKey(Patch, on_delete=models.CASCADE)
+ user = models.ForeignKey(User, on_delete=models.CASCADE)
date = models.DateTimeField(default=datetime.datetime.now)
state = models.SmallIntegerField(
project = models.ForeignKey(
Project, related_name='+', db_index=True,
+ on_delete=models.CASCADE,
help_text='The project that the events belongs to.')
# event metadata
patch = models.ForeignKey(
Patch, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE,
help_text='The patch that this event was created for.')
series = models.ForeignKey(
Series, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE,
help_text='The series that this event was created for.')
cover = models.ForeignKey(
CoverLetter, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE,
help_text='The cover letter that this event was created for.')
# fields for 'patch-state-changed' events
previous_state = models.ForeignKey(
- State, related_name='+', null=True, blank=True)
+ State, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE)
current_state = models.ForeignKey(
- State, related_name='+', null=True, blank=True)
+ State, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE)
# fields for 'patch-delegate-changed' events
previous_delegate = models.ForeignKey(
- User, related_name='+', null=True, blank=True)
+ User, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE)
current_delegate = models.ForeignKey(
- User, related_name='+', null=True, blank=True)
+ User, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE)
# fields or 'patch-check-created' events
created_check = models.ForeignKey(
- Check, related_name='+', null=True, blank=True)
+ Check, related_name='+', null=True, blank=True,
+ on_delete=models.CASCADE)
# TODO(stephenfin): Validate that the correct fields are being set by way
# of a 'clean' method
('optout', 'Email opt-out'),
])
email = models.CharField(max_length=200)
- user = models.ForeignKey(User, null=True)
+ user = models.ForeignKey(User, null=True, on_delete=models.CASCADE)
key = HashField()
date = models.DateTimeField(default=datetime.datetime.now)
active = models.BooleanField(default=True)
class PatchChangeNotification(models.Model):
- patch = models.OneToOneField(Patch, primary_key=True)
+ patch = models.OneToOneField(Patch, primary_key=True,
+ on_delete=models.CASCADE)
last_modified = models.DateTimeField(default=datetime.datetime.now)
- orig_state = models.ForeignKey(State)
+ orig_state = models.ForeignKey(State, on_delete=models.CASCADE)
if django.VERSION < (1, 7):