@@ -33,7 +33,12 @@ class Banding(models.Model):
3333 name = models .CharField (max_length = 200 , blank = False , unique = True )
3434 currency = models .CharField (max_length = 255 , blank = True , null = True )
3535 default_price = models .IntegerField (blank = True , null = True , default = 0 )
36- billing_agent = models .ForeignKey ('BillingAgent' , null = True , blank = True )
36+ billing_agent = models .ForeignKey (
37+ 'BillingAgent' ,
38+ null = True ,
39+ blank = True ,
40+ on_delete = models .SET_NULL ,
41+ )
3742 display = models .BooleanField (default = True )
3843 redirect_url = models .URLField (blank = True , null = True )
3944 size = models .CharField (max_length = 20 , choices = banding_choices (), default = 'small' )
@@ -91,7 +96,12 @@ class Institution(models.Model):
9196
9297 multiplier = models .DecimalField (decimal_places = 2 , max_digits = 3 , default = 1.0 )
9398
94- supporter_level = models .ForeignKey (SupportLevel , blank = True , null = True )
99+ supporter_level = models .ForeignKey (
100+ SupportLevel ,
101+ blank = True ,
102+ null = True ,
103+ on_delete = models .SET_NULL ,
104+ )
95105
96106 referral_code = models .UUIDField (default = uuid .uuid4 )
97107
@@ -119,7 +129,10 @@ class Renewal(models.Model):
119129 date = models .DateField (default = timezone .now )
120130 amount = models .DecimalField (decimal_places = 2 , max_digits = 20 , blank = False )
121131 currency = models .CharField (max_length = 255 , blank = False )
122- institution = models .ForeignKey (Institution )
132+ institution = models .ForeignKey (
133+ Institution ,
134+ on_delete = models .CASCADE ,
135+ )
123136 billing_complete = models .BooleanField (default = False )
124137 date_renewed = models .DateTimeField (blank = True , null = True )
125138
@@ -134,7 +147,10 @@ def __str__(self):
134147
135148
136149class ExcludedUser (models .Model ):
137- user = models .ForeignKey ('core.Account' )
150+ user = models .ForeignKey (
151+ 'core.Account' ,
152+ on_delete = models .CASCADE ,
153+ )
138154
139155
140156class Signup (models .Model ):
@@ -154,7 +170,11 @@ class Signup(models.Model):
154170
155171
156172class Poll (models .Model ):
157- staffer = models .ForeignKey ('core.Account' )
173+ staffer = models .ForeignKey (
174+ 'core.Account' ,
175+ null = True ,
176+ on_delete = models .SET_NULL ,
177+ )
158178 name = models .CharField (max_length = 255 )
159179 text = models .TextField (null = True )
160180 file = models .FileField (upload_to = file_upload_path , null = True , blank = True , storage = fs )
@@ -189,8 +209,14 @@ def __str__(self):
189209
190210
191211class IncreaseOptionBand (models .Model ):
192- banding = models .ForeignKey (Banding )
193- option = models .ForeignKey (Option )
212+ banding = models .ForeignKey (
213+ Banding ,
214+ on_delete = models .CASCADE ,
215+ )
216+ option = models .ForeignKey (
217+ Option ,
218+ on_delete = models .CASCADE ,
219+ )
194220 price_increase = models .DecimalField (max_digits = 10 , decimal_places = 2 , default = 0.00 )
195221
196222 def __str__ (self ):
@@ -199,15 +225,29 @@ def __str__(self):
199225
200226
201227class Vote (models .Model ):
202- institution = models .ForeignKey (Institution )
203- poll = models .ForeignKey (Poll )
228+ institution = models .ForeignKey (
229+ Institution ,
230+ on_delete = models .CASCADE ,
231+ )
232+ poll = models .ForeignKey (
233+ Poll ,
234+ on_delete = models .CASCADE ,
235+ )
204236 aye = models .ManyToManyField (Option , related_name = "vote_aye" )
205237 no = models .ManyToManyField (Option , related_name = "vote_no" )
206238
207239
208240class Referral (models .Model ):
209- referring_institution = models .ForeignKey (Institution , related_name = 'referring_institution' )
210- new_institution = models .ForeignKey (Institution , related_name = 'new_institution' )
241+ referring_institution = models .ForeignKey (
242+ Institution ,
243+ related_name = 'referring_institution' ,
244+ on_delete = models .CASCADE ,
245+ )
246+ new_institution = models .ForeignKey (
247+ Institution ,
248+ related_name = 'new_institution' ,
249+ on_delete = models .CASCADE ,
250+ )
211251 referring_discount = models .DecimalField (decimal_places = 2 , max_digits = 10 , blank = True , null = True )
212252 referent_discount = models .DecimalField (decimal_places = 2 , max_digits = 10 , blank = True , null = True )
213253 datetime = models .DateTimeField (default = timezone .now )
0 commit comments