mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
email_server: aliases: Refactor for simpler organization
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
f2279ab58a
commit
31b438e5fd
@ -4,10 +4,20 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import pwd
|
import pwd
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
from dataclasses import InitVar, dataclass, field
|
||||||
|
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
|
|
||||||
from . import models
|
|
||||||
|
@dataclass
|
||||||
|
class Alias:
|
||||||
|
value: int
|
||||||
|
name: str
|
||||||
|
enabled: bool = field(init=False)
|
||||||
|
status: InitVar[int]
|
||||||
|
|
||||||
|
def __post_init__(self, status):
|
||||||
|
self.enabled = (status != 0)
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
@ -29,7 +39,7 @@ def get(uid):
|
|||||||
query = 'SELECT name, value, status FROM alias WHERE value=?'
|
query = 'SELECT name, value, status FROM alias WHERE value=?'
|
||||||
with _get_cursor() as cursor:
|
with _get_cursor() as cursor:
|
||||||
rows = cursor.execute(query, (uid, ))
|
rows = cursor.execute(query, (uid, ))
|
||||||
return [models.Alias(**row) for row in rows]
|
return [Alias(**row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
def exists(name):
|
def exists(name):
|
||||||
@ -1,12 +0,0 @@
|
|||||||
from dataclasses import InitVar, dataclass, field
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Alias:
|
|
||||||
value: int
|
|
||||||
name: str
|
|
||||||
enabled: bool = field(init=False)
|
|
||||||
status: InitVar[int]
|
|
||||||
|
|
||||||
def __post_init__(self, status):
|
|
||||||
self.enabled = (status != 0)
|
|
||||||
Loading…
x
Reference in New Issue
Block a user