feat: added contact collection in the artist

This commit is contained in:
Hellow 2023-09-12 18:21:30 +02:00
parent 06f5411c47
commit 6e82c1e5cb
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,37 @@
from typing import Optional, List, Tuple
from ..utils.enums.contact import ContactMethod
from .parents import DatabaseObject
class Contact(DatabaseObject):
COLLECTION_ATTRIBUTES = tuple()
SIMPLE_ATTRIBUTES = {
"contact_method": None,
"value": None,
}
@property
def indexing_values(self) -> List[Tuple[str, object]]:
return [
('id', self.id),
('value', self.value),
]
def __init__(self, contact_method: ContactMethod, value: str) -> None:
self.contact_method: ContactMethod = contact_method
self.value: str = value
@classmethod
def match_url(cls, url: str) -> Optional["Contact"]:
url = url.strip()
if url.startswith("mailto:"):
return cls(ContactMethod.EMAIL, url.replace("mailto:", "", 1))
if url.startswith("tel:"):
return cls(ContactMethod.PHONE, url.replace("tel:", "", 1))
if url.startswith("fax:"):
return cls(ContactMethod.FAX, url.replace("fax:", "", 1))

View File

@ -0,0 +1,7 @@
from enum import Enum
class ContactMethod(Enum):
EMAIL = "email"
PHONE = "phone"
FAX = "fax"