Source code for org.models.page_move

from onegov.page import Page, PageCollection


from typing import Generic, TypeVar, TYPE_CHECKING
if TYPE_CHECKING:
    from onegov.core.orm.abstract import (
        AdjacencyList, AdjacencyListCollection, MoveDirection)
    from sqlalchemy.orm import Session


[docs] _L = TypeVar('_L', bound='AdjacencyList')
[docs] class AdjacencyListMove(Generic[_L]): """ Represents a single move of an adjacency list item. """
[docs] __collection__: type['AdjacencyListCollection[_L]']
def __init__( self, session: 'Session', subject: _L, target: _L, direction: 'MoveDirection' ) -> None:
[docs] self.session = session
[docs] self.subject = subject
[docs] self.target = target
[docs] self.direction = direction
@property
[docs] def subject_id(self) -> int: return self.subject.id
@property
[docs] def target_id(self) -> int: return self.target.id
[docs] def execute(self) -> None: self.__collection__(self.session).move( subject=self.subject, target=self.target, direction=self.direction )
[docs] class PageMove(AdjacencyListMove[Page]):
[docs] __collection__ = PageCollection