~homeworkprod/byceps

7814dd7526a6a5cac8b2e8d692e5e444c4cbfe4d — Jochen Kupperschmidt 8 months ago ed0821b
Return DTOs after entity update from services where not yet the case
M byceps/blueprints/admin/news/views.py => byceps/blueprints/admin/news/views.py +2 -2
@@ 238,7 238,7 @@ def image_update(image_id):
    caption = form.caption.data.strip()
    attribution = form.attribution.data.strip()

    news_image_service.update_image(
    image = news_image_service.update_image(
        image.id, alt_text=alt_text, caption=caption, attribution=attribution,
    )



@@ 446,7 446,7 @@ def item_update(item_id):
    body = form.body.data.strip()
    image_url_path = form.image_url_path.data.strip()

    news_item_service.update_item(
    item = news_item_service.update_item(
        item.id, slug, creator.id, title, body, image_url_path=image_url_path
    )


M byceps/services/news/image_service.py => byceps/services/news/image_service.py +3 -1
@@ 126,7 126,7 @@ def update_image(
    alt_text: Optional[str] = None,
    caption: Optional[str] = None,
    attribution: Optional[str] = None,
) -> None:
) -> Image:
    """Update a news image."""
    image = _find_db_image(image_id)



@@ 139,6 139,8 @@ def update_image(

    db.session.commit()

    return _db_entity_to_image(image, image.item.channel_id)


def find_image(image_id: ImageID) -> Optional[Image]:
    """Return the image with that id, or `None` if not found."""

M byceps/services/news/service.py => byceps/services/news/service.py +3 -1
@@ 65,7 65,7 @@ def update_item(
    body: str,
    *,
    image_url_path: Optional[str] = None,
) -> None:
) -> Item:
    """Update a news item by creating a new version of it and setting
    the new version as the current one.
    """


@@ 82,6 82,8 @@ def update_item(

    db.session.commit()

    return _db_entity_to_item(item)


def _create_version(
    item: DbItem,

M byceps/services/orga_team/service.py => byceps/services/orga_team/service.py +3 -1
@@ 155,7 155,7 @@ def create_membership(

def update_membership(
    membership_id: MembershipID, team_id: OrgaTeamID, duties: str
) -> None:
) -> Membership:
    """Update the membership."""
    membership = _find_db_membership(membership_id)
    if membership is None:


@@ 169,6 169,8 @@ def update_membership(
    membership.duties = duties
    db.session.commit()

    return _db_entity_to_membership(membership)


def delete_membership(membership_id: MembershipID) -> None:
    """Delete the membership."""

M byceps/services/tourney/category_service.py => byceps/services/tourney/category_service.py +12 -4
@@ 17,7 17,7 @@ from .models.tourney_category import TourneyCategory as DbTourneyCategory
from .transfer.models import TourneyCategory, TourneyCategoryID


def create_category(party_id: PartyID, title: str) -> DbTourneyCategory:
def create_category(party_id: PartyID, title: str) -> TourneyCategory:
    """Create a category for that party."""
    party = DbParty.query.get(party_id)
    if party is None:


@@ 31,15 31,19 @@ def create_category(party_id: PartyID, title: str) -> DbTourneyCategory:
    return _db_entity_to_category(category)


def update_category(category_id: TourneyCategoryID, title: str) -> None:
def update_category(
    category_id: TourneyCategoryID, title: str
) -> TourneyCategory:
    """Update category."""
    category = _get_db_category(category_id)

    category.title = title
    db.session.commit()

    return _db_entity_to_category(category)


def move_category_up(category_id: TourneyCategoryID) -> None:
def move_category_up(category_id: TourneyCategoryID) -> TourneyCategory:
    """Move a category upwards by one position."""
    category = _get_db_category(category_id)



@@ 53,8 57,10 @@ def move_category_up(category_id: TourneyCategoryID) -> None:

    db.session.commit()

    return _db_entity_to_category(category)


def move_category_down(category_id: TourneyCategoryID) -> None:
def move_category_down(category_id: TourneyCategoryID) -> TourneyCategory:
    """Move a category downwards by one position."""
    category = _get_db_category(category_id)



@@ 68,6 74,8 @@ def move_category_down(category_id: TourneyCategoryID) -> None:

    db.session.commit()

    return _db_entity_to_category(category)


def delete_category(category_id: TourneyCategoryID) -> None:
    """Delete a category."""