add on_delete to all foreignkeys
This commit is contained in:
parent
663099a603
commit
df5e167376
|
@ -4,7 +4,7 @@ from utils.models import CampRelatedModel
|
|||
|
||||
class ProductCategory(CampRelatedModel):
|
||||
name = models.CharField(max_length=255)
|
||||
camp = models.ForeignKey('camps.Camp')
|
||||
camp = models.ForeignKey('camps.Camp', on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -16,7 +16,11 @@ class ProductCategory(CampRelatedModel):
|
|||
class Product(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
price = models.IntegerField()
|
||||
category = models.ForeignKey(ProductCategory, related_name="products")
|
||||
category = models.ForeignKey(
|
||||
ProductCategory,
|
||||
related_name="products",
|
||||
on_delete=models.PROTECT
|
||||
)
|
||||
in_stock = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -655,7 +655,11 @@ class Speaker(CampRelatedModel):
|
|||
|
||||
|
||||
class Favorite(models.Model):
|
||||
user = models.ForeignKey('auth.User', related_name='favorites')
|
||||
user = models.ForeignKey(
|
||||
'auth.User',
|
||||
related_name='favorites',
|
||||
on_delete=models.PROTECT
|
||||
)
|
||||
event_instance = models.ForeignKey('program.EventInstance')
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -72,6 +72,7 @@ class Order(CreatedUpdatedModel):
|
|||
verbose_name=_('User'),
|
||||
help_text=_('The user this shop order belongs to.'),
|
||||
related_name='orders',
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
|
||||
paid = models.BooleanField(
|
||||
|
@ -290,7 +291,8 @@ class Product(CreatedUpdatedModel, UUIDModel):
|
|||
|
||||
category = models.ForeignKey(
|
||||
'shop.ProductCategory',
|
||||
related_name='products'
|
||||
related_name='products',
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
|
||||
name = models.CharField(max_length=150)
|
||||
|
@ -311,6 +313,7 @@ class Product(CreatedUpdatedModel, UUIDModel):
|
|||
|
||||
ticket_type = models.ForeignKey(
|
||||
'tickets.TicketType',
|
||||
on_delete=models.PROTECT,
|
||||
null=True,
|
||||
blank=True
|
||||
)
|
||||
|
@ -345,8 +348,8 @@ class Product(CreatedUpdatedModel, UUIDModel):
|
|||
|
||||
|
||||
class OrderProductRelation(CreatedUpdatedModel):
|
||||
order = models.ForeignKey('shop.Order')
|
||||
product = models.ForeignKey('shop.Product')
|
||||
order = models.ForeignKey('shop.Order', on_delete=models.PROTECT)
|
||||
product = models.ForeignKey('shop.Product', on_delete=models.PROTECT)
|
||||
quantity = models.PositiveIntegerField()
|
||||
handed_out = models.BooleanField(default=False)
|
||||
|
||||
|
@ -374,7 +377,7 @@ class EpayPayment(CreatedUpdatedModel, UUIDModel):
|
|||
verbose_name_plural = 'Epay Payments'
|
||||
|
||||
order = models.OneToOneField('shop.Order')
|
||||
callback = models.ForeignKey('shop.EpayCallback')
|
||||
callback = models.ForeignKey('shop.EpayCallback', on_delete=models.PROTECT)
|
||||
txnid = models.IntegerField()
|
||||
|
||||
|
||||
|
@ -402,6 +405,7 @@ class CreditNote(CreatedUpdatedModel):
|
|||
verbose_name=_('User'),
|
||||
help_text=_('The user this credit note belongs to, if any.'),
|
||||
related_name='creditnotes',
|
||||
on_delete=models.PROTECT,
|
||||
null=True,
|
||||
blank=True
|
||||
)
|
||||
|
|
|
@ -19,7 +19,7 @@ class Sponsor(CampRelatedModel):
|
|||
help_text='Name of the sponsor'
|
||||
)
|
||||
|
||||
tier = models.ForeignKey('sponsors.SponsorTier')
|
||||
tier = models.ForeignKey('sponsors.SponsorTier', on_delete=models.PROTECT)
|
||||
|
||||
description = models.TextField(
|
||||
help_text='A short description of the sponsorship'
|
||||
|
@ -57,6 +57,7 @@ class SponsorTier(CampRelatedModel):
|
|||
camp = models.ForeignKey(
|
||||
'camps.Camp',
|
||||
null=True,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='sponsor_tiers',
|
||||
help_text='The camp this sponsor tier belongs to',
|
||||
)
|
||||
|
|
|
@ -106,8 +106,8 @@ class Team(CampRelatedModel):
|
|||
|
||||
|
||||
class TeamMember(CampRelatedModel):
|
||||
user = models.ForeignKey('auth.User')
|
||||
team = models.ForeignKey('teams.Team')
|
||||
user = models.ForeignKey('auth.User', on_delete=models.PROTECT)
|
||||
team = models.ForeignKey('teams.Team', on_delete=models.PROTECT)
|
||||
approved = models.BooleanField(default=False)
|
||||
responsible = models.BooleanField(default=False)
|
||||
|
||||
|
@ -132,6 +132,7 @@ class TeamTask(CampRelatedModel):
|
|||
team = models.ForeignKey(
|
||||
'teams.Team',
|
||||
related_name='tasks',
|
||||
on_delete=models.PROTECT,
|
||||
help_text='The team this task belongs to',
|
||||
)
|
||||
name = models.CharField(
|
||||
|
|
|
@ -18,14 +18,14 @@ logger = logging.getLogger("bornhack.%s" % __name__)
|
|||
# TicketType can be full week, one day. etc.
|
||||
class TicketType(CampRelatedModel, UUIDModel):
|
||||
name = models.TextField()
|
||||
camp = models.ForeignKey('camps.Camp')
|
||||
camp = models.ForeignKey('camps.Camp', on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return '{} ({})'.format(self.name, self.camp.title)
|
||||
|
||||
|
||||
class BaseTicket(CampRelatedModel, UUIDModel):
|
||||
ticket_type = models.ForeignKey('TicketType')
|
||||
ticket_type = models.ForeignKey('TicketType', on_delete=models.PROTECT)
|
||||
checked_in = models.BooleanField(default=False)
|
||||
badge_handed_out = models.BooleanField(default=False)
|
||||
|
||||
|
@ -69,7 +69,7 @@ class BaseTicket(CampRelatedModel, UUIDModel):
|
|||
|
||||
|
||||
class SponsorTicket(BaseTicket):
|
||||
sponsor = models.ForeignKey('sponsors.Sponsor')
|
||||
sponsor = models.ForeignKey('sponsors.Sponsor', on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return 'SponsorTicket: {}'.format(self.pk)
|
||||
|
@ -93,8 +93,12 @@ class DiscountTicket(BaseTicket):
|
|||
|
||||
|
||||
class ShopTicket(BaseTicket):
|
||||
order = models.ForeignKey('shop.Order', related_name='shoptickets')
|
||||
product = models.ForeignKey('shop.Product')
|
||||
order = models.ForeignKey(
|
||||
'shop.Order',
|
||||
related_name='shoptickets',
|
||||
on_delete=models.PROTECT
|
||||
)
|
||||
product = models.ForeignKey('shop.Product', on_delete=models.PROTECT)
|
||||
|
||||
name = models.CharField(
|
||||
max_length=100,
|
||||
|
|
|
@ -11,8 +11,8 @@ class Village(UUIDModel, CampRelatedModel):
|
|||
ordering = ['name']
|
||||
unique_together = ('slug', 'camp')
|
||||
|
||||
contact = models.ForeignKey('auth.User')
|
||||
camp = models.ForeignKey('camps.Camp')
|
||||
contact = models.ForeignKey('auth.User', on_delete=models.PROTECT)
|
||||
camp = models.ForeignKey('camps.Camp', on_delete=models.PROTECT)
|
||||
name = models.CharField(max_length=255)
|
||||
slug = models.SlugField(max_length=255, blank=True)
|
||||
description = models.TextField(
|
||||
|
|
Loading…
Reference in a new issue