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 (community) +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 Merge Bot (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 Merge Bot (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 Merge Bot (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
=== modified file 'turku_api/admin.py'
--- turku_api/admin.py 2017-06-13 12:12:05 +0000
+++ turku_api/admin.py 2020-03-24 21:51:29 +0000
@@ -59,10 +59,11 @@
5959
60 def render_change_form(self, request, context, *args, **kwargs):60 def render_change_form(self, request, context, *args, **kwargs):
61 related_links = []61 related_links = []
62 if 'object_id' in context:62 # Broken in Django 1.8+; see if related_links can be re-implemented
63 for obj in self.model._meta.get_all_related_objects():63 #if 'object_id' in context:
64 count = obj.model.objects.filter(**{obj.field.name: context['object_id']}).count()64 # for obj in self.model._meta.get_all_related_objects():
65 related_links.append((obj, count))65 # count = obj.model.objects.filter(**{obj.field.name: context['object_id']}).count()
66 # related_links.append((obj, count))
66 context.update({'related_links': related_links})67 context.update({'related_links': related_links})
6768
68 return super(CustomModelAdmin, self).render_change_form(request, context, *args, **kwargs)69 return super(CustomModelAdmin, self).render_change_form(request, context, *args, **kwargs)
@@ -71,6 +72,7 @@
71class MachineAdminForm(forms.ModelForm):72class MachineAdminForm(forms.ModelForm):
72 class Meta:73 class Meta:
73 model = Machine74 model = Machine
75 fields = '__all__'
7476
75 def __init__(self, *args, **kwargs):77 def __init__(self, *args, **kwargs):
76 super(MachineAdminForm, self).__init__(*args, **kwargs)78 super(MachineAdminForm, self).__init__(*args, **kwargs)
@@ -80,6 +82,7 @@
80class StorageAdminForm(forms.ModelForm):82class StorageAdminForm(forms.ModelForm):
81 class Meta:83 class Meta:
82 model = Storage84 model = Storage
85 fields = '__all__'
8386
84 def __init__(self, *args, **kwargs):87 def __init__(self, *args, **kwargs):
85 super(StorageAdminForm, self).__init__(*args, **kwargs)88 super(StorageAdminForm, self).__init__(*args, **kwargs)
8689
=== removed directory 'turku_api/migrations'
=== removed file 'turku_api/migrations/0001_initial.py'
=== removed file 'turku_api/migrations/0002_add_field_source_published.py'
=== removed file 'turku_api/migrations/0003_noop.py'
=== removed file 'turku_api/migrations/0004_add_field_auth_name.py'
=== removed file 'turku_api/migrations/0005_add_hashed_secrets_fields.py'
=== removed file 'turku_api/migrations/0006_hash_secrets.py'
=== removed file 'turku_api/migrations/0007_remove_unhashed_secrets_fields.py'
=== removed file 'turku_api/migrations/0008_fix_auth_unique_together.py'
=== removed file 'turku_api/migrations/0009_use_uuid_primary_key_field.py'
=== removed file 'turku_api/migrations/0010_auto__add_backuplog.py'
=== removed file 'turku_api/migrations/0011_auto__add_field_source_success.py'
=== removed file 'turku_api/migrations/0012_auto__add_filterset__add_field_source_filter.py'
=== removed file 'turku_api/migrations/0013_auto__add_field_backuplog_snapshot.py'
=== removed file 'turku_api/migrations/0014_auto__add_field_storage_space_total__add_field_storage_space_available.py'
=== removed file 'turku_api/migrations/0015_auto__add_field_source_snapshot_mode.py'
=== removed file 'turku_api/migrations/0016_auto__chg_field_source_username__chg_field_source_password.py'
=== removed file 'turku_api/migrations/0017_auto__add_field_source_bwlimit.py'
=== removed file 'turku_api/migrations/0018_auto__del_field_source_username__del_field_source_password.py'
=== removed file 'turku_api/migrations/0019_auto__add_field_auth_secret_hash__add_unique_auth_name__del_unique_aut.py'
=== removed file 'turku_api/migrations/0020_hash_auth_secrets.py'
=== removed file 'turku_api/migrations/0021_auto__del_field_auth_secret__chg_field_auth_secret_hash.py'
=== removed file 'turku_api/migrations/0022_auto__add_field_machine_published.py'
=== removed file 'turku_api/migrations/0023_auto__add_field_storage_published.py'
=== removed file 'turku_api/migrations/0024_auto__add_field_source_preserve_hard_links.py'
=== removed file 'turku_api/migrations/__init__.py'
=== modified file 'turku_api/models.py'
--- turku_api/models.py 2019-10-29 10:07:18 +0000
+++ turku_api/models.py 2020-03-24 21:51:29 +0000
@@ -20,7 +20,6 @@
20from django.contrib.auth.hashers import is_password_usable20from django.contrib.auth.hashers import is_password_usable
21from django.utils import timezone21from django.utils import timezone
22from datetime import timedelta22from datetime import timedelta
23from south.modelsinspector import add_introspection_rules
24import json23import json
25import uuid24import uuid
2625
@@ -462,6 +461,3 @@
462461
463 def __unicode__(self):462 def __unicode__(self):
464 return self.name463 return self.name
465
466
467add_introspection_rules([], ["^turku_api\.models\.UuidPrimaryKeyField"])
468464
=== modified file 'turku_api/settings.py'
--- turku_api/settings.py 2015-07-30 22:41:42 +0000
+++ turku_api/settings.py 2020-03-24 21:51:29 +0000
@@ -29,7 +29,6 @@
29 'django.contrib.sessions',29 'django.contrib.sessions',
30 'django.contrib.messages',30 'django.contrib.messages',
31 'django.contrib.staticfiles',31 'django.contrib.staticfiles',
32 'south',
33 'turku_api',32 'turku_api',
34)33)
35MIDDLEWARE_CLASSES = (34MIDDLEWARE_CLASSES = (
@@ -48,9 +47,21 @@
48USE_L10N = True47USE_L10N = True
49USE_TZ = True48USE_TZ = True
50STATIC_URL = '/static/'49STATIC_URL = '/static/'
51TEMPLATE_DIRS = (50TEMPLATES = [
52 os.path.join(BASE_DIR, 'turku_api/templates'),51 {
53)52 'BACKEND': 'django.template.backends.django.DjangoTemplates',
53 'DIRS': [os.path.join(BASE_DIR, 'turku_api/templates')],
54 'APP_DIRS': True,
55 'OPTIONS': {
56 'context_processors': [
57 'django.template.context_processors.debug',
58 'django.template.context_processors.request',
59 'django.contrib.auth.context_processors.auth',
60 'django.contrib.messages.context_processors.messages',
61 ],
62 },
63 },
64]
54DATABASES = {65DATABASES = {
55 'default': {66 'default': {
56 'ENGINE': 'django.db.backends.sqlite3',67 'ENGINE': 'django.db.backends.sqlite3',
5768
=== modified file 'turku_api/urls.py'
--- turku_api/urls.py 2015-07-30 22:41:42 +0000
+++ turku_api/urls.py 2020-03-24 21:51:29 +0000
@@ -14,7 +14,7 @@
14# License along with this program. If not, see14# License along with this program. If not, see
15# <http://www.gnu.org/licenses/>.15# <http://www.gnu.org/licenses/>.
1616
17from django.conf.urls import patterns, include, url17from django.conf.urls import include, url
18from django.core.urlresolvers import reverse_lazy18from django.core.urlresolvers import reverse_lazy
19from django.views.generic.base import RedirectView19from django.views.generic.base import RedirectView
20from turku_api import views20from turku_api import views
@@ -23,8 +23,7 @@
2323
24admin.autodiscover()24admin.autodiscover()
2525
26urlpatterns = patterns(26urlpatterns = [
27 '',
28 url(r'^$', RedirectView.as_view(url=reverse_lazy('admin:index'))),27 url(r'^$', RedirectView.as_view(url=reverse_lazy('admin:index'))),
29 url(r'^v1/health$', views.health, name='health'),28 url(r'^v1/health$', views.health, name='health'),
30 url(r'^v1/update_config$', views.update_config, name='update_config'),29 url(r'^v1/update_config$', views.update_config, name='update_config'),
@@ -34,7 +33,7 @@
34 url(r'^v1/storage_ping_source_update$', views.storage_ping_source_update, name='storage_ping_source_update'),33 url(r'^v1/storage_ping_source_update$', views.storage_ping_source_update, name='storage_ping_source_update'),
35 url(r'^v1/storage_update_config$', views.storage_update_config, name='storage_update_config'),34 url(r'^v1/storage_update_config$', views.storage_update_config, name='storage_update_config'),
36 url(r'^admin/', include(admin.site.urls)),35 url(r'^admin/', include(admin.site.urls)),
37)36]
3837
39try:38try:
40 from local_urls import *39 from local_urls import *

Subscribers

People subscribed via source and target branches

to all changes: