refactor kontor-spring
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, AnyStr, Dict
|
||||
from typing import Any, Dict
|
||||
|
||||
from sqlalchemy import Column, ForeignKey, Integer, String, Boolean
|
||||
from sqlalchemy.orm import relationship, mapped_column, Mapped
|
||||
@@ -19,16 +19,16 @@ class Profile(Base, BaseMixin):
|
||||
tokens = relationship("Token")
|
||||
|
||||
def get_full_name(self) -> str:
|
||||
full_name = ""
|
||||
full_name: str = ""
|
||||
if self.first_name is not None:
|
||||
full_name += self.first_name
|
||||
full_name += str(self.first_name)
|
||||
if self.last_name is not None:
|
||||
if len(full_name) > 0:
|
||||
full_name += " "
|
||||
full_name += self.last_name
|
||||
full_name += str(self.last_name)
|
||||
return full_name
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
def import_dict(self, import_data: Dict[str, Any]):
|
||||
self.id = import_data['id']
|
||||
self.created_date = import_data['created_date']
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
@@ -40,8 +40,8 @@ class Profile(Base, BaseMixin):
|
||||
self.password = import_data['password']
|
||||
self.enabled = import_data['enabled']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
def export_dict(self) -> Dict[str, Any]:
|
||||
item: Dict[str, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
@@ -64,7 +64,7 @@ class Token(Base, BaseMixin):
|
||||
profile_id = Column(String, ForeignKey("profile.id"), nullable=False)
|
||||
profile = relationship("Profile", back_populates="tokens")
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
def import_dict(self, import_data: Dict[str, Any]):
|
||||
self.id = import_data['id']
|
||||
self.created_date = import_data['created_date']
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
@@ -75,8 +75,8 @@ class Token(Base, BaseMixin):
|
||||
self.enabled = import_data['enabled']
|
||||
self.profile_id = import_data['profile_id']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
def export_dict(self) -> Dict[str, Any]:
|
||||
item: Dict[str, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
@@ -87,22 +87,22 @@ class Token(Base, BaseMixin):
|
||||
item['enabled'] = self.enabled
|
||||
item['profile_id'] = self.profile_id
|
||||
return item
|
||||
|
||||
|
||||
|
||||
class Permission(Base, BaseMixin):
|
||||
__tablename__ = "permission"
|
||||
name = Column(String, nullable=False)
|
||||
assignments = relationship("Assignment")
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
def import_dict(self, import_data: Dict[str, Any]):
|
||||
self.id = import_data['id']
|
||||
self.created_date = import_data['created_date']
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
self.version = import_data['version']
|
||||
self.name = import_data['name']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
def export_dict(self) -> Dict[str, Any]:
|
||||
item: Dict[str, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
@@ -117,7 +117,7 @@ class Assignment(Base, BaseMixin):
|
||||
permission_id = Column(String, ForeignKey("permission.id"), nullable=False)
|
||||
permission = relationship("Permission", back_populates="assignments")
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
def import_dict(self, import_data: Dict[str, Any]):
|
||||
self.id = import_data['id']
|
||||
self.created_date = import_data['created_date']
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
@@ -125,8 +125,8 @@ class Assignment(Base, BaseMixin):
|
||||
self.profile_id = import_data['profile_id']
|
||||
self.permission_id = import_data['permission_id']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
def export_dict(self) -> Dict[str, Any]:
|
||||
item: Dict[str, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
@@ -145,7 +145,7 @@ class MailAccount(Base, BaseMixin):
|
||||
password = Column(String)
|
||||
start_tls = Column(Boolean)
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
def import_dict(self, import_data: Dict[str, Any]):
|
||||
self.id = import_data['id']
|
||||
self.created_date = import_data['created_date']
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
@@ -157,8 +157,8 @@ class MailAccount(Base, BaseMixin):
|
||||
self.password = import_data['password']
|
||||
self.start_tls = import_data['start_tls']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
def export_dict(self) -> Dict[str, Any]:
|
||||
item: Dict[str, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
@@ -180,7 +180,7 @@ class Mail(Base, BaseMixin):
|
||||
sent_date: Mapped[datetime] = mapped_column()
|
||||
received_date: Mapped[datetime] = mapped_column()
|
||||
|
||||
def import_dict(self, import_data: Dict[AnyStr, Any]):
|
||||
def import_dict(self, import_data: Dict[str, Any]):
|
||||
self.id = import_data['id']
|
||||
self.created_date = import_data['created_date']
|
||||
self.last_modified_date = import_data['last_modified_date']
|
||||
@@ -191,8 +191,8 @@ class Mail(Base, BaseMixin):
|
||||
self.sent_date = import_data['sent_date']
|
||||
self.received_date = import_data['received_date']
|
||||
|
||||
def export_dict(self) -> Dict[AnyStr, Any]:
|
||||
item: Dict[AnyStr, Any] = {}
|
||||
def export_dict(self) -> Dict[str, Any]:
|
||||
item: Dict[str, Any] = {}
|
||||
item['id'] = self.id
|
||||
item['created_date'] = str(self.created_date)
|
||||
item['last_modified_date'] = str(self.last_modified_date)
|
||||
|
||||
Reference in New Issue
Block a user