~homeworkprod/byceps

f8c663d0c8d818803b7d3711c3f71fc4f86b6c29 — Jochen Kupperschmidt 2 years ago a959e43
Add optional contact address attribute to e-mail configuration model

DDL:

    ALTER TABLE email_configs ADD COLUMN contact_address text;
M byceps/services/email/models.py => byceps/services/email/models.py +4 -1
@@ 19,12 19,15 @@ class EmailConfig(db.Model):
    id = db.Column(db.UnicodeText, primary_key=True)
    sender_address = db.Column(db.UnicodeText, nullable=False)
    sender_name = db.Column(db.UnicodeText, nullable=True)
    contact_address = db.Column(db.UnicodeText, nullable=True)

    def __init__(self, config_id: str, sender_address: str,
                 *, sender_name: Optional[str]=None) -> None:
                 *, sender_name: Optional[str]=None,
                 contact_address: Optional[str]=None) -> None:
        self.id = config_id
        self.sender_address = sender_address
        self.sender_name = sender_name
        self.contact_address = contact_address

    def __repr__(self) -> str:
        return ReprBuilder(self) \

M byceps/services/email/service.py => byceps/services/email/service.py +4 -1
@@ 43,7 43,8 @@ def get_config(config_id: str) -> Sender:


def set_config(config_id: str, sender_address: str,
               *, sender_name: Optional[str]=None) -> None:
               *, sender_name: Optional[str]=None,
               contact_address: Optional[str]=None) -> None:
    """Add or update configuration for that ID."""
    table = DbEmailConfig.__table__
    identifier = {


@@ 52,6 53,7 @@ def set_config(config_id: str, sender_address: str,
    }
    replacement = {
        'sender_name': sender_name,
        'contact_address': contact_address,
    }

    upsert(table, identifier, replacement)


@@ 87,4 89,5 @@ def _db_entity_to_config(config: DbEmailConfig) -> EmailConfig:
    return EmailConfig(
        config.id,
        sender,
        config.contact_address,
    )

M byceps/services/email/transfer/models.py => byceps/services/email/transfer/models.py +1 -0
@@ 27,6 27,7 @@ class Sender:
class EmailConfig:
    id: str
    sender: Sender
    contact_address: str


@attrs(auto_attribs=True, frozen=True, slots=True)