~sircmpwn/names.sr.ht

7d85145ed46ad9647cb8abd17b9d32717ec4644a — Drew DeVault 1 year, 9 months ago 4befa4e
Refine database schema throughout
M names/templates/dashboard.html => names/templates/dashboard.html +3 -0
@@ 11,6 11,9 @@
    <a href="{{url_for('.create_GET')}}" class="btn btn-primary btn-block">
      Add a domain {{icon("caret-right")}}
    </a>
    <a href="#" class="btn btn-default btn-block">
      Manage contacts {{icon("caret-right")}}
    </a>
  </div>
  <div class="col-md-8">
    <div class="alert alert-info">

M names/types/__init__.py => names/types/__init__.py +14 -17
@@ 3,7 3,7 @@ from enum import IntFlag, auto
from srht.database import Base
from srht.flagtype import FlagType
from srht.oauth import ExternalUserMixin
from names.types.contact import DomainContact, ContactType
from names.types.contact import DomainContact
from names.types.gtld_specific import *

class ExtendedDomainData(IntFlag):


@@ 62,22 62,19 @@ class User(Base, ExternalUserMixin):
    extra_info = sa.Column(FlagType(ExtendedDomainData),
            nullable=False, server_default='0')

    owner_contact = sa.orm.relationship("DomainContact",
            primaryjoin=sa.and_(
                ExternalUserMixin.id == DomainContact.user_id,
                DomainContact._contact_type == ContactType.owner.value))
    default_owner_id = sa.Column(sa.Integer, sa.ForeignKey("domain_contact.id"))
    default_owner = sa.orm.relationship("DomainContact",
            foreign_keys=[default_owner_id])

    admin_contact = sa.orm.relationship("DomainContact",
            primaryjoin=sa.and_(
                ExternalUserMixin.id == DomainContact.user_id,
                DomainContact._contact_type == ContactType.admin.value))
    default_admin_id = sa.Column(sa.Integer, sa.ForeignKey("domain_contact.id"))
    default_admin = sa.orm.relationship("DomainContact",
            foreign_keys=[default_admin_id])

    billing_contact = sa.orm.relationship("DomainContact",
            primaryjoin=sa.and_(
                ExternalUserMixin.id == DomainContact.user_id,
                DomainContact._contact_type == ContactType.billing.value))
    default_billing_id = sa.Column(sa.Integer,
            sa.ForeignKey("domain_contact.id"))
    default_billing = sa.orm.relationship("DomainContact",
            foreign_keys=[default_billing_id])

    tech_contact = sa.orm.relationship("DomainContact",
            primaryjoin=sa.and_(
                ExternalUserMixin.id == DomainContact.user_id,
                DomainContact._contact_type == ContactType.tech.value))
    default_tech_id = sa.Column(sa.Integer, sa.ForeignKey("domain_contact.id"))
    default_tech = sa.orm.relationship("DomainContact",
            foreign_keys=[default_tech_id])

M names/types/contact.py => names/types/contact.py +1 -15
@@ 2,27 2,13 @@ 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
    note = sa.Column(sa.Unicode)

    # https://domains.opensrs.guide/docs/domain-contacts
    first_name = sa.Column(sa.Unicode(64), nullable=False)

M names/types/domain.py => names/types/domain.py +1 -1
@@ 15,7 15,7 @@ class Domain(Base):
    created = sa.Column(sa.DateTime, nullable=False)
    updated = sa.Column(sa.DateTime, nullable=False)
    name = sa.Column(sa.String(256), nullable=False)
    status = sa.Column(sau.ChoiceType(DomainStatus, impl=sa.String),
    status = sa.Column(sau.ChoiceType(DomainStatus, impl=sa.Unicode),
            nullable=False, server_default='external')

    ns1 = sa.Column(sa.String)

M names/types/gtld_specific.py => names/types/gtld_specific.py +16 -21
@@ 27,7 27,7 @@ class RegistrantType(enum.Enum):

class RegistrantTypeMixin:
    registrant_type = sa.Column(
            sau.ChoiceType(RegistrantType, impl=sa.Unicode), nullable=False)
            sau.ChoiceType(RegistrantType), nullable=False)
    """The entity type of registrant."""

class IdCardNumberMixin:


@@ 164,8 164,7 @@ class AuExtraData(Base, ExtraDataMixin):
    number, the registration will fail.
    """

    eligibility_id_type = sa.Column(
            sau.ChoiceType(AuEligibilityIdType, impl=sa.Unicode))
    eligibility_id_type = sa.Column(sau.ChoiceType(AuEligibilityIdType))
    """
    The type of eligibility ID specified.
    """


@@ 173,12 172,11 @@ class AuExtraData(Base, ExtraDataMixin):
    eligibility_name = sa.Column(sa.Unicode)
    """The name on the eligibility ID document."""

    eligibility_type = sa.Column(sau.ChoiceType(
        AuEligibilityType, impl=sa.Unicode), nullable=False)
    eligibility_type = sa.Column(
            sau.ChoiceType(AuEligibilityType), nullable=False)
    """The reason that the registrant is eligible for the domain."""

    policy_reason = sa.Column(sau.ChoiceType(
        AuPolicyReason, impl=sa.Integer), nullable=False)
    policy_reason = sa.Column(sau.ChoiceType(AuPolicyReason), nullable=False)
    """The reason this name is applicable to the registrant."""

    registrant_id  = sa.Column(sa.Unicode)


@@ 189,8 187,8 @@ class AuExtraData(Base, ExtraDataMixin):
    number, the registration will fail.
    """

    registrant_id_type = sa.Column(sau.ChoiceType(
        AuRegistrantIdType, impl=sa.Unicode), nullable=False)
    registrant_id_type = sa.Column(
            sau.ChoiceType(AuRegistrantIdType), nullable=False)

    registrant_name = sa.Column(sa.Unicode)
    """


@@ 260,8 258,7 @@ class EsExtraData(Base, ExtraDataMixin):
    """
    __tablename__ = "extra_data_es"

    es_id_type = sa.Column(sau.ChoiceType(
        EsIdType, impl=sa.Unicode), nullable=False)
    es_id_type = sa.Column(sau.ChoiceType(EsIdType), nullable=False)
    """ID Type"""

    es_id_number = sa.Column(sa.Unicode) # required if NIE or NIF


@@ 302,8 299,8 @@ class EuExtraData(Base, ExtraDataMixin):
    """Registration of .eu domains is limited to EU citizens only."""
    __tablename__ = "extra_data_eu"

    country_of_citizenship = sa.Column(sau.ChoiceType(
        EuCitizenship, impl=sa.Unicode), nullable=False)
    country_of_citizenship = sa.Column(
            sau.ChoiceType(EuCitizenship), nullable=False)
    """Country of citizenship"""

### .de


@@ 397,7 394,7 @@ class ItEntityType(enum.Enum):

class ItExtraData(Base, ExtraDataMixin):
    __tablename__ = "extra_data_it"
    entity_type = sa.Column(sau.ChoiceType(ItEntityType, impl=sa.Integer))
    entity_type = sa.Column(sau.ChoiceType(ItEntityType))
    """The legal entity type of registrant"""

    nationality_code = sa.Column(sa.Unicode(2))


@@ 730,7 727,7 @@ class LawExtraData(Base, ExtraDataMixin):
    """Qualified Lawyer's Accreditation Body"""

    qli_jurisdiction_country = sa.Column(
            sau.ChoiceType(LawJurisdictionCountry, impl=sa.Unicode),
            sau.ChoiceType(LawJurisdictionCountry),
            nullable=False)
    """Accreditation Jurisdiction Country"""



@@ 925,8 922,8 @@ class UkExtraData(Base,
        RegistrationNumberMixin):
    __tablename__ = "extra_data_uk"

    registrant_type = sa.Column(sau.ChoiceType(
        UkRegistrantType, impl=sa.Unicode), nullable=False)
    registrant_type = sa.Column(
            sau.ChoiceType(UkRegistrantType), nullable=False)
    """Registrant type"""

    trading_name = sa.Column(sa.Unicode)


@@ 964,12 961,10 @@ class UsNexusCategory(enum.Enum):
class UsExtraData(Base, ExtraDataMixin):
    __tablename__ = "extra_data_us"

    app_purpose = sa.Column(sau.ChoiceType(
        UsAppPurpose, impl=sa.Unicode), nullable=False)
    app_purpose = sa.Column(sau.ChoiceType(UsAppPurpose), nullable=False)
    """A description of the domain's application purpose"""

    category = sa.Column(sau.ChoiceType(
        UsNexusCategory, impl=sa.Unicode), nullable=False)
    category = sa.Column(sau.ChoiceType(UsNexusCategory), nullable=False)
    """A description of the domain's nexus category"""

    validator = sa.Column(sau.CountryType) # required for C31 or C32