Skip to content

Commit

Permalink
Move on_create, on_created, on_update & on_updated
Browse files Browse the repository at this point in the history
SDESK-7442
  • Loading branch information
eos87 committed Dec 8, 2024
1 parent 4035048 commit 4778c25
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 45 deletions.
1 change: 0 additions & 1 deletion server/planning/commands/export_to_newsroom_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ async def setup_data(self):
"type": "event",
},
]
events = [EventResourceModel.from_dict(ev) for ev in events]

planning = [
{
Expand Down
25 changes: 11 additions & 14 deletions server/planning/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@

"""Superdesk Events"""

from typing import Dict, Any, Optional, List, Tuple

import re
import pytz
import logging
import itertools

from copy import deepcopy
from datetime import timedelta

import pytz
import re
from typing import Dict, Any, Optional, List, Tuple
from eve.methods.common import resolve_document_etag
from eve.utils import date_to_str
from dateutil.rrule import (
Expand All @@ -35,9 +36,9 @@
SU,
)

import superdesk
from superdesk.core import get_app_config, get_current_app
from superdesk.resource_fields import ID_FIELD
import superdesk
from superdesk import get_resource_service
from superdesk.errors import SuperdeskApiError
from superdesk.metadata.utils import generate_guid
Expand All @@ -48,12 +49,8 @@
from apps.auth import get_user, get_user_id
from apps.archive.common import get_auth, update_dates_for

from planning.types import (
Event,
EmbeddedPlanning,
PlanningRelatedEventLink,
PLANNING_RELATED_EVENT_LINK_TYPE,
)
from planning.types import Event, PlanningRelatedEventLink, PLANNING_RELATED_EVENT_LINK_TYPE
from planning.types.event import EmbeddedPlanning
from planning.common import (
UPDATE_SINGLE,
UPDATE_FUTURE,
Expand Down Expand Up @@ -281,9 +278,9 @@ def create(self, docs: List[Event], **kwargs):

embedded_planning_lists: List[Tuple[Event, List[EmbeddedPlanning]]] = []
for event in docs:
embedded_planning = get_events_embedded_planning(event)
if len(embedded_planning):
embedded_planning_lists.append((event, embedded_planning))
emb_planning = get_events_embedded_planning(event)
if len(emb_planning):
embedded_planning_lists.append((event, emb_planning)) # type: ignore

ids = self.backend.create(self.datasource, docs, **kwargs)

Expand Down
Loading

0 comments on commit 4778c25

Please sign in to comment.