From 829350b71e4646d3d581e3c38c612ce2dddb87c1 Mon Sep 17 00:00:00 2001 From: duker Date: Fri, 22 Jun 2018 12:02:29 +0300 Subject: [PATCH 1/6] #360 Refresh py reqs according to stb --- requirements.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index 37dfc01a..3d530eae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ beautifulsoup4 -celery +celery==4.1.0 Django==1.10 django-debug-toolbar django-redis django-mptt==0.8.7 django-widget-tweaks ipython -openpyxl==2.4.2 -pillow -psycopg2-binary +openpyxl==2.5.2 +Pillow==5.1.0 +psycopg2-binary==2.7.4 requests -selenium -selenium-requests -tblib -unidecode -ua-parser==0.7.3 -user-agents==1.0.1 +selenium==3.11.0 +selenium-requests==1.3 +tblib==1.3.2 +Unidecode==1.0.22 +ua-parser==0.8.0 +user-agents==1.1.0 sorl-thumbnail==12.4a1 https://github.com/selwin/django-user_agents/archive/master.zip -https://github.com/fidals/refarm-site/archive/0.1.0.zip +https://github.com/fidals/refarm-site/archive/0.1.6.zip From f0e55678fa7db78f212e848195a047ef9abe7e59 Mon Sep 17 00:00:00 2001 From: duker Date: Fri, 22 Jun 2018 12:57:26 +0300 Subject: [PATCH 2/6] #360 Create test with unexpected behaviour explaining --- shopelectro/tests/tests_views.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/shopelectro/tests/tests_views.py b/shopelectro/tests/tests_views.py index 2a4a3c8c..def98f84 100644 --- a/shopelectro/tests/tests_views.py +++ b/shopelectro/tests/tests_views.py @@ -5,6 +5,7 @@ They all should be using Django's TestClient. """ import json +import unittest from functools import partial from itertools import chain from operator import attrgetter @@ -516,3 +517,36 @@ def test_admin_autocomplete_has_no_model_pages(self): f'?term={self.QUOTED_SIGNLE_RESULT_TERM}&pageType=category' ) self.assertTrue(len(json_to_dict(response)) == 1) + + +class Redirects(TestCase): + + fixtures = ['dump.json'] + + @unittest.expectedFailure('rf#140 task will resurrect it') + def test_redirect_on_existing_page(self): + """DB based redirect from existing url should do, but should not avoid it.""" + # take some existing `url_from` + url_from = '/catalog/categories/category-0/tags/6-v/' + response = self.client.get(url_from) + self.assertEqual(response.status_code, 200) + + # create redirect from `url_from` to another existing one - `url_to` + from django.contrib.redirects.models import Redirect + from django.contrib.sites.models import Site + + # Site.objects.create(domain='shopelectro.ru', name='shopelectro') + + url_to = '/catalog/categories/category-0/' + Redirect.objects.create( + site=Site.objects.first(), + old_path=url_from, + new_path=url_to + ) + + # `url_from` should redirect to `url_to` + response = self.client.get(url_from) + self.assertEqual(response.status_code, 301) + response = self.client.get(url_from, follow=True) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.url, url_from) From a3c499b46e810c59ca9be3d8f073aa5ae3699775 Mon Sep 17 00:00:00 2001 From: duker Date: Fri, 22 Jun 2018 16:21:34 +0300 Subject: [PATCH 3/6] #360 Fix commented test and refarm-site dependency --- requirements.txt | 2 +- shopelectro/tests/tests_views.py | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3d530eae..4f2b771e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,4 +18,4 @@ ua-parser==0.8.0 user-agents==1.1.0 sorl-thumbnail==12.4a1 https://github.com/selwin/django-user_agents/archive/master.zip -https://github.com/fidals/refarm-site/archive/0.1.6.zip +https://github.com/fidals/refarm-site/archive/0.1.3.zip diff --git a/shopelectro/tests/tests_views.py b/shopelectro/tests/tests_views.py index def98f84..c497aabb 100644 --- a/shopelectro/tests/tests_views.py +++ b/shopelectro/tests/tests_views.py @@ -14,6 +14,8 @@ from bs4 import BeautifulSoup from django.conf import settings +from django.contrib.redirects.models import Redirect +from django.contrib.sites.models import Site from django.db.models import Q from django.http import HttpResponse from django.test import TestCase @@ -523,7 +525,6 @@ class Redirects(TestCase): fixtures = ['dump.json'] - @unittest.expectedFailure('rf#140 task will resurrect it') def test_redirect_on_existing_page(self): """DB based redirect from existing url should do, but should not avoid it.""" # take some existing `url_from` @@ -532,11 +533,6 @@ def test_redirect_on_existing_page(self): self.assertEqual(response.status_code, 200) # create redirect from `url_from` to another existing one - `url_to` - from django.contrib.redirects.models import Redirect - from django.contrib.sites.models import Site - - # Site.objects.create(domain='shopelectro.ru', name='shopelectro') - url_to = '/catalog/categories/category-0/' Redirect.objects.create( site=Site.objects.first(), From fd19fabe84cc80947a73be4a7829d6fc7f5997eb Mon Sep 17 00:00:00 2001 From: duker Date: Fri, 22 Jun 2018 16:54:48 +0300 Subject: [PATCH 4/6] rf#140 Change imports to new redirects app --- shopelectro/admin.py | 2 +- shopelectro/settings/base.py | 4 ++-- shopelectro/tests/tests_views.py | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/shopelectro/admin.py b/shopelectro/admin.py index 0a9441f7..99d0b0be 100644 --- a/shopelectro/admin.py +++ b/shopelectro/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin from django.contrib.admin.widgets import FilteredSelectMultiple -from django.contrib.redirects.models import Redirect +from redirects.models import Redirect from django.db import models as django_models from django.urls import reverse from django.utils.html import format_html diff --git a/shopelectro/settings/base.py b/shopelectro/settings/base.py index 11ee1601..e7842baa 100644 --- a/shopelectro/settings/base.py +++ b/shopelectro/settings/base.py @@ -47,7 +47,6 @@ 'django.contrib.contenttypes', 'django.contrib.auth', 'django.contrib.messages', - 'django.contrib.redirects', 'django.contrib.sessions', 'django.contrib.sitemaps', 'django.contrib.sites', @@ -66,6 +65,7 @@ 'catalog', 'search', 'ecommerce', + 'redirects', 'shopelectro', ] @@ -78,10 +78,10 @@ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django_user_agents.middleware.UserAgentMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', + 'redirects.middleware.RedirectFallbackMiddleware', ] ROOT_URLCONF = 'shopelectro.urls' diff --git a/shopelectro/tests/tests_views.py b/shopelectro/tests/tests_views.py index c497aabb..565ec56b 100644 --- a/shopelectro/tests/tests_views.py +++ b/shopelectro/tests/tests_views.py @@ -14,13 +14,13 @@ from bs4 import BeautifulSoup from django.conf import settings -from django.contrib.redirects.models import Redirect from django.contrib.sites.models import Site from django.db.models import Q from django.http import HttpResponse from django.test import TestCase from django.urls import reverse from django.utils.translation import ugettext as _ +from redirects.models import Redirect from shopelectro.models import Category, Product, Tag, TagGroup, TagQuerySet, serialize_tags_to_url from shopelectro.views.service import generate_md5_for_ya_kassa, YANDEX_REQUEST_PARAM @@ -545,4 +545,3 @@ def test_redirect_on_existing_page(self): self.assertEqual(response.status_code, 301) response = self.client.get(url_from, follow=True) self.assertEqual(response.status_code, 200) - self.assertEqual(response.url, url_from) From a5452c371835bf028c5281b96dc687b1ce802f14 Mon Sep 17 00:00:00 2001 From: duker Date: Sun, 24 Jun 2018 18:52:47 +0300 Subject: [PATCH 5/6] rf#140 Fix commented code volumes in dc.yml --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0da6d666..1954534a 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -30,7 +30,7 @@ services: # contains refarm-site modules - $DEPS_DIR # Thus, you can work with apps related to the refarm-site - # - $REFARM_SRC/search:/root/.local/lib/python3.6/site-packages/search + #- $REFARM_DIR/search:/root/.local/lib/python3.6/site-packages/search command: python manage.py runserver 0.0.0.0:$VIRTUAL_HOST_PORT nodejs: From 2af6215508ec41a1a98ed42158757fbd05f25f47 Mon Sep 17 00:00:00 2001 From: duker Date: Tue, 3 Jul 2018 15:04:13 +0300 Subject: [PATCH 6/6] rf#140 Inherit redirects app from django's one --- shopelectro/settings/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shopelectro/settings/base.py b/shopelectro/settings/base.py index e7842baa..a70cb0e0 100644 --- a/shopelectro/settings/base.py +++ b/shopelectro/settings/base.py @@ -65,7 +65,7 @@ 'catalog', 'search', 'ecommerce', - 'redirects', + 'refarm_redirects', 'shopelectro', ] @@ -81,7 +81,7 @@ 'django.middleware.locale.LocaleMiddleware', 'django_user_agents.middleware.UserAgentMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', - 'redirects.middleware.RedirectFallbackMiddleware', + 'refarm_redirects.middleware.RedirectFallbackMiddleware', ] ROOT_URLCONF = 'shopelectro.urls'