Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add redirect view for integrations

Krzysztof Wolski947fa4e4b651
diff --git a/saleor/integrations/feeds.py b/saleor/integrations/feeds.py
index 0e3f6afe9d..119faf4d12 100644
--- a/saleor/integrations/feeds.py
+++ b/saleor/integrations/feeds.py
@@ -28,6 +28,7 @@ class GoogleProductFeed(object):
https://support.google.com/merchants/answer/7052112?visit_id=1-636148270257062854-1147518273&rd=1
"""
file_path = path.join(settings.INTEGRATIONS_DIR, 'google-feed.csv.gz')
+ file_url = settings.STATIC_URL + file_path
attributes = ['id', 'title', 'product_type', 'google_product_category',
'link', 'image_link', 'condition', 'availability',
'price', 'tax', 'shipping', 'sale_price',
@@ -199,6 +200,7 @@ class SaleorFeed(GoogleProductFeed):
Example of using GoogleProductFeed.
"""
file_path = path.join(settings.INTEGRATIONS_DIR, 'saleor-feed.csv.gz')
+ file_url = settings.MEDIA_URL + file_path
def item_shipping(self, item):
"""Flat shipping price"""
diff --git a/saleor/integrations/urls.py b/saleor/integrations/urls.py
index 3c9a775301..ff82eb6cc4 100644
--- a/saleor/integrations/urls.py
+++ b/saleor/integrations/urls.py
@@ -1,7 +1,9 @@
from django.conf.urls import url
-from . import views
+from django.views.generic.base import RedirectView
+from .feeds import SaleorFeed
urlpatterns = [
- url(r'saleor-feed/$', views.saleor_feed, name='saleor-feed'),
+ url(r'saleor-feed/$', RedirectView.as_view(url=SaleorFeed.file_url),
+ name='saleor-feed'),
]
diff --git a/saleor/integrations/views.py b/saleor/integrations/views.py
deleted file mode 100644
index ab5b6c22af..0000000000
--- a/saleor/integrations/views.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from __future__ import unicode_literals
-
-from django.core.files.storage import default_storage
-from django.http import Http404
-from django.http import HttpResponse
-
-from .feeds import SaleorFeed
-
-
-def get_integration_response(file_path, content_type):
- if not default_storage.exists(file_path):
- raise Http404("Integration file does not exists")
- feed_file = default_storage.open(file_path)
- return HttpResponse(feed_file, content_type=content_type)
-
-
-def saleor_feed(request):
- feed = SaleorFeed()
- return get_integration_response(feed.file_path,
- 'application/atom+xml; charset=utf-8')