diff --git a/server/planning/__init__.py b/server/planning/__init__.py index 328a42460..8baab761a 100644 --- a/server/planning/__init__.py +++ b/server/planning/__init__.py @@ -12,7 +12,7 @@ import logging import superdesk -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext from superdesk.resource_fields import ID_FIELD from .agendas import AgendasResource, AgendasService @@ -292,38 +292,12 @@ def init_app(app): init_scheduled_exports_task(app) - # Create 'type' required for planning module if not already preset - with app.app_context(): - vocabulary_service = superdesk.get_resource_service("vocabularies") - types = vocabulary_service.find_one(req=None, _id="type") - if types: - items = types.get("items") or [] - added_types = [] - type_names = [t["qcode"] for t in items] - - planning_type_list = [ - {"is_active": True, "name": "Planning item", "qcode": "planning"}, - {"is_active": True, "name": "Event", "qcode": "event"}, - { - "is_active": True, - "name": "Featured Stories", - "qcode": "planning_featured", - }, - ] - - for item in planning_type_list: - if item["qcode"] not in type_names: - added_types.append(item) - - if len(added_types) > 0: - vocabulary_service.patch(types.get(ID_FIELD), {"items": (items + added_types)}) - - custom_loaders = jinja2.ChoiceLoader( - app.jinja_loader.loaders + [jinja2.FileSystemLoader(os.path.join(_SERVER_PATH, "templates"))] - ) - app.jinja_loader = custom_loaders - - register_jinja_filter("formatted_address", get_formatted_address) + custom_loaders = jinja2.ChoiceLoader( + app.jinja_loader.loaders + [jinja2.FileSystemLoader(os.path.join(_SERVER_PATH, "templates"))] + ) + app.jinja_loader = custom_loaders + + register_jinja_filter("formatted_address", get_formatted_address) # add planning translations directory app.config["BABEL_TRANSLATION_DIRECTORIES"] += ";" + os.path.join(_SERVER_PATH, "translations") diff --git a/server/planning/assignments/__init__.py b/server/planning/assignments/__init__.py index 3b489762c..df28b6a98 100644 --- a/server/planning/assignments/__init__.py +++ b/server/planning/assignments/__init__.py @@ -9,7 +9,7 @@ # at https://www.sourcefabric.org/superdesk/license import superdesk -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext from superdesk.services import BaseService from .assignments import AssignmentsResource, AssignmentsService from .assignments_content import AssignmentsContentResource, AssignmentsContentService diff --git a/server/planning/assignments/assignments_link.py b/server/planning/assignments/assignments_link.py index 0dc74e989..5f751c32b 100644 --- a/server/planning/assignments/assignments_link.py +++ b/server/planning/assignments/assignments_link.py @@ -6,7 +6,7 @@ # AUTHORS and LICENSE files distributed with this source code, or # at https://www.sourcefabric.org/superdesk/license from copy import deepcopy -from flask_babel import _ +from quart_babel import gettext as _ from superdesk.resource_fields import ID_FIELD from superdesk import Resource, Service, get_resource_service diff --git a/server/planning/content_profiles/__init__.py b/server/planning/content_profiles/__init__.py index 8526c6fda..a7285f8cd 100644 --- a/server/planning/content_profiles/__init__.py +++ b/server/planning/content_profiles/__init__.py @@ -9,7 +9,7 @@ # at https://www.sourcefabric.org/superdesk/license from eve import Eve -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext import superdesk diff --git a/server/planning/events/__init__.py b/server/planning/events/__init__.py index cdbb39d75..cfe2c60a3 100644 --- a/server/planning/events/__init__.py +++ b/server/planning/events/__init__.py @@ -9,7 +9,7 @@ # at https://www.sourcefabric.org/superdesk/license import superdesk -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext from .events import EventsResource, EventsService from .events_spike import ( EventsSpikeResource, diff --git a/server/planning/feeding_services/onclusive_api_service.py b/server/planning/feeding_services/onclusive_api_service.py index 0e597ad4e..f81be444e 100644 --- a/server/planning/feeding_services/onclusive_api_service.py +++ b/server/planning/feeding_services/onclusive_api_service.py @@ -3,7 +3,7 @@ from typing import Optional from datetime import timedelta, datetime -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext from superdesk.io.registry import register_feeding_service_parser from superdesk.io.feeding_services.http_base_service import HTTPFeedingServiceBase from superdesk.timer import timer diff --git a/server/planning/io/ingest_rule_handler.py b/server/planning/io/ingest_rule_handler.py index 26f3fc000..698a774db 100644 --- a/server/planning/io/ingest_rule_handler.py +++ b/server/planning/io/ingest_rule_handler.py @@ -11,7 +11,7 @@ from typing import Dict, Any, Optional import logging -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext from bson import ObjectId from superdesk.resource_fields import ID_FIELD diff --git a/server/planning/locations/__init__.py b/server/planning/locations/__init__.py index 9205cb896..ee9152a1a 100644 --- a/server/planning/locations/__init__.py +++ b/server/planning/locations/__init__.py @@ -8,7 +8,7 @@ # AUTHORS and LICENSE files distributed with this source code, or # at https://www.sourcefabric.org/superdesk/license -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext import superdesk from .locations_service import LocationsResource, LocationsService diff --git a/server/planning/planning/__init__.py b/server/planning/planning/__init__.py index 4a135d881..ebebcf01a 100644 --- a/server/planning/planning/__init__.py +++ b/server/planning/planning/__init__.py @@ -8,7 +8,7 @@ # AUTHORS and LICENSE files distributed with this source code, or # at https://www.sourcefabric.org/superdesk/license -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext import superdesk diff --git a/server/planning/search/__init__.py b/server/planning/search/__init__.py index 6de066723..d00415ab0 100644 --- a/server/planning/search/__init__.py +++ b/server/planning/search/__init__.py @@ -9,7 +9,7 @@ # at https://www.sourcefabric.org/superdesk/license import superdesk -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext from .planning_search import PlanningSearchResource, PlanningSearchService from .eventsplanning_search import EventsPlanningResource, EventsPlanningService from .eventsplanning_filters import ( diff --git a/server/planning/utils.py b/server/planning/utils.py index 7cfbddf51..c6ecd0a0b 100644 --- a/server/planning/utils.py +++ b/server/planning/utils.py @@ -14,7 +14,7 @@ from bson.objectid import ObjectId from bson.errors import InvalidId -from flask_babel import lazy_gettext +from quart_babel import lazy_gettext from eve.utils import str_to_date, ParsedRequest import arrow import pytz diff --git a/server/requirements.txt b/server/requirements.txt index 66f0e7651..cfb4e4d3a 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -19,4 +19,4 @@ pytest-env -e . # Install in editable state so we get feature fixtures --e git+https://github.com/superdesk/superdesk-core.git@async#egg=superdesk-core +-e git+https://github.com/superdesk/superdesk-core.git@async