Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: William Moreno Reyes CP|MBA <wmoreno@bmogroup.solutions>
  • Loading branch information
williamjmorenor committed Aug 11, 2024
1 parent b226197 commit 4e6007b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
45 changes: 33 additions & 12 deletions cacao_accounting_desktop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from flaskwebgui import FlaskUI
from PIL import Image


if TYPE_CHECKING:
from flask import Flask

Expand Down Expand Up @@ -138,6 +139,9 @@ def __init__(self, *args, **kwargs):
self.npswd = customtkinter.CTkEntry(self, placeholder_text="Clave de Acceso", show="*")
self.npswd.grid(row=6)

self.npswd2 = customtkinter.CTkEntry(self, placeholder_text="Confirmar Clave", show="*")
self.npswd2.grid(row=7)

self.create = customtkinter.CTkButton(
self,
corner_radius=20,
Expand All @@ -150,12 +154,17 @@ def __init__(self, *args, **kwargs):
anchor="w",
command=self.create_db,
)
self.create.grid(row=7)
self.create.grid(row=8)

def create_db(self):
self.DATABASE_FILE = Path(os.path.join(APP_DATA_DIR, self.dbname.get()))
self.DATABASE_URI = "sqlite:///" + str(self.DATABASE_FILE)

from cacao_accounting.logs import log

log.warning(self.DATABASE_FILE)
log.warning(self.DATABASE_URI)

self.app = create_app(
{
"SECRET_KEY": get_secret_key(),
Expand All @@ -165,22 +174,34 @@ def create_db(self):

self.new_user = self.nuser.get()
self.new_passwd = self.npswd.get()
self.new_passwd2 = self.npswd2.get()
self.checkpw = self.new_passwd == self.new_passwd2

try:
from cacao_accounting.database.helpers import inicia_base_de_datos

inicia_base_de_datos(app=self.app, user=self.new_user, passwd=self.new_passwd)
self.message = CTkMessagebox(
title="Confirmación",
icon="check",
message="Base de datos creada correctamente.",
)
except:
if self.checkpw is not True:
self.message = CTkMessagebox(
title="Error",
icon="cancel",
message="Hubo un error al crear la base de datos.",
message="Las contraseñas no coinciden.",
)

else:

try:
from cacao_accounting.database.helpers import inicia_base_de_datos

inicia_base_de_datos(app=self.app, user=self.new_user, passwd=self.new_passwd, with_examples=False)
self.message = CTkMessagebox(
title="Confirmación",
icon="check",
message="Base de datos creada correctamente.",
)
except:
self.message = CTkMessagebox(
title="Error",
icon="cancel",
message="Hubo un error al crear la base de datos.",
)

self.withdraw()


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "cacao-accounting-desktop"
description = "Cacao Accounting Desktop App."
readme = "README.md"
requires-python = ">=3.8"
version="2024.08.07"
version="2024.08.11"
authors = [
{name = "BMO Soluciones", email = "development@bmogroup.solutions"},
]
Expand Down

0 comments on commit 4e6007b

Please sign in to comment.