Merge lp:~roadmr/canonical-identity-provider/fix-deprecation-warnings-1 into lp:canonical-identity-provider/release

Proposed by Daniel Manrique
Status: Merged
Approved by: Daniel Manrique
Approved revision: no longer in the source branch.
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~roadmr/canonical-identity-provider/fix-deprecation-warnings-1
Merge into: lp:canonical-identity-provider/release
Diff against target: 325 lines (+43/-32)
12 files modified
Makefile (+1/-1)
src/identityprovider/migrations/0001_initial.py (+11/-11)
src/identityprovider/migrations/0005_authlog.py (+1/-1)
src/identityprovider/models/account.py (+3/-2)
src/identityprovider/models/authlog.py (+1/-1)
src/identityprovider/models/authtoken.py (+2/-1)
src/identityprovider/models/emailaddress.py (+4/-2)
src/identityprovider/models/openidmodels.py (+4/-2)
src/identityprovider/models/person.py (+7/-4)
src/identityprovider/models/twofactor.py (+2/-1)
src/oauth_backend/migrations/0001_initial.py (+4/-4)
src/oauth_backend/models.py (+3/-2)
To merge this branch: bzr merge lp:~roadmr/canonical-identity-provider/fix-deprecation-warnings-1
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini Approve
Review via email: mp+346897@code.launchpad.net

Commit message

Fix deprecation warnings concerning on_delete on model field definitions and migrations.

This fixes only such warnings in this project's code; some remain on django-piston and django-openid-auth, which will be tackled separately.

Description of the change

Fix deprecation warnings concerning on_delete on model field definitions and migrations.

This fixes only such warnings in this project's code; some remain on django-piston and django-openid-auth, which will be tackled separately.

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

+1, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2018-04-16 21:22:24 +0000
3+++ Makefile 2018-05-25 18:10:37 +0000
4@@ -11,7 +11,7 @@
5 LOCAL_SETTINGS_DIR ?= $(CURDIR)/../local_config
6 LOCAL_SETTINGS_PATH = $(LOCAL_SETTINGS_DIR)/settings.py
7 FLAKE8 = $(ENV)/bin/flake8
8-PYTHON = $(ENV)/bin/python -Wd
9+PYTHON = $(ENV)/bin/python -Wd -Wignore:"Not importing":ImportWarning
10 PIP = $(PYTHON) $(ENV)/bin/pip
11 SRC_DIR = $(CURDIR)/src
12 LIB_DIR = $(CURDIR)/lib
13
14=== modified file 'src/identityprovider/migrations/0001_initial.py'
15--- src/identityprovider/migrations/0001_initial.py 2015-06-26 16:21:26 +0000
16+++ src/identityprovider/migrations/0001_initial.py 2018-05-25 18:10:37 +0000
17@@ -69,7 +69,7 @@
18 fields=[
19 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
20 ('password', identityprovider.models.account.PasswordField()),
21- ('account', models.OneToOneField(db_column=b'account', to='identityprovider.Account')),
22+ ('account', models.OneToOneField(db_column=b'account', on_delete=models.CASCADE, to='identityprovider.Account')),
23 ],
24 options={
25 'db_table': 'accountpassword',
26@@ -102,7 +102,7 @@
27 ('name', models.TextField()),
28 ('counter', models.IntegerField(default=0)),
29 ('device_type', models.TextField(null=True)),
30- ('account', models.ForeignKey(related_name='devices', to='identityprovider.Account')),
31+ ('account', models.ForeignKey(related_name='devices', on_delete=models.CASCADE, to='identityprovider.Account')),
32 ],
33 options={
34 'ordering': ('id',),
35@@ -122,7 +122,7 @@
36 ('redirection_url', models.TextField(null=True, blank=True)),
37 ('displayname', identityprovider.models.account.DisplaynameField(null=True, blank=True)),
38 ('password', identityprovider.models.account.PasswordField(null=True, blank=True)),
39- ('requester', models.ForeignKey(db_column=b'requester', blank=True, to='identityprovider.Account', null=True)),
40+ ('requester', models.ForeignKey(db_column=b'requester', blank=True, on_delete=models.CASCADE, to='identityprovider.Account', null=True)),
41 ],
42 options={
43 'db_table': 'authtoken',
44@@ -137,7 +137,7 @@
45 ('lp_person', models.IntegerField(null=True, editable=False, db_column=b'person', blank=True)),
46 ('status', models.IntegerField(choices=[(1, b'NEW'), (2, b'VALIDATED'), (4, b'PREFERRED')])),
47 ('date_created', models.DateTimeField(default=django.utils.timezone.now, editable=False, blank=True)),
48- ('account', models.ForeignKey(db_column=b'account', blank=True, to='identityprovider.Account', null=True)),
49+ ('account', models.ForeignKey(db_column=b'account', blank=True, on_delete=models.CASCADE, to='identityprovider.Account', null=True)),
50 ],
51 options={
52 'db_table': 'emailaddress',
53@@ -153,7 +153,7 @@
54 ('date_created', models.DateTimeField(editable=False, blank=True)),
55 ('date_invalidated', models.DateTimeField(default=django.utils.timezone.now, null=True, blank=True)),
56 ('account_notified', models.BooleanField(default=False)),
57- ('account', models.ForeignKey(db_column=b'account', blank=True, to='identityprovider.Account', null=True)),
58+ ('account', models.ForeignKey(db_column=b'account', blank=True, on_delete=models.CASCADE, to='identityprovider.Account', null=True)),
59 ],
60 options={
61 'db_table': 'invalidated_emailaddress',
62@@ -212,7 +212,7 @@
63 ('date_created', models.DateTimeField(default=django.utils.timezone.now, editable=False, blank=True)),
64 ('date_expires', models.DateTimeField()),
65 ('trust_root', models.TextField()),
66- ('account', models.ForeignKey(to='identityprovider.Account', db_column=b'account')),
67+ ('account', models.ForeignKey(on_delete=models.CASCADE, to='identityprovider.Account', db_column=b'account')),
68 ],
69 options={
70 'db_table': 'openidauthorization',
71@@ -268,7 +268,7 @@
72 ('date_last_used', models.DateTimeField(default=django.utils.timezone.now, editable=False, blank=True)),
73 ('total_logins', models.IntegerField(default=1)),
74 ('approved_data', models.TextField(default='', null=True, blank=True)),
75- ('account', models.ForeignKey(to='identityprovider.Account', db_column=b'account')),
76+ ('account', models.ForeignKey(on_delete=models.CASCADE, to='identityprovider.Account', db_column=b'account')),
77 ],
78 options={
79 'db_table': 'openidrpsummary',
80@@ -333,7 +333,7 @@
81 ('date_last_modified', models.DateTimeField(null=True)),
82 ('visible', models.NullBooleanField(default=True)),
83 ('locked', models.NullBooleanField(default=False)),
84- ('person', models.OneToOneField(null=True, db_column=b'person', to='identityprovider.Person')),
85+ ('person', models.OneToOneField(null=True, db_column=b'person', on_delete=models.CASCADE, to='identityprovider.Person')),
86 ],
87 options={
88 'db_table': 'lp_personlocation',
89@@ -344,8 +344,8 @@
90 name='TeamParticipation',
91 fields=[
92 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
93- ('person', models.ForeignKey(db_column=b'person', to='identityprovider.Person', null=True)),
94- ('team', models.ForeignKey(related_name='team_participations', db_column=b'team', to='identityprovider.Person', null=True)),
95+ ('person', models.ForeignKey(db_column=b'person', on_delete=models.CASCADE, to='identityprovider.Person', null=True)),
96+ ('team', models.ForeignKey(related_name='team_participations', db_column=b'team', on_delete=models.CASCADE, to='identityprovider.Person', null=True)),
97 ],
98 options={
99 'db_table': 'lp_teamparticipation',
100@@ -361,7 +361,7 @@
101 ('secret', models.TextField(default=identityprovider.utils.generate_random_string_len_70)),
102 ('date_created', models.DateTimeField(default=django.utils.timezone.now)),
103 ('date_updated', models.DateTimeField(default=django.utils.timezone.now)),
104- ('consumer', models.ForeignKey(to='identityprovider.Account')),
105+ ('consumer', models.ForeignKey(on_delete=models.CASCADE, to='identityprovider.Account')),
106 ],
107 options={
108 },
109
110=== modified file 'src/identityprovider/migrations/0005_authlog.py'
111--- src/identityprovider/migrations/0005_authlog.py 2015-12-10 20:27:28 +0000
112+++ src/identityprovider/migrations/0005_authlog.py 2018-05-25 18:10:37 +0000
113@@ -38,7 +38,7 @@
114 ('referer', models.TextField()),
115 ('remote_ip', models.GenericIPAddressField()),
116 ('user_agent', models.TextField()),
117- ('account', models.ForeignKey(to='identityprovider.Account', null=True)),
118+ ('account', models.ForeignKey(on_delete=models.CASCADE, to='identityprovider.Account', null=True)),
119 ],
120 options={
121 },
122
123=== modified file 'src/identityprovider/models/account.py'
124--- src/identityprovider/models/account.py 2018-02-15 11:27:21 +0000
125+++ src/identityprovider/models/account.py 2018-05-25 18:10:37 +0000
126@@ -700,7 +700,8 @@
127
128
129 class AccountPassword(models.Model):
130- account = models.OneToOneField(Account, db_column=b'account')
131+ account = models.OneToOneField(
132+ Account, db_column=b'account', on_delete=models.CASCADE)
133 password = PasswordField()
134 last_leak_check = models.DateTimeField(null=True)
135 date_changed = models.DateTimeField(null=True, editable=False)
136@@ -737,7 +738,7 @@
137
138 class Token(models.Model):
139
140- consumer = models.ForeignKey(Account)
141+ consumer = models.ForeignKey(Account, on_delete=models.CASCADE)
142 name = models.TextField()
143 scope = models.TextField(
144 choices=TokenScope._get_choices(), default=TokenScope.VERSION_2)
145
146=== modified file 'src/identityprovider/models/authlog.py'
147--- src/identityprovider/models/authlog.py 2015-09-15 22:30:26 +0000
148+++ src/identityprovider/models/authlog.py 2018-05-25 18:10:37 +0000
149@@ -23,7 +23,7 @@
150 # EmailField, so we can 1) accept input longer than 255 chars, and 2)
151 # accept input that's not valid e-mail addresses (we want to log that).
152 login_email = models.TextField(default='', null=False)
153- account = models.ForeignKey(Account, null=True)
154+ account = models.ForeignKey(Account, null=True, on_delete=models.CASCADE)
155 referer = models.TextField()
156 remote_ip = models.GenericIPAddressField()
157 user_agent = models.TextField()
158
159=== modified file 'src/identityprovider/models/authtoken.py'
160--- src/identityprovider/models/authtoken.py 2017-06-08 20:45:08 +0000
161+++ src/identityprovider/models/authtoken.py 2018-05-25 18:10:37 +0000
162@@ -102,7 +102,8 @@
163 token_type = models.IntegerField(choices=AuthTokenType._get_choices())
164 hashed_token = models.TextField(unique=True, db_column=b'token')
165 requester = models.ForeignKey(
166- Account, db_column=b'requester', null=True, blank=True)
167+ Account, db_column=b'requester', null=True,
168+ on_delete=models.CASCADE, blank=True)
169 requester_email = models.TextField(null=True, blank=True)
170 email = models.TextField(db_index=True, validators=[validate_email])
171 redirection_url = models.TextField(null=True, blank=True)
172
173=== modified file 'src/identityprovider/models/emailaddress.py'
174--- src/identityprovider/models/emailaddress.py 2018-05-09 22:00:09 +0000
175+++ src/identityprovider/models/emailaddress.py 2018-05-25 18:10:37 +0000
176@@ -41,7 +41,8 @@
177 date_created = models.DateTimeField(
178 default=now, blank=True, editable=False)
179 account = models.ForeignKey(
180- Account, db_column=b'account', blank=True, null=True)
181+ Account, db_column=b'account', blank=True,
182+ null=True, on_delete=models.CASCADE)
183
184 objects = EmailAddressManager.from_queryset(EmailAddressQuerySet)()
185
186@@ -96,7 +97,8 @@
187 default=now, blank=True, editable=False)
188 date_invalidated = models.DateTimeField(default=now, null=True, blank=True)
189 account = models.ForeignKey(
190- Account, db_column=b'account', blank=True, null=True)
191+ Account, db_column=b'account', blank=True,
192+ null=True, on_delete=models.CASCADE)
193 account_notified = models.BooleanField(default=False)
194
195 class Meta:
196
197=== modified file 'src/identityprovider/models/openidmodels.py'
198--- src/identityprovider/models/openidmodels.py 2018-02-09 20:56:16 +0000
199+++ src/identityprovider/models/openidmodels.py 2018-05-25 18:10:37 +0000
200@@ -87,7 +87,8 @@
201
202
203 class OpenIDAuthorization(models.Model):
204- account = models.ForeignKey(Account, db_column=b'account')
205+ account = models.ForeignKey(
206+ Account, db_column=b'account', on_delete=models.CASCADE)
207 client_id = models.TextField(blank=True, null=True)
208 date_created = models.DateTimeField(
209 default=now, blank=True, editable=False)
210@@ -228,7 +229,8 @@
211
212
213 class OpenIDRPSummary(models.Model):
214- account = models.ForeignKey(Account, db_column=b'account')
215+ account = models.ForeignKey(
216+ Account, db_column=b'account', on_delete=models.CASCADE)
217 openid_identifier = models.TextField(db_index=True)
218 trust_root = models.TextField(db_index=True)
219 date_created = models.DateTimeField(
220
221=== modified file 'src/identityprovider/models/person.py'
222--- src/identityprovider/models/person.py 2018-02-09 15:07:55 +0000
223+++ src/identityprovider/models/person.py 2018-05-25 18:10:37 +0000
224@@ -161,7 +161,8 @@
225
226 class PersonLocation(models.Model):
227 date_created = models.DateTimeField(null=True)
228- person = models.OneToOneField(Person, db_column=b'person', null=True)
229+ person = models.OneToOneField(
230+ Person, db_column=b'person', null=True, on_delete=models.CASCADE)
231 latitude = models.FloatField(null=True, blank=True)
232 longitude = models.FloatField(null=True, blank=True)
233 time_zone = models.TextField(null=True, blank=True)
234@@ -177,9 +178,11 @@
235
236
237 class TeamParticipation(models.Model):
238- team = models.ForeignKey(Person, db_column=b'team', null=True,
239- related_name='team_participations')
240- person = models.ForeignKey(Person, db_column=b'person', null=True)
241+ team = models.ForeignKey(
242+ Person, db_column=b'team', null=True,
243+ on_delete=models.CASCADE, related_name='team_participations')
244+ person = models.ForeignKey(
245+ Person, db_column=b'person', null=True, on_delete=models.CASCADE)
246
247 class Meta:
248 app_label = 'identityprovider'
249
250=== modified file 'src/identityprovider/models/twofactor.py'
251--- src/identityprovider/models/twofactor.py 2018-02-09 20:56:16 +0000
252+++ src/identityprovider/models/twofactor.py 2018-05-25 18:10:37 +0000
253@@ -128,7 +128,8 @@
254
255
256 class AuthenticationDevice(models.Model):
257- account = models.ForeignKey(Account, related_name='devices')
258+ account = models.ForeignKey(
259+ Account, on_delete=models.CASCADE, related_name='devices')
260 key = models.TextField()
261 name = models.TextField()
262 counter = models.IntegerField(default=0)
263
264=== modified file 'src/oauth_backend/migrations/0001_initial.py'
265--- src/oauth_backend/migrations/0001_initial.py 2015-09-22 14:47:30 +0000
266+++ src/oauth_backend/migrations/0001_initial.py 2018-05-25 18:10:37 +0000
267@@ -21,7 +21,7 @@
268 ('secret', models.CharField(default=oauth_backend.models.generate_random_string_secret, max_length=255, blank=True)),
269 ('created_at', models.DateTimeField(auto_now_add=True)),
270 ('updated_at', models.DateTimeField(auto_now=True)),
271- ('user', models.OneToOneField(related_name='oauth_consumer', to=settings.AUTH_USER_MODEL)),
272+ ('user', models.OneToOneField(related_name='oauth_consumer', on_delete=models.CASCADE, to=settings.AUTH_USER_MODEL)),
273 ],
274 options={
275 'db_table': 'oauth_consumer',
276@@ -34,7 +34,7 @@
277 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
278 ('nonce', models.CharField(max_length=255, editable=False)),
279 ('created_at', models.DateTimeField(auto_now_add=True)),
280- ('consumer', models.ForeignKey(to='oauth_backend.Consumer')),
281+ ('consumer', models.ForeignKey(on_delete=models.CASCADE, to='oauth_backend.Consumer')),
282 ],
283 options={
284 'db_table': 'oauth_nonce',
285@@ -49,7 +49,7 @@
286 ('name', models.CharField(max_length=255, blank=True)),
287 ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
288 ('updated_at', models.DateTimeField(default=django.utils.timezone.now)),
289- ('consumer', models.ForeignKey(to='oauth_backend.Consumer')),
290+ ('consumer', models.ForeignKey(on_delete=models.CASCADE, to='oauth_backend.Consumer')),
291 ],
292 options={
293 'db_table': 'oauth_token',
294@@ -59,7 +59,7 @@
295 migrations.AddField(
296 model_name='nonce',
297 name='token',
298- field=models.ForeignKey(to='oauth_backend.Token'),
299+ field=models.ForeignKey(on_delete=models.CASCADE, to='oauth_backend.Token'),
300 preserve_default=True,
301 ),
302 migrations.AlterUniqueTogether(
303
304=== modified file 'src/oauth_backend/models.py'
305--- src/oauth_backend/models.py 2015-09-22 16:11:08 +0000
306+++ src/oauth_backend/models.py 2018-05-25 18:10:37 +0000
307@@ -44,7 +44,8 @@
308 class Consumer(models.Model):
309 """An OAuth consumer (client)."""
310
311- user = models.OneToOneField(User, related_name='oauth_consumer')
312+ user = models.OneToOneField(
313+ User, on_delete=models.CASCADE, related_name='oauth_consumer')
314
315 secret = models.CharField(
316 max_length=255, blank=True, default=generate_random_string_secret,
317@@ -67,7 +68,7 @@
318 class Token(models.Model):
319 """An OAuth access token."""
320
321- consumer = models.ForeignKey(Consumer)
322+ consumer = models.ForeignKey(Consumer, on_delete=models.CASCADE)
323
324 token = models.CharField(
325 max_length=TOKEN_LENGTH, default=generate_random_string_token,