Fixed Notes view on Accounts window

This commit is contained in:
Lucas Mathews
2024-06-02 22:43:40 +02:00
parent fd2622ac2c
commit aa865e008d
6 changed files with 22 additions and 8 deletions

View File

@@ -863,6 +863,8 @@ components:
balance:
type: integer
format: float
notes:
type: string
example:
account_id: "63b6e8e8"
client_id: "896d4ed8"
@@ -870,6 +872,7 @@ components:
opening_timestamp: "17-04-2022 16:21:12"
account_type: Savings Account"
balance: 2314.23
notes: "This account is for savings"
Transaction:
type: object
properties:

View File

@@ -21,7 +21,7 @@ notes_text = None
if len(sys.argv) > 3: # Check if the account description is provided as a command line argument
account_id = sys.argv[1]
account_description = sys.argv[3] # This is passed so that the window can be titled appopriately
account_description = sys.argv[3] # This is passed so that the window can be titled appropriately
else:
messagebox.showerror("Error", "Account ID and description were not provided by the server.")
sys.exit(1)
@@ -66,7 +66,11 @@ def display_account_info(account_id):
label_value = customtkinter.CTkLabel(info_frame, text=value, font=("Helvetica", 14))
label_key.grid(row=0, column=i*2, sticky='w', padx=10)
label_value.grid(row=0, column=i*2+1, sticky='w', padx=10)
global notes_text
notes = get_account(account_id).get('data', {}).get('notes', '')
print(f"Account: {account}") # Debugging
print(f"Account: {notes}") # Debugging
notes_text.configure(text=account.get('notes', ''))
def on_transaction_double_click(event):
@@ -183,11 +187,15 @@ else:
welcome_label = customtkinter.CTkLabel(root, text=f"Transactions for: {account_description}", font=("Helvetica", 24))
welcome_label.pack(pady=10)
# Display account information
info_frame = customtkinter.CTkFrame(root)
info_frame.pack(fill=tk.X)
# Create the notes label and text box
notes_label = customtkinter.CTkLabel(root, text="Notes:", font=("Helvetica", 14))
notes_label.pack(pady=10)
notes_text = customtkinter.CTkLabel(root, height=4, width=50, wraplength=400) # Use CTkLabel instead of CTkTextbox
notes_text.pack(pady=10, fill=tk.BOTH, expand=True) # Add fill and expand options
notes_label = customtkinter.CTkLabel(info_frame, text="Notes:", font=("Helvetica", 14))
notes_label.grid(row=1, column=0, padx=10, pady=5, sticky='w')
notes_text = customtkinter.CTkLabel(info_frame, height=4, width=50, wraplength=400) # Use CTkLabel instead of CTkTextbox
notes_text.grid(row=1, column=1, padx=10, pady=5, sticky='ew') # Add fill and expand options
# Display account information
info_frame = customtkinter.CTkFrame(root)

View File

@@ -1 +1 @@
{"session_cookie": {"session": "rVrt6XfG-HNcgZwJHJGmwEg8boBPPRljoCFcrRfQ-ss"}, "client_id": "9755c18f"}
{"session_cookie": {"session": "zEUX5N4IojE58Mg8yfVC0XiNC-IcnHaZcBJRMRH9J94"}, "client_id": "9755c18f"}

BIN
bank.db

Binary file not shown.

View File

@@ -39,4 +39,5 @@ class Account(Base):
"open_timestamp": self.open_timestamp,
"account_type": self.account_type,
"balance": self.balance,
"notes": self.notes
}

View File

@@ -160,6 +160,8 @@ def generate_otp(client_id: str):
try:
send_email(email, "Luxbank One Time Password", f"Your one-time password is: {password}")
otps[client_id] = (password, time.time()) # Store the OTP and the current time
log_event(f"OTP Code {password} emailed to {email}")
print(f"OTP Code {password} emailed to {email}")
return format_response(True, "OTP generated and sent successfully."), 200
except EmailSendingError as e:
log_event(f"Error sending email: {str(e)}")
@@ -252,7 +254,6 @@ def get_accounts(client_id: str):
@login_required
def get_account(account_id:str):
"""Returns a specific account in the database. If the account is not found, returns an error message."""
print(account_id)
current_client_id, is_admin = get_current_client()
account_owner = session.query(Account).filter_by(account_id=account_id).one_or_none().client_id
if not is_admin and account_owner != current_client_id:
@@ -260,6 +261,7 @@ def get_account(account_id:str):
account = session.query(Account).filter_by(account_id=account_id).one_or_none()
for account in session.query(Account).all():
if account.account_id == account_id:
print(account.to_dict())
return format_response(True, "", account.to_dict()), 200
return format_response(False, "Account not found."), 404