~homeworkprod/byceps

087d94ccb90c98821dff2e8f2bd3cdc967074229 — Jochen Kupperschmidt 10 months ago 4fad7af
Remove suffix from email config service fetch functions' names
M byceps/blueprints/admin/brand/views.py => byceps/blueprints/admin/brand/views.py +2 -2
@@ 59,7 59,7 @@ def view(brand_id):
    brand = _get_brand_or_404(brand_id)

    settings = brand_settings_service.get_settings(brand.id)
    email_config = email_service.find_config_for_brand(brand.id)
    email_config = email_service.find_config(brand.id)

    return {
        'brand': brand,


@@ 202,7 202,7 @@ def _get_brand_or_404(brand_id):


def _get_email_config_or_404(brand_id):
    config = email_service.find_config_for_brand(brand_id)
    config = email_service.find_config(brand_id)

    if config is None:
        abort(404)

M byceps/blueprints/admin/shop/email/views.py => byceps/blueprints/admin/shop/email/views.py +1 -1
@@ 37,7 37,7 @@ def view_for_shop(shop_id):
    """Show e-mail examples."""
    shop = _get_shop_or_404(shop_id)

    email_config = email_service.find_config_for_brand(shop.brand_id)
    email_config = email_service.find_config(shop.brand_id)

    example_placed_order_message_text = _get_example_placed_order_message_text(
        shop.id

M byceps/blueprints/common/authentication/password/views.py => byceps/blueprints/common/authentication/password/views.py +1 -1
@@ 132,7 132,7 @@ def _get_sender() -> Optional[Sender]:
        return None

    site = site_service.get_site(g.site_id)
    email_config = email_service.get_config_for_brand(site.brand_id)
    email_config = email_service.get_config(site.brand_id)
    return email_config.sender



M byceps/blueprints/site/ticketing/notification_service.py => byceps/blueprints/site/ticketing/notification_service.py +1 -1
@@ 123,7 123,7 @@ def _get_party_title():

def _enqueue_email(recipient: User, subject: str, body: str) -> None:
    site = site_service.get_site(g.site_id)
    email_config = email_service.get_config_for_brand(site.brand_id)
    email_config = email_service.get_config(site.brand_id)
    sender = email_config.sender

    recipient_address = user_service.get_email_address(recipient.id)

M byceps/services/email/service.py => byceps/services/email/service.py +10 -10
@@ 51,7 51,7 @@ def update_config(
    contact_address: Optional[str],
) -> EmailConfig:
    """Update a configuration."""
    config = _find_db_config_for_brand(brand_id)
    config = _find_db_config(brand_id)

    if config is None:
        raise UnknownEmailConfigId(


@@ 75,7 75,7 @@ def delete_config(brand_id: BrandID) -> bool:

    Return `True` on success, or `False` if an error occurred.
    """
    get_config_for_brand(brand_id)  # Verify ID exists.
    get_config(brand_id)  # Verify ID exists.

    try:
        db.session.query(DbEmailConfig) \


@@ 90,15 90,15 @@ def delete_config(brand_id: BrandID) -> bool:
    return True


def _find_db_config_for_brand(brand_id: BrandID) -> Optional[DbEmailConfig]:
def _find_db_config(brand_id: BrandID) -> Optional[DbEmailConfig]:
    return DbEmailConfig.query \
        .filter_by(brand_id=brand_id) \
        .one_or_none()


def find_config_for_brand(brand_id: BrandID) -> Optional[EmailConfig]:
    """Return the configuration for that brand, or `None` if not found."""
    config = _find_db_config_for_brand(brand_id)
def find_config(brand_id: BrandID) -> Optional[EmailConfig]:
    """Return the configuration, or `None` if not found."""
    config = _find_db_config(brand_id)

    if config is None:
        return None


@@ 106,11 106,11 @@ def find_config_for_brand(brand_id: BrandID) -> Optional[EmailConfig]:
    return _db_entity_to_config(config)


def get_config_for_brand(brand_id: BrandID) -> EmailConfig:
    """Return the configuration for that brand, or raise an error if
    none is configured for that brand ID.
def get_config(brand_id: BrandID) -> EmailConfig:
    """Return the configuration, or raise an error if none is configured
    for that brand.
    """
    config = find_config_for_brand(brand_id)
    config = find_config(brand_id)

    if config is None:
        raise UnknownEmailConfigId(

M byceps/services/shop/order/email/service.py => byceps/services/shop/order/email/service.py +1 -1
@@ 183,7 183,7 @@ def _assemble_email_to_orderer(


def _get_sender_address(brand_id: BrandID) -> Optional[Sender]:
    config = email_service.find_config_for_brand(brand_id)
    config = email_service.find_config(brand_id)

    if not config:
        current_app.logger.warning(

M byceps/services/user/email_address_verification_service.py => byceps/services/user/email_address_verification_service.py +1 -1
@@ 33,7 33,7 @@ def send_email_address_confirmation_email(
) -> None:
    site = site_service.get_site(site_id)

    email_config = email_service.get_config_for_brand(site.brand_id)
    email_config = email_service.get_config(site.brand_id)
    sender = email_config.sender

    verification_token = verification_token_service.create_for_email_address_confirmation(

M byceps/services/user_message/service.py => byceps/services/user_message/service.py +1 -1
@@ 80,7 80,7 @@ def _assemble_message(
    site: Site,
) -> Message:
    """Assemble an email message with the rendered template as its body."""
    email_config = email_service.get_config_for_brand(site.brand_id)
    email_config = email_service.get_config(site.brand_id)

    website_contact_address = email_config.contact_address


M tests/conftest.py => tests/conftest.py +1 -1
@@ 207,7 207,7 @@ def make_email_config(admin_app, brand):
            contact_address=contact_address,
        )

        config = email_service.get_config_for_brand(brand_id)
        config = email_service.get_config(brand_id)
        configs.append(config)

        return config