~sircmpwn/names.sr.ht

ref: 4befa4e5942b52045dc9ef9bcd3473389db71d61 names.sr.ht/names/types/contact.py -rw-r--r-- 1.6 KiB
4befa4e5Drew DeVault Add tables for remaining TLDs with special reqs 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import enum
import sqlalchemy as sa
from srht.database import Base

class ContactType(enum.Enum):
    owner = "owner"
    admin = "admin"
    billing = "billing"
    tech = "tech"

class DomainContact(Base):
    __tablename__ = 'domain_contact'
    id = sa.Column(sa.Integer, primary_key=True)
    created = sa.Column(sa.DateTime, nullable=False)
    updated = sa.Column(sa.DateTime, nullable=False)
    _contact_type = sa.Column("contact_type", sa.Unicode, nullable=False)
    user_id = sa.Column(sa.Integer, sa.ForeignKey('user.id'), nullable=False)

    @property
    def contact_type(self):
        return ContactType(self._contact_type)

    @contact_type.setter
    def contact_type_set(self, val):
        self._contact_type = val.value

    # https://domains.opensrs.guide/docs/domain-contacts
    first_name = sa.Column(sa.Unicode(64), nullable=False)
    last_name = sa.Column(sa.Unicode(64), nullable=False)
    org_name = sa.Column(sa.Unicode(64), nullable=False)
    address1 = sa.Column(sa.Unicode(64), nullable=False)
    address2 = sa.Column(sa.Unicode(64))
    address3 = sa.Column(sa.Unicode(64))
    city = sa.Column(sa.Unicode(64), nullable=False)
    state = sa.Column(sa.Unicode(32)) # Required if country in [CA, US]
    postal_code = sa.Column(sa.Unicode(16), nullable=False)
    country = sa.Column(sa.Unicode(2), nullable=False)
    phone = sa.Column(sa.Unicode(20), nullable=False)
    fax = sa.Column(sa.Unicode(20))
    email = sa.Column(sa.Unicode(128), nullable=False)
    # Required for only some kinds of domains:
    lang = sa.Column(sa.Unicode(2))
    vat = sa.Column(sa.Unicode(16))