mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-22 11:59:33 +00:00
- Use the IntergrityError exception instead of a complex query to ignore an already existing alias. - When retrieving existing aliases, use explicit list of columns instead of * so that schema updates adding columns won't fail the code using the row results. - Use terminology used by post fix. "name" for the name of the alias. "value" for the mapping. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
13 lines
243 B
Python
13 lines
243 B
Python
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)
|