Skip to content

Commit

Permalink
[NHUB-537] Upgrade Agenda to async resource (#1150)
Browse files Browse the repository at this point in the history
* update types

* fix init_data: await elastic_rebuild

* new base web search service

* new agenda resource service

* new agenda search service

* update agenda module

* update agenda views

* update agenda notifications and emails

* update agenda featured to use new agenda search

* update push to use async agenda

* update wire module

* update remove_expired_agenda command

* user async resources in update_action_list

* fix company updates

* add more async product helpers

* fix update company products

* update reports to use async resources

* fix template_locale context with no locale nor timezone

* improve async topic helpers

* remove old utils no longer used

* add pydantic to mypy

* fix leaking db connectors in pytest

* fix tests

* use NHUB-537 branch in superdesk-core

* fix duplicate import

* use async branch from superdesk-core

* remove commented code

* Replace if/elif block with match case statements
  • Loading branch information
MarkLark86 authored Nov 10, 2024
1 parent ae4c663 commit d32dbe3
Show file tree
Hide file tree
Showing 104 changed files with 4,026 additions and 3,410 deletions.
8 changes: 4 additions & 4 deletions features/web_api/agenda_restrict_coverage_details.feature
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ Feature: Agenda Restricted Coverage Details
"coverages": [{
"coverage_id": "plan1_cov1",
"coverage_type": "text",
"scheduled": "2018-05-28T10:51:52+0000",
"scheduled": "2018-05-28T10:51:52+00:00",
"slugline": "Vivid planning item",
"workflow_status": "draft",
"coverage_status": "coverage intended"
}, {
"coverage_id": "plan1_cov2",
"coverage_type": "text",
"scheduled": "2018-05-28T10:51:52+0000",
"scheduled": "2018-05-28T10:51:52+00:00",
"slugline": "Vivid planning item",
"workflow_status": "draft",
"coverage_status": "coverage intended"
Expand All @@ -166,7 +166,7 @@ Feature: Agenda Restricted Coverage Details
"guid": "plan1",
"slugline": "New Press Conference",
"name": "Prime minister press conference",
"planning_date": "2018-05-28T05:00:00+0000",
"planning_date": "2018-05-28T05:00:00+00:00",
"coverages": [{
"coverage_id": "plan1_cov1",
"news_coverage_status": {
Expand Down Expand Up @@ -283,7 +283,7 @@ Feature: Agenda Restricted Coverage Details
}, {
"coverage_id": "plan1_cov2",
"coverage_type": "text",
"scheduled": "2018-05-28T10:51:52+0000",
"scheduled": "2018-05-28T10:51:52+00:00",
"slugline": "Vivid planning item",
"workflow_status": "completed",
"coverage_status": "coverage intended",
Expand Down
18 changes: 9 additions & 9 deletions features/web_api/agenda_search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Feature: Agenda Search
},
"calendars": [{"qcode": "cal1", "name": "Calendar1"}],
"subject": [
{"code": "d1", "scheme": "sttdepartment", "name": "Dep1"},
{"code": "s1", "scheme": "sttsubj", "name": "Sub1"},
{"code": "e1", "scheme": "event_type", "name": "Sports"}
{"qcode": "d1", "scheme": "sttdepartment", "name": "Dep1"},
{"qcode": "s1", "scheme": "sttsubj", "name": "Sub1"},
{"qcode": "e1", "scheme": "event_type", "name": "Sports"}
],
"place": [
{"code": "NSW", "name": "New South Wales"}
Expand Down Expand Up @@ -51,9 +51,9 @@ Feature: Agenda Search
{"_id": "test", "name": "Agenda2"}
],
"subject": [
{"code": "d2", "scheme": "sttdepartment", "name": "Dep2"},
{"code": "s1", "scheme": "sttsubj", "name": "Sub1"},
{"code": "s2", "scheme": "sttsubj", "name": "Sub2"}
{"qcode": "d2", "scheme": "sttdepartment", "name": "Dep2"},
{"qcode": "s1", "scheme": "sttsubj", "name": "Sub1"},
{"qcode": "s2", "scheme": "sttsubj", "name": "Sub2"}
],
"place": [
{"code": "VIC", "name": "Victoria"}
Expand Down Expand Up @@ -95,9 +95,9 @@ Feature: Agenda Search
{"_id": "test", "name": "Agenda2"}
],
"subject": [
{"code": "d3", "scheme": "sttdepartment", "name": "Dep3"},
{"code": "s1", "scheme": "sttsubj", "name": "Sub1"},
{"code": "s2", "scheme": "sttsubj", "name": "Sub2"}
{"qcode": "d3", "scheme": "sttdepartment", "name": "Dep3"},
{"qcode": "s1", "scheme": "sttsubj", "name": "Sub1"},
{"qcode": "s2", "scheme": "sttsubj", "name": "Sub2"}
],
"place": [
{"code": "VIC", "name": "Victoria"}
Expand Down
1 change: 1 addition & 0 deletions mypy-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mypy
pydantic
types-Flask
types-Jinja2
types-python-dateutil
Expand Down
30 changes: 12 additions & 18 deletions newsroom/agenda/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import superdesk
from quart_babel import lazy_gettext

from superdesk.flask import Blueprint
from newsroom.utils import url_for_agenda
from .agenda import AgendaResource, AgendaService, aggregations, PRIVATE_FIELDS
from newsroom.search.config import init_nested_aggregation
from . import formatters

from .formatters import iCalFormatter, CSVFormatter
from .utils import (
get_coverage_email_text,
get_coverage_content_type_name,
Expand All @@ -15,20 +12,22 @@
get_coverage_status,
get_event_state,
)
from .filters import AgendaSearchRequestArgs
from .agenda_service import AgendaItemService
from .agenda_search import AgendaSearchServiceAsync


blueprint = Blueprint("agenda", __name__)

from . import views # noqa
from .module import module # noqa


AGENDA_NESTED_SEARCH_FIELDS = ["subject"]
__all__ = [
"AgendaSearchServiceAsync",
"AgendaItemService",
"AgendaSearchRequestArgs",
]


def init_app(app):
superdesk.register_resource("agenda", AgendaResource, AgendaService, _app=app)

app.section("agenda", app.config["AGENDA_SECTION"], "agenda")
app.sidenav(app.config["AGENDA_SECTION"], "agenda.index", "calendar", section="agenda")
app.sidenav(
Expand All @@ -40,8 +39,8 @@ def init_app(app):
badge="saved-items-count",
)

app.download_formatter("ical", formatters.iCalFormatter(), "iCalendar", ["agenda"])
app.download_formatter("Csv", formatters.CSVFormatter(), "CSV", ["agenda"])
app.download_formatter("ical", iCalFormatter(), "iCalendar", ["agenda"])
app.download_formatter("Csv", CSVFormatter(), "CSV", ["agenda"])
app.add_template_global(url_for_agenda)
app.add_template_global(get_coverage_email_text)
app.add_template_global(get_coverage_content_type_name, "get_coverage_content_type")
Expand Down Expand Up @@ -80,8 +79,3 @@ def init_app(app):
"label": lazy_gettext("Place"),
},
]

init_nested_aggregation("agenda", AGENDA_NESTED_SEARCH_FIELDS, app.config.get("AGENDA_GROUPS", []), aggregations)

if app.config.get("AGENDA_HIDE_COVERAGE_ASSIGNEES"):
PRIVATE_FIELDS.extend(["*.assigned_desk_*", "*.assigned_user_*"])
Loading

0 comments on commit d32dbe3

Please sign in to comment.