From d4bd11306f1af84bf02ff852314f12e452dbbd8c Mon Sep 17 00:00:00 2001 From: Mateusz Kurek Date: Fri, 30 Dec 2016 14:45:46 +0100 Subject: [PATCH 1/6] Bump django-sitetree do 1.7.0 This version of sitetree supports Django 1.10 --- requirements/base.txt | 2 +- src/ralph/settings/dev.py | 4 ---- src/ralph/urls/base.py | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index 4fe5f68ad1..c115eb35c3 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -8,6 +8,7 @@ django-import-export==0.4.2 django-mptt==0.8.7 django-reversion==1.8.6 django-rq==0.9.0 +django-sitetree==1.7.0 django-taggit==0.17.1 django-taggit-serializer==0.1.5 django-threadlocals==0.8 @@ -26,5 +27,4 @@ six>=1.9.0 sqlparse==0.1.16 Unidecode==0.04.18 tablib==0.11.2 -git+https://github.com/idlesign/django-sitetree.git@a626559c39ff1e865cde3441c44f42864c648dfb factory-boy diff --git a/src/ralph/settings/dev.py b/src/ralph/settings/dev.py index 6858ab97b9..59f29824c3 100644 --- a/src/ralph/settings/dev.py +++ b/src/ralph/settings/dev.py @@ -22,10 +22,6 @@ def only_true(request): ROOT_URLCONF = 'ralph.urls.dev' -# Disable exception for the missing element in SiteTree -# https://github.com/idlesign/django-sitetree/pull/157/files -RAISE_ITEMS_ERRORS_ON_DEBUG = False - TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', diff --git a/src/ralph/urls/base.py b/src/ralph/urls/base.py index 240dc0726d..dc6ecc85a7 100644 --- a/src/ralph/urls/base.py +++ b/src/ralph/urls/base.py @@ -29,8 +29,10 @@ # api views are registered in router) api_urls += [url(r'^', include(router.urls))] +ralph_urls, ralph_app_name, ralph_namespace = admin.urls urlpatterns = [ - url(r'^', include(admin.urls)), + # override app_name (admin) with ralph (mainly for sitetree) + url(r'^', include((ralph_urls, 'ralph', ralph_namespace))), url(r'^api/', include(api_urls)), url(r'^api-token-auth/', views.obtain_auth_token), url(r'^', include('ralph.dc_view.urls.ui')), From f99917527a8b821b8bb447e60b75eadf21fc046b Mon Sep 17 00:00:00 2001 From: Mateusz Kurek Date: Fri, 30 Dec 2016 15:34:36 +0100 Subject: [PATCH 2/6] wip --- src/ralph/lib/custom_fields/tests/urls.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ralph/lib/custom_fields/tests/urls.py b/src/ralph/lib/custom_fields/tests/urls.py index 84686c735c..7d48480ef0 100644 --- a/src/ralph/lib/custom_fields/tests/urls.py +++ b/src/ralph/lib/custom_fields/tests/urls.py @@ -2,7 +2,9 @@ from . import admin, api +cf_tests_urls, cf_tests_app_name, cf_tests_namespace = admin.site.urls + urlpatterns = [ - url(r'^cf_tests_admin/', include(admin.site.urls)), + url(r'^cf_tests_admin/', include((cf_tests_urls, 'ralph', cf_tests_namespace))), url(r'^cf_test_api/', include(api.urlpatterns)) ] From 9d5037e8b6d2c85060b5243f59b68a15abc2c36d Mon Sep 17 00:00:00 2001 From: Mateusz Kurek Date: Fri, 30 Dec 2016 17:23:02 +0100 Subject: [PATCH 3/6] wip --- src/ralph/lib/custom_fields/tests/models.py | 4 ++-- src/ralph/lib/custom_fields/tests/urls.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ralph/lib/custom_fields/tests/models.py b/src/ralph/lib/custom_fields/tests/models.py index eb5f3eaf6f..689665d398 100644 --- a/src/ralph/lib/custom_fields/tests/models.py +++ b/src/ralph/lib/custom_fields/tests/models.py @@ -10,13 +10,13 @@ class SomeModel(WithCustomFieldsMixin, models.Model): def get_absolute_url(self): return reverse( - 'cf_admin:{}_{}_change'.format( + 'admin:{}_{}_change'.format( self._meta.app_label, self._meta.model_name ), args=(self.pk,) ) @classmethod def get_add_url(self): - return reverse('cf_admin:{}_{}_add'.format( + return reverse('admin:{}_{}_add'.format( self._meta.app_label, self._meta.model_name )) diff --git a/src/ralph/lib/custom_fields/tests/urls.py b/src/ralph/lib/custom_fields/tests/urls.py index 7d48480ef0..02a4e6106d 100644 --- a/src/ralph/lib/custom_fields/tests/urls.py +++ b/src/ralph/lib/custom_fields/tests/urls.py @@ -3,8 +3,8 @@ from . import admin, api cf_tests_urls, cf_tests_app_name, cf_tests_namespace = admin.site.urls - +import ipdb; ipdb.set_trace() urlpatterns = [ - url(r'^cf_tests_admin/', include((cf_tests_urls, 'ralph', cf_tests_namespace))), + url(r'^cf_tests_admin/', include((cf_tests_urls, 'ralph', 'admin'))), url(r'^cf_test_api/', include(api.urlpatterns)) ] From 017b85ce55b82679660541fb7c615cd1b802ac20 Mon Sep 17 00:00:00 2001 From: Mateusz Kurek Date: Fri, 30 Dec 2016 18:16:19 +0100 Subject: [PATCH 4/6] wip --- src/ralph/lib/custom_fields/tests/models.py | 4 ++-- src/ralph/lib/custom_fields/tests/urls.py | 4 +--- src/ralph/urls/base.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ralph/lib/custom_fields/tests/models.py b/src/ralph/lib/custom_fields/tests/models.py index 689665d398..eb5f3eaf6f 100644 --- a/src/ralph/lib/custom_fields/tests/models.py +++ b/src/ralph/lib/custom_fields/tests/models.py @@ -10,13 +10,13 @@ class SomeModel(WithCustomFieldsMixin, models.Model): def get_absolute_url(self): return reverse( - 'admin:{}_{}_change'.format( + 'cf_admin:{}_{}_change'.format( self._meta.app_label, self._meta.model_name ), args=(self.pk,) ) @classmethod def get_add_url(self): - return reverse('admin:{}_{}_add'.format( + return reverse('cf_admin:{}_{}_add'.format( self._meta.app_label, self._meta.model_name )) diff --git a/src/ralph/lib/custom_fields/tests/urls.py b/src/ralph/lib/custom_fields/tests/urls.py index 02a4e6106d..84686c735c 100644 --- a/src/ralph/lib/custom_fields/tests/urls.py +++ b/src/ralph/lib/custom_fields/tests/urls.py @@ -2,9 +2,7 @@ from . import admin, api -cf_tests_urls, cf_tests_app_name, cf_tests_namespace = admin.site.urls -import ipdb; ipdb.set_trace() urlpatterns = [ - url(r'^cf_tests_admin/', include((cf_tests_urls, 'ralph', 'admin'))), + url(r'^cf_tests_admin/', include(admin.site.urls)), url(r'^cf_test_api/', include(api.urlpatterns)) ] diff --git a/src/ralph/urls/base.py b/src/ralph/urls/base.py index dc6ecc85a7..49ed831dc0 100644 --- a/src/ralph/urls/base.py +++ b/src/ralph/urls/base.py @@ -29,10 +29,9 @@ # api views are registered in router) api_urls += [url(r'^', include(router.urls))] -ralph_urls, ralph_app_name, ralph_namespace = admin.urls urlpatterns = [ # override app_name (admin) with ralph (mainly for sitetree) - url(r'^', include((ralph_urls, 'ralph', ralph_namespace))), + url(r'^', include(admin.urls)), url(r'^api/', include(api_urls)), url(r'^api-token-auth/', views.obtain_auth_token), url(r'^', include('ralph.dc_view.urls.ui')), @@ -48,3 +47,10 @@ if getattr(settings, 'ENABLE_HERMES_INTEGRATION', False): urlpatterns += url(r'^hermes/', include('pyhermes.apps.django.urls')), + + +# monkey patch for sitetree until +# https://github.com/idlesign/django-sitetree/issues/226 will be discussed +# and resolved +from sitetree.sitetreeapp import SiteTree # noqa +SiteTree.current_app_is_admin = lambda self: False From b5f797db1d91ae2266c2717329cea96b173e4b4b Mon Sep 17 00:00:00 2001 From: Mateusz Kurek Date: Fri, 30 Dec 2016 18:24:10 +0100 Subject: [PATCH 5/6] wip --- src/ralph/urls/base.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ralph/urls/base.py b/src/ralph/urls/base.py index 49ed831dc0..44a9ab3100 100644 --- a/src/ralph/urls/base.py +++ b/src/ralph/urls/base.py @@ -1,10 +1,16 @@ from django.conf import settings from django.conf.urls import include, url from rest_framework.authtoken import views +from sitetree.sitetreeapp import SiteTree # noqa from ralph.admin import ralph_site as admin from ralph.api import router +# monkey patch for sitetree until +# https://github.com/idlesign/django-sitetree/issues/226 will be discussed +# and resolved +SiteTree.current_app_is_admin = lambda self: False + # import custom urls from each api module # notice that each module should have `urlpatters` variable defined # (as empty list if there is any custom url) @@ -47,10 +53,3 @@ if getattr(settings, 'ENABLE_HERMES_INTEGRATION', False): urlpatterns += url(r'^hermes/', include('pyhermes.apps.django.urls')), - - -# monkey patch for sitetree until -# https://github.com/idlesign/django-sitetree/issues/226 will be discussed -# and resolved -from sitetree.sitetreeapp import SiteTree # noqa -SiteTree.current_app_is_admin = lambda self: False From dfc3910ef2e59b775bca78189337b1f533d72d6d Mon Sep 17 00:00:00 2001 From: Mateusz Kurek Date: Mon, 2 Jan 2017 09:13:22 +0100 Subject: [PATCH 6/6] wip --- src/ralph/urls/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ralph/urls/base.py b/src/ralph/urls/base.py index 44a9ab3100..d3d59e0fe4 100644 --- a/src/ralph/urls/base.py +++ b/src/ralph/urls/base.py @@ -36,7 +36,6 @@ api_urls += [url(r'^', include(router.urls))] urlpatterns = [ - # override app_name (admin) with ralph (mainly for sitetree) url(r'^', include(admin.urls)), url(r'^api/', include(api_urls)), url(r'^api-token-auth/', views.obtain_auth_token),