add one to many relationships and various updates surrounding this
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
# Lucas Mathews - Fontys Student ID: 5023572
|
||||
# Banking System Client Class
|
||||
|
||||
from sqlalchemy import Column, String, Boolean
|
||||
from sqlalchemy import Column, String, Boolean, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
|
||||
from class_base import Base
|
||||
|
||||
@@ -18,7 +20,7 @@ class Client(Base):
|
||||
notes = Column("notes", String)
|
||||
enabled = Column("enabled", Boolean)
|
||||
administrator = Column("administrator", Boolean)
|
||||
accounts = Column("accounts", String)
|
||||
accounts = relationship("Account", backref="client")
|
||||
|
||||
def __init__(self, client_id, name, birthdate, opening_timestamp, address, phone_number, email, hash, notes, enabled, administrator, accounts):
|
||||
self.client_id = client_id
|
||||
@@ -32,7 +34,7 @@ class Client(Base):
|
||||
self.notes = notes
|
||||
self.enabled = enabled
|
||||
self.administrator = administrator
|
||||
self.accounts = accounts
|
||||
self.accounts = accounts if accounts is not None else []
|
||||
|
||||
def __repr__(self):
|
||||
return f"Client ID: {self.client_id}, Name: {self.name}, Birthdate: {self.birthdate}, Address: {self.address}, Phone Number: {self.phone_number}, Email: {self.email}, Enabled: {self.enabled}, Accounts: {self.accounts}"
|
||||
Reference in New Issue
Block a user