Merge lp:~fo0bar/turku/bionic into lp:turku/turku-api

Proposed by Ryan Finnie
Status: Merged
Approved by: Haw Loeung
Approved revision: 60
Merged at revision: 60
Proposed branch: lp:~fo0bar/turku/bionic
Merge into: lp:turku/turku-api
Diff against target: 149 lines (+25/-16)
4 files modified
turku_api/admin.py (+7/-4)
turku_api/models.py (+0/-4)
turku_api/settings.py (+15/-4)
turku_api/urls.py (+3/-4)
To merge this branch: bzr merge lp:~fo0bar/turku/bionic
Reviewer Review Type Date Requested Status
Joel Sing +1 Approve
Review via email: mp+344994@code.launchpad.net

Commit message

Add compatibility for Django 1.8~1.11 (xenial/bionic):
- Disable admin form "related links" (form children links) -- broken as of
  1.8, would be nice to have back if someone can figure out a replacement
- Add "fields = '__all__'" to admin forms
- Remove south migrations
- Port TEMPLATE_DIRS to TEMPLATES
- Change urlpatterns from patterns() to url() list

Changes have been tested as being backwards compatible to 1.6 (trusty).

To post a comment you must log in.
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Ryan Finnie (fo0bar) wrote :

(Yes, the MP date is correct, this is from 2018 and apparently slipped through the cracks.)

Revision history for this message
Joel Sing (jsing) wrote :

LGTM

review: Approve (+1)
Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

Failed to merge change (unable to merge source branch due to conflicts), setting status to needs review.

lp:~fo0bar/turku/bionic updated
60. By Ryan Finnie

Add compatibility for Django 1.8~1.11 (xenial/bionic)

- Disable admin form "related links" (form children links) -- broken as of
  1.8, would be nice to have back if someone can figure out a replacement
- Add "fields = '__all__'" to admin forms
- Remove south migrations
- Port TEMPLATE_DIRS to TEMPLATES
- Change urlpatterns from patterns() to url() list

Changes have been tested as being backwards compatible to 1.6 (trusty).

Revision history for this message
Canonical IS Mergebot (canonical-is-mergebot) wrote :

Change successfully merged at revision 60

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'turku_api/admin.py'
2--- turku_api/admin.py 2017-06-13 12:12:05 +0000
3+++ turku_api/admin.py 2020-03-24 21:51:29 +0000
4@@ -59,10 +59,11 @@
5
6 def render_change_form(self, request, context, *args, **kwargs):
7 related_links = []
8- if 'object_id' in context:
9- for obj in self.model._meta.get_all_related_objects():
10- count = obj.model.objects.filter(**{obj.field.name: context['object_id']}).count()
11- related_links.append((obj, count))
12+ # Broken in Django 1.8+; see if related_links can be re-implemented
13+ #if 'object_id' in context:
14+ # for obj in self.model._meta.get_all_related_objects():
15+ # count = obj.model.objects.filter(**{obj.field.name: context['object_id']}).count()
16+ # related_links.append((obj, count))
17 context.update({'related_links': related_links})
18
19 return super(CustomModelAdmin, self).render_change_form(request, context, *args, **kwargs)
20@@ -71,6 +72,7 @@
21 class MachineAdminForm(forms.ModelForm):
22 class Meta:
23 model = Machine
24+ fields = '__all__'
25
26 def __init__(self, *args, **kwargs):
27 super(MachineAdminForm, self).__init__(*args, **kwargs)
28@@ -80,6 +82,7 @@
29 class StorageAdminForm(forms.ModelForm):
30 class Meta:
31 model = Storage
32+ fields = '__all__'
33
34 def __init__(self, *args, **kwargs):
35 super(StorageAdminForm, self).__init__(*args, **kwargs)
36
37=== removed directory 'turku_api/migrations'
38=== removed file 'turku_api/migrations/0001_initial.py'
39=== removed file 'turku_api/migrations/0002_add_field_source_published.py'
40=== removed file 'turku_api/migrations/0003_noop.py'
41=== removed file 'turku_api/migrations/0004_add_field_auth_name.py'
42=== removed file 'turku_api/migrations/0005_add_hashed_secrets_fields.py'
43=== removed file 'turku_api/migrations/0006_hash_secrets.py'
44=== removed file 'turku_api/migrations/0007_remove_unhashed_secrets_fields.py'
45=== removed file 'turku_api/migrations/0008_fix_auth_unique_together.py'
46=== removed file 'turku_api/migrations/0009_use_uuid_primary_key_field.py'
47=== removed file 'turku_api/migrations/0010_auto__add_backuplog.py'
48=== removed file 'turku_api/migrations/0011_auto__add_field_source_success.py'
49=== removed file 'turku_api/migrations/0012_auto__add_filterset__add_field_source_filter.py'
50=== removed file 'turku_api/migrations/0013_auto__add_field_backuplog_snapshot.py'
51=== removed file 'turku_api/migrations/0014_auto__add_field_storage_space_total__add_field_storage_space_available.py'
52=== removed file 'turku_api/migrations/0015_auto__add_field_source_snapshot_mode.py'
53=== removed file 'turku_api/migrations/0016_auto__chg_field_source_username__chg_field_source_password.py'
54=== removed file 'turku_api/migrations/0017_auto__add_field_source_bwlimit.py'
55=== removed file 'turku_api/migrations/0018_auto__del_field_source_username__del_field_source_password.py'
56=== removed file 'turku_api/migrations/0019_auto__add_field_auth_secret_hash__add_unique_auth_name__del_unique_aut.py'
57=== removed file 'turku_api/migrations/0020_hash_auth_secrets.py'
58=== removed file 'turku_api/migrations/0021_auto__del_field_auth_secret__chg_field_auth_secret_hash.py'
59=== removed file 'turku_api/migrations/0022_auto__add_field_machine_published.py'
60=== removed file 'turku_api/migrations/0023_auto__add_field_storage_published.py'
61=== removed file 'turku_api/migrations/0024_auto__add_field_source_preserve_hard_links.py'
62=== removed file 'turku_api/migrations/__init__.py'
63=== modified file 'turku_api/models.py'
64--- turku_api/models.py 2019-10-29 10:07:18 +0000
65+++ turku_api/models.py 2020-03-24 21:51:29 +0000
66@@ -20,7 +20,6 @@
67 from django.contrib.auth.hashers import is_password_usable
68 from django.utils import timezone
69 from datetime import timedelta
70-from south.modelsinspector import add_introspection_rules
71 import json
72 import uuid
73
74@@ -462,6 +461,3 @@
75
76 def __unicode__(self):
77 return self.name
78-
79-
80-add_introspection_rules([], ["^turku_api\.models\.UuidPrimaryKeyField"])
81
82=== modified file 'turku_api/settings.py'
83--- turku_api/settings.py 2015-07-30 22:41:42 +0000
84+++ turku_api/settings.py 2020-03-24 21:51:29 +0000
85@@ -29,7 +29,6 @@
86 'django.contrib.sessions',
87 'django.contrib.messages',
88 'django.contrib.staticfiles',
89- 'south',
90 'turku_api',
91 )
92 MIDDLEWARE_CLASSES = (
93@@ -48,9 +47,21 @@
94 USE_L10N = True
95 USE_TZ = True
96 STATIC_URL = '/static/'
97-TEMPLATE_DIRS = (
98- os.path.join(BASE_DIR, 'turku_api/templates'),
99-)
100+TEMPLATES = [
101+ {
102+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
103+ 'DIRS': [os.path.join(BASE_DIR, 'turku_api/templates')],
104+ 'APP_DIRS': True,
105+ 'OPTIONS': {
106+ 'context_processors': [
107+ 'django.template.context_processors.debug',
108+ 'django.template.context_processors.request',
109+ 'django.contrib.auth.context_processors.auth',
110+ 'django.contrib.messages.context_processors.messages',
111+ ],
112+ },
113+ },
114+]
115 DATABASES = {
116 'default': {
117 'ENGINE': 'django.db.backends.sqlite3',
118
119=== modified file 'turku_api/urls.py'
120--- turku_api/urls.py 2015-07-30 22:41:42 +0000
121+++ turku_api/urls.py 2020-03-24 21:51:29 +0000
122@@ -14,7 +14,7 @@
123 # License along with this program. If not, see
124 # <http://www.gnu.org/licenses/>.
125
126-from django.conf.urls import patterns, include, url
127+from django.conf.urls import include, url
128 from django.core.urlresolvers import reverse_lazy
129 from django.views.generic.base import RedirectView
130 from turku_api import views
131@@ -23,8 +23,7 @@
132
133 admin.autodiscover()
134
135-urlpatterns = patterns(
136- '',
137+urlpatterns = [
138 url(r'^$', RedirectView.as_view(url=reverse_lazy('admin:index'))),
139 url(r'^v1/health$', views.health, name='health'),
140 url(r'^v1/update_config$', views.update_config, name='update_config'),
141@@ -34,7 +33,7 @@
142 url(r'^v1/storage_ping_source_update$', views.storage_ping_source_update, name='storage_ping_source_update'),
143 url(r'^v1/storage_update_config$', views.storage_update_config, name='storage_update_config'),
144 url(r'^admin/', include(admin.site.urls)),
145-)
146+]
147
148 try:
149 from local_urls import *

Subscribers

People subscribed via source and target branches

to all changes: