Repository: fidals/shopelectro

Issue:
Bump refarm-site version
Bump a version from 0.1.0 to 0.1.6


Discussion:

Resolving patch:
diff --git a/shopelectro/settings/base.py b/shopelectro/settings/base.py
--- a/shopelectro/settings/base.py
+++ b/shopelectro/settings/base.py
@@ -86,10 +86,11 @@
 
 ROOT_URLCONF = 'shopelectro.urls'
 
+TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
-        'DIRS': [os.path.join(BASE_DIR, 'templates')],
+        'DIRS': [TEMPLATE_DIR],
         'APP_DIRS': True,
         'OPTIONS': {
             'context_processors': [
@@ -166,10 +167,10 @@
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql',
-        'NAME': os.environ["POSTGRES_DB"],
-        'USER': os.environ["POSTGRES_USER"],
-        'PASSWORD': os.environ["POSTGRES_PASSWORD"],
-        'HOST': os.environ["POSTGRES_URL"],
+        'NAME': os.environ['POSTGRES_DB'],
+        'USER': os.environ['POSTGRES_USER'],
+        'PASSWORD': os.environ['POSTGRES_PASSWORD'],
+        'HOST': os.environ['POSTGRES_URL'],
         'PORT': '5432',
     }
 }
@@ -267,8 +268,7 @@
 EMAIL_HOST = 'smtp.yandex.ru'
 EMAIL_PORT = 587
 EMAIL_SENDER = 'info@shopelectro.ru'
-EMAIL_RECIPIENT = 'info@shopelectro.ru'
-SHOP_EMAIL = 'info@shopelectro.ru'
+EMAIL_RECIPIENTS = os.environ.get('EMAIL_RECIPIENTS', 'info@shopelectro.ru').split(',')
 
 # FTP configs
 FTP_USER = os.environ.get('FTP_USER', 'user')
@@ -316,6 +316,11 @@
     'local_delivery_cost_threshold': 5000,
 }
 
+
+def get_robots_content():
+    with open(os.path.join(TEMPLATE_DIR, 'robots.txt')) as robots_file:
+        return robots_file.read()
+
 # used in data-migrations and tests
 CUSTOM_PAGES = {
     'index': {
@@ -346,7 +351,11 @@
     'order_success': {
         'slug': 'order-success',
         'name': 'Заказ принят',
-    }
+    },
+    'robots': {
+        'slug': 'robots',
+        'content': get_robots_content(),
+    },
 }
 
 TAGS_URL_DELIMITER = '-or-'
diff --git a/shopelectro/sitemaps.py b/shopelectro/sitemaps.py
--- a/shopelectro/sitemaps.py
+++ b/shopelectro/sitemaps.py
@@ -80,4 +80,4 @@ def items(self):
 class PagesSitemap(AbstractSitemap):
 
     def items(self):
-        return Page.objects.filter(is_active=True)
+        return Page.objects.get_active()
diff --git a/shopelectro/urls.py b/shopelectro/urls.py
--- a/shopelectro/urls.py
+++ b/shopelectro/urls.py
@@ -6,8 +6,8 @@
 from django.contrib.sitemaps.views import sitemap
 from django.views.decorators.cache import cache_page
 
-from pages.models import Page
-from pages.views import robots, SitemapPage
+from pages.views import RobotsView, SitemapPage
+from pages.urls import custom_page_url
 
 from shopelectro import sitemaps, config, views
 from shopelectro.admin import se_admin
@@ -90,14 +90,14 @@ def cache_page(arg):  # Ignore PyFlakesBear
     url(r'', include('ecommerce.urls')),
 ]
 
-url_name = Page.CUSTOM_PAGES_URL_NAME
 custom_pages = [
-    url(r'^(?P<page>)$', cached_2h(views.IndexPage.as_view()), name=url_name),
-    url(r'^(?P<page>search)/$', views.Search.as_view(), name=url_name),
-    url(r'^(?P<page>catalog)/$', cached_2h(views.CategoryTree.as_view()), name=url_name),
-    url(r'^shop/(?P<page>order)/$', views.OrderPage.as_view(), name=url_name),
-    url(r'^shop/(?P<page>order-success)/$', views.OrderSuccess.as_view(), name=url_name),
-    url(r'^(?P<page>sitemap)/$', SitemapPage.as_view(), name=url_name),
+    custom_page_url(r'^(?P<page>)$', cached_2h(views.IndexPage.as_view())),
+    custom_page_url(r'^robots\.txt/$', RobotsView.as_view(in_db=True)),
+    custom_page_url(r'^(?P<page>search)/$', views.Search.as_view()),
+    custom_page_url(r'^(?P<page>catalog)/$', cached_2h(views.CategoryTree.as_view())),
+    custom_page_url(r'^shop/(?P<page>order)/$', views.OrderPage.as_view()),
+    custom_page_url(r'^shop/(?P<page>order-success)/$', views.OrderSuccess.as_view()),
+    custom_page_url(r'^(?P<page>sitemap)/$', SitemapPage.as_view()),
 ]
 
 urlpatterns = [
@@ -105,7 +105,6 @@ def cache_page(arg):  # Ignore PyFlakesBear
     url(r'^admin/', include(admin_urls)),
     url(r'^catalog/', include(catalog_urls)),
     url(r'^pages/', include('pages.urls')),
-    url(r'^robots\.txt$', robots),
     url(r'^save-feedback/$', views.save_feedback),
     url(r'^delete-feedback/$', views.delete_feedback),
     url(r'^set-view-type/$', views.set_view_type, name='set_view_type'),


Test patch: