aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/styles/base.py
blob: 36d11c7824a7f98faea83d8130968d2c98b9cec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
""""""

from public import public

from mailman_pgp.config import config
from mailman_pgp.database import transaction
from mailman_pgp.model.list import EncryptedMailingList


@public
class EncryptedStyle:
    def apply(self, mailing_list):
        """Creates the encrypted mailing list instance for the list it's
        applied to.
        """
        enc_list = config.db.session.query(EncryptedMailingList).filter_by(
            list_id=mailing_list.list_id).first()
        if enc_list:
            return

        enc_list = EncryptedMailingList(mailing_list)
        with transaction():
            config.db.session.add(enc_list)