wip
This commit is contained in:
26
app/alchemy/base.plantuml
Normal file
26
app/alchemy/base.plantuml
Normal file
@@ -0,0 +1,26 @@
|
||||
@startuml
|
||||
|
||||
|
||||
top to bottom direction
|
||||
skinparam linetype ortho
|
||||
|
||||
abstract Base {
|
||||
id\t\t\t\tInteger\t\t<<Primary>> {field}
|
||||
# __tablename__\tto_snake_case(__name__) {field}
|
||||
}
|
||||
'abstract DeclarativeBase {
|
||||
' + registry
|
||||
' + metadata
|
||||
' # __name__
|
||||
' # __mapper__
|
||||
' # __table__
|
||||
' # __tablename__
|
||||
' # __mapper_args__
|
||||
' # __table_args__
|
||||
' - _sa_registry
|
||||
' - _sa_inspect_type()
|
||||
' - _sa_inspect_instance()
|
||||
'}
|
||||
'
|
||||
'DeclarativeBase <|-- Base
|
||||
@enduml
|
||||
27
app/alchemy/contact.plantuml
Normal file
27
app/alchemy/contact.plantuml
Normal file
@@ -0,0 +1,27 @@
|
||||
@startuml
|
||||
|
||||
'!include base.plantuml
|
||||
!include status.plantuml
|
||||
!include user.plantuml
|
||||
|
||||
skinparam linetype polyline
|
||||
|
||||
|
||||
class Contact {
|
||||
{field} + code\tString(80)\t<<Unique>>
|
||||
{field} + address\tString(255) | None
|
||||
{field} + notes\tText | None
|
||||
}
|
||||
|
||||
abstract ContactForeignKey {
|
||||
contact_id\tContact.id {field}
|
||||
+ contact\t\tContact {field}
|
||||
}
|
||||
|
||||
|
||||
'Base <|--Contact
|
||||
StatusForeignKey <|-[#blue]- Contact
|
||||
Versioned <|-[#blue]- Contact
|
||||
Contact *-- ContactForeignKey
|
||||
|
||||
@enduml
|
||||
25
app/alchemy/contact.puml
Normal file
25
app/alchemy/contact.puml
Normal file
@@ -0,0 +1,25 @@
|
||||
@startuml
|
||||
|
||||
'!include base.plantuml
|
||||
!include status.puml
|
||||
!include user.puml
|
||||
|
||||
skinparam linetype polyline
|
||||
|
||||
entity contact {
|
||||
* id\t\t\tint
|
||||
--
|
||||
* code\t\tvarchar(80)\t<<UK>>
|
||||
address\t\tvarchar(255)
|
||||
notes\t\ttext
|
||||
status_id\t\tvarchar(3)\t<<FK>>
|
||||
* _created__\tdatetime
|
||||
_updated__\tdatetime
|
||||
_user__id\t\tint\t\t\t<<FK>>
|
||||
}
|
||||
|
||||
status --{ contact : status_id
|
||||
user ..{ contact : _user__id
|
||||
|
||||
|
||||
@enduml
|
||||
@@ -13,7 +13,7 @@ class Contact(StatusForeignKey, Versioned, Base):
|
||||
"""Contact"""
|
||||
|
||||
code: Mapped[str] = mapped_column(String(80), unique=True)
|
||||
address: Mapped[str | None] = mapped_column(String(253))
|
||||
address: Mapped[str | None] = mapped_column(String(255))
|
||||
notes: Mapped[str | None] = mapped_column(Text)
|
||||
|
||||
|
||||
|
||||
72
app/alchemy/location.plantuml
Normal file
72
app/alchemy/location.plantuml
Normal file
@@ -0,0 +1,72 @@
|
||||
@startuml
|
||||
|
||||
'!include base.plantuml
|
||||
!include status.plantuml
|
||||
!include contact.plantuml
|
||||
|
||||
skinparam linetype polyline
|
||||
|
||||
|
||||
class Country {
|
||||
{field} + code\t\tString(2)\t\t<<Unique>>
|
||||
{field} + name\t\tString(80)
|
||||
{field} + notes\t\tText | None
|
||||
+ __repr__()\t\tstr
|
||||
}
|
||||
|
||||
abstract CountryForeignKey {
|
||||
country_id\tCountry.id {field}
|
||||
+ country\t\tCountry {field}
|
||||
}
|
||||
|
||||
|
||||
class LocationCode {
|
||||
{field} + code\t\tString(8)\t\t<<Unique>>
|
||||
{field} + description\tString(80)
|
||||
{field} + notes\t\tText | None
|
||||
+ __repr__()\t\tstr
|
||||
}
|
||||
|
||||
abstract LocationCodeForeignKey {
|
||||
location_code_id\tLocationCode.id
|
||||
+ location_code\t\tLocationCode
|
||||
}
|
||||
|
||||
|
||||
class Location {
|
||||
{field} + code\t\tString(30)
|
||||
{field} + description\tString(80)
|
||||
{field} + notes\t\tText | None
|
||||
{field} <<Unique>>\n\tlocation_code_id\n\tcode
|
||||
+ __repr__()\t\tstr
|
||||
}
|
||||
|
||||
abstract LocationForeignKey {
|
||||
location_id\tLocation.id
|
||||
+ location\t\tLocation
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Versioned <|-[#blue]- Country
|
||||
StatusForeignKey <|-[#blue]- Country
|
||||
Country *-- CountryForeignKey
|
||||
|
||||
|
||||
Versioned <|-[#blue]- LocationCode
|
||||
StatusForeignKey <|-[#blue]- LocationCode
|
||||
LocationCode *-- LocationCodeForeignKey
|
||||
CountryForeignKey <|-[#blue]- LocationCode
|
||||
ContactForeignKey o.. LocationCode
|
||||
|
||||
|
||||
Versioned <|-[#blue]- Location
|
||||
StatusForeignKey <|-[#blue]- Location
|
||||
Location *-- LocationForeignKey
|
||||
LocationCodeForeignKey <|-[#blue]- Location
|
||||
ContactForeignKey o.. Location
|
||||
|
||||
@enduml
|
||||
66
app/alchemy/location.puml
Normal file
66
app/alchemy/location.puml
Normal file
@@ -0,0 +1,66 @@
|
||||
@startuml
|
||||
|
||||
'!include base.plantuml
|
||||
!include status.puml
|
||||
!include contact.puml
|
||||
|
||||
skinparam linetype polyline
|
||||
|
||||
|
||||
entity country {
|
||||
* id\t\t\tint
|
||||
--
|
||||
* code\t\tvarchar(2)\t<<UK>>
|
||||
name\t\tvarchar(80)
|
||||
notes\t\ttext
|
||||
status_id\t\tvarchar(3)\t<<FK>>
|
||||
* _created__\tdatetime
|
||||
_updated__\tdatetime
|
||||
_user__id\t\tint\t\t\t<<FK>>
|
||||
}
|
||||
|
||||
|
||||
|
||||
entity location_code {
|
||||
* id\t\t\tint
|
||||
--
|
||||
* code\t\tvarchar(8)\t<<UK>>
|
||||
description\tvarchar(80)
|
||||
notes\t\ttext
|
||||
* country_id\tint\t\t\t<<FK>>
|
||||
contact_id\tint\t\t\t<<FK>>
|
||||
status_id\t\tvarchar(3)\t<<FK>>
|
||||
* _created__\tdatetime
|
||||
_updated__\tdatetime
|
||||
_user__id\t\tint\t\t\t<<FK>>
|
||||
}
|
||||
|
||||
|
||||
entity location {
|
||||
* id\t\t\t\tint
|
||||
.. <<UK>> ..
|
||||
* location_code_id\tint\t\t\t<<FK>>
|
||||
* code\t\t\tvarchar(30)
|
||||
--
|
||||
description\t\tvarchar(80)
|
||||
notes\t\t\ttext
|
||||
contact_id\tint\t\t\t<<FK>>
|
||||
status_id\t\t\tvarchar(3)\t<<FK>>
|
||||
* _created__\t\tdatetime
|
||||
_updated__\t\tdatetime
|
||||
_user__id\t\t\tint\t\t\t<<FK>>
|
||||
}
|
||||
|
||||
contact ..{ location : contact_id
|
||||
contact ..{ location_code : contact_id
|
||||
country --{ location_code : country_id
|
||||
location_code --{ location : location_code_id
|
||||
status --{ country : status_id
|
||||
status --{ location : status_id
|
||||
status --{ location_code : status_id
|
||||
user ..{ country : _user__id
|
||||
user ..{ location : _user__id
|
||||
user ..{ location_code : _user__id
|
||||
|
||||
|
||||
@enduml
|
||||
1
app/alchemy/location.svg
Normal file
1
app/alchemy/location.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 36 KiB |
20
app/alchemy/status.plantuml
Normal file
20
app/alchemy/status.plantuml
Normal file
@@ -0,0 +1,20 @@
|
||||
@startuml
|
||||
|
||||
'!include base.plantuml
|
||||
|
||||
|
||||
class Status {
|
||||
id\t\tString(3)\t\t<<Primary>> {field}
|
||||
+ name\tString(30)\t<<Unique>> {field}
|
||||
}
|
||||
|
||||
'Base <|-- Status
|
||||
|
||||
abstract StatusForeignKey {
|
||||
status_id\t\tStatus.id {field}
|
||||
+ status\t\tStatus {field}
|
||||
}
|
||||
|
||||
Status *-- StatusForeignKey
|
||||
|
||||
@enduml
|
||||
9
app/alchemy/status.puml
Normal file
9
app/alchemy/status.puml
Normal file
@@ -0,0 +1,9 @@
|
||||
@startuml
|
||||
|
||||
entity status {
|
||||
* id\t\tvarchar(3)
|
||||
--
|
||||
* name\tvarchar(30)\t<<UK>>
|
||||
}
|
||||
|
||||
@enduml
|
||||
31
app/alchemy/user.plantuml
Normal file
31
app/alchemy/user.plantuml
Normal file
@@ -0,0 +1,31 @@
|
||||
@startuml
|
||||
|
||||
'!include base.plantuml
|
||||
!include status.plantuml
|
||||
skinparam linetype ortho
|
||||
|
||||
|
||||
class User {
|
||||
{field} + code\t\tString(253)\t<<Unique>>
|
||||
{field} + name\t\tString(253)
|
||||
{field} + password\tString(255) | None
|
||||
{field} + ldap_name\tString(255) | None
|
||||
{field} + notes\t\tText | None
|
||||
+ __repr__()\t\tstr
|
||||
}
|
||||
|
||||
abstract Versioned {
|
||||
{field} + user__\t\tUser
|
||||
{field} # _created__\tDatetime
|
||||
{field} # _updated__\tDatetime | None
|
||||
{field} _user__id\t\tInteger | None
|
||||
{field} # __versioned__\t= True
|
||||
}
|
||||
|
||||
'Base <|-- User
|
||||
StatusForeignKey <|-[#blue]- User
|
||||
Versioned <|-[#blue]- User
|
||||
User *-- Versioned
|
||||
|
||||
|
||||
@enduml
|
||||
25
app/alchemy/user.puml
Normal file
25
app/alchemy/user.puml
Normal file
@@ -0,0 +1,25 @@
|
||||
@startuml
|
||||
|
||||
|
||||
!include status.puml
|
||||
skinparam linetype polyline
|
||||
|
||||
|
||||
entity user {
|
||||
* id\t\t\tint
|
||||
--
|
||||
* code\t\tvarchar(255)\t<<UK>>
|
||||
* name\t\tvarchar(255)
|
||||
password\tvarchar(255)
|
||||
ldap_name\tvarchar(255)
|
||||
notes\t\ttext
|
||||
status_id\t\tvarchar(3)\t<<FK>>
|
||||
* _created__\tdatetime
|
||||
_updated__\tdatetime
|
||||
_user__id\t\tint\t\t\t<<FK>>
|
||||
}
|
||||
|
||||
status --{ user : status_id
|
||||
user ..{ user : _user__id
|
||||
|
||||
@enduml
|
||||
@@ -61,15 +61,15 @@ class Versioned:
|
||||
|
||||
# noinspection PyMethodParameters
|
||||
@declared_attr
|
||||
def _user__(cls) -> Mapped["User"]:
|
||||
def user__(cls) -> Mapped["User"]:
|
||||
return relationship()
|
||||
|
||||
|
||||
class User(StatusForeignKey, Versioned, Base):
|
||||
"""User"""
|
||||
|
||||
code: Mapped[str] = mapped_column(String(253), unique=True)
|
||||
name: Mapped[str] = mapped_column(String(253))
|
||||
code: Mapped[str] = mapped_column(String(255), unique=True)
|
||||
name: Mapped[str] = mapped_column(String(255))
|
||||
password: Mapped[str | None] = mapped_column(String(255))
|
||||
ldap_name: Mapped[str | None] = mapped_column(String(255))
|
||||
notes: Mapped[str | None] = mapped_column(Text)
|
||||
@@ -90,10 +90,8 @@ def initialize_user(target, connection, **kwargs):
|
||||
session.commit()
|
||||
for kwargs in (
|
||||
dict(code="CTM", name="Control-M", password=get_password_hash("secret"), notes="user for automation"),
|
||||
dict(code="exde37c8", name="Bernhard Radermacher",
|
||||
password=get_password_hash("secret"),
|
||||
ldap_name="a0061806@kiongroup.com",
|
||||
),
|
||||
dict(code="de31c7", name="Andy Le", ldap_name="a0032514@kiongroup.com"),
|
||||
dict(code="exde37c8", name="Bernhard Radermacher", ldap_name="a0061806@kiongroup.com"),
|
||||
):
|
||||
kwargs.update(dict(status_id='A', _user__id=qsys.id))
|
||||
session.add(User(**kwargs))
|
||||
|
||||
Reference in New Issue
Block a user