From 3258b127afc8fc653c2782149f605d2f7e671487 Mon Sep 17 00:00:00 2001 From: Tolga Akin Date: Thu, 23 Apr 2020 20:01:55 +1000 Subject: [PATCH] Caching home cards per company (#1038) * Caching home cards per company * Ading email validator * Skipping user sign up Co-authored-by: Tolga Akin --- newsroom/wire/views.py | 7 ++++--- requirements.txt | 1 + tests/test_auth.py | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/newsroom/wire/views.py b/newsroom/wire/views.py index 1d9554faf..24057c2db 100644 --- a/newsroom/wire/views.py +++ b/newsroom/wire/views.py @@ -72,8 +72,9 @@ def get_view_data(): def get_items_by_card(cards, company_id): - if app.cache.get(HOME_ITEMS_CACHE_KEY): - return app.cache.get(HOME_ITEMS_CACHE_KEY) + cache_key = '{}{}'.format(HOME_ITEMS_CACHE_KEY, company_id or '') + if app.cache.get(cache_key): + return app.cache.get(cache_key) items_by_card = {} for card in cards: @@ -83,7 +84,7 @@ def get_items_by_card(cards, company_id): elif card['type'] == '4-photo-gallery': items_by_card[card['label']] = app.get_media_cards_external(card) - app.cache.set(HOME_ITEMS_CACHE_KEY, items_by_card, timeout=300) + app.cache.set(cache_key, items_by_card, timeout=300) return items_by_card diff --git a/requirements.txt b/requirements.txt index 5b958df61..2587e1cf0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ werkzeug>=0.9.4,<=0.11.15 +email-validator==1.0.5 -e . git+git://github.com/superdesk/superdesk-planning.git@1.10#egg=superdesk-planning git+git://github.com/superdesk/superdesk-core.git@master#egg=superdesk-core diff --git a/tests/test_auth.py b/tests/test_auth.py index 7c57e10bf..153089f23 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -1,7 +1,7 @@ import datetime from flask import url_for from bson import ObjectId -from pytest import fixture +from pytest import fixture, mark from superdesk import get_resource_service from superdesk.utils import get_hash @@ -58,6 +58,7 @@ def test_new_user_signup_sends_email(app, client): assert 'Press co.' in outbox[0].body +@mark.skip(reason="STT doesn't have sign up") def test_new_user_signup_fails_if_fields_not_provided(client): # Register a new account response = client.post(url_for('auth.signup'), data={