Skip to content

Commit 718947c

Browse files
authored
Merge pull request #25 from BirkbeckCTP/django_three_two
Updated for django 3.2
2 parents 18b1afb + f5022e0 commit 718947c

File tree

3 files changed

+91
-13
lines changed

3 files changed

+91
-13
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Generated by Django 3.2.16 on 2022-12-16 13:29
2+
3+
from django.conf import settings
4+
import django.core.files.storage
5+
from django.db import migrations, models
6+
import django.db.models.deletion
7+
import plugins.consortial_billing.models
8+
9+
10+
class Migration(migrations.Migration):
11+
12+
dependencies = [
13+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
14+
('consortial_billing', '0038_auto_20190823_1144'),
15+
]
16+
17+
operations = [
18+
migrations.AlterField(
19+
model_name='banding',
20+
name='billing_agent',
21+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='consortial_billing.billingagent'),
22+
),
23+
migrations.AlterField(
24+
model_name='institution',
25+
name='supporter_level',
26+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='consortial_billing.supportlevel'),
27+
),
28+
migrations.AlterField(
29+
model_name='poll',
30+
name='file',
31+
field=models.FileField(blank=True, null=True, storage=django.core.files.storage.FileSystemStorage(location='/home/ajrbyers/Code/janeway/src/media'), upload_to=plugins.consortial_billing.models.file_upload_path),
32+
),
33+
migrations.AlterField(
34+
model_name='poll',
35+
name='staffer',
36+
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
37+
),
38+
]

models.py

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

136149
class ExcludedUser(models.Model):
137-
user = models.ForeignKey('core.Account')
150+
user = models.ForeignKey(
151+
'core.Account',
152+
on_delete=models.CASCADE,
153+
)
138154

139155

140156
class Signup(models.Model):
@@ -154,7 +170,11 @@ class Signup(models.Model):
154170

155171

156172
class 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

191211
class 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

201227
class 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

208240
class 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)

plugin_settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
PLUGIN_NAME = 'Consortial Billing'
44
DESCRIPTION = 'This is a plugin to handle consortial billing.'
55
AUTHOR = 'Martin Paul Eve'
6-
VERSION = '1.1'
6+
VERSION = '1.2'
77
SHORT_NAME = 'consortial_billing'
88
DISPLAY_NAME = 'supporters'
99
MANAGER_URL = 'consortial_index'
10-
JANEWAY_VERSION = "1.3.6"
10+
JANEWAY_VERSION = "1.5.0"
1111

1212

1313
def get_self():

0 commit comments

Comments
 (0)