From 22c0da6338af341bc3af2218d359cf5d9d9cf2e3 Mon Sep 17 00:00:00 2001 From: mominur-helios Date: Sat, 5 Apr 2025 20:52:35 +0600 Subject: [PATCH 1/3] Fix codebase and add chart --- apps/__init__.py | 2 +- apps/charts/__init__.py | 12 +++++ apps/charts/routes.py | 13 ++++++ apps/config.py | 4 +- apps/db.sqlite3 | Bin 45056 -> 45056 bytes apps/models.py | 4 ++ templates/authentication/login.html | 33 +++++++------- templates/charts/index.html | 65 +++++++++++++++++++++++++++ templates/dyn_dt/model.html | 6 +-- templates/includes/sidebar.html | 67 ++++++++++++++++++++-------- 10 files changed, 166 insertions(+), 40 deletions(-) create mode 100644 apps/charts/__init__.py create mode 100644 apps/charts/routes.py create mode 100644 templates/charts/index.html diff --git a/apps/__init__.py b/apps/__init__.py index 2a95beb8..943563bc 100644 --- a/apps/__init__.py +++ b/apps/__init__.py @@ -17,7 +17,7 @@ def register_extensions(app): login_manager.init_app(app) def register_blueprints(app): - for module_name in ('authentication', 'home', 'dyn_dt'): + for module_name in ('authentication', 'home', 'dyn_dt', 'charts',): module = import_module('apps.{}.routes'.format(module_name)) app.register_blueprint(module.blueprint) diff --git a/apps/charts/__init__.py b/apps/charts/__init__.py new file mode 100644 index 00000000..66711689 --- /dev/null +++ b/apps/charts/__init__.py @@ -0,0 +1,12 @@ +# -*- encoding: utf-8 -*- +""" +Copyright (c) 2019 - present AppSeed.us +""" + +from flask import Blueprint + +blueprint = Blueprint( + 'charts_blueprint', + __name__, + url_prefix='' +) diff --git a/apps/charts/routes.py b/apps/charts/routes.py new file mode 100644 index 00000000..f9e74da5 --- /dev/null +++ b/apps/charts/routes.py @@ -0,0 +1,13 @@ +# -*- encoding: utf-8 -*- +""" +Copyright (c) 2019 - present AppSeed.us +""" + +from apps.charts import blueprint +from flask import render_template +from apps.models import Product + +@blueprint.route('/charts') +def charts(): + products = [{'name': product.name, 'price': product.price} for product in Product.get_list()] + return render_template('charts/index.html', segment='charts', products=products) \ No newline at end of file diff --git a/apps/config.py b/apps/config.py index 15f9c670..e4079bb2 100644 --- a/apps/config.py +++ b/apps/config.py @@ -29,14 +29,14 @@ class Config(object): # Enable/Disable Github Social Login if GITHUB_ID and GITHUB_SECRET: - SOCIAL_AUTH_GITHUB = True + SOCIAL_AUTH_GITHUB = True GOOGLE_ID = os.getenv('GOOGLE_ID' , None) GOOGLE_SECRET = os.getenv('GOOGLE_SECRET', None) # Enable/Disable Google Social Login if GOOGLE_ID and GOOGLE_SECRET: - SOCIAL_AUTH_GOOGLE = True + SOCIAL_AUTH_GOOGLE = True SQLALCHEMY_TRACK_MODIFICATIONS = False diff --git a/apps/db.sqlite3 b/apps/db.sqlite3 index 0685a65dd4df6599c0fc1ba96a2be60a519f36e7..7fc1bedfdeda81814c1a42fcfa197e4fd07c41ae 100644 GIT binary patch delta 579 zcma)&y=qiJ6vyYzD%?o2V_ddL3~phQB5^*>nVEYVUByz_##S<4R~8KscVn9bUqD z0mK)Ot*y08kmK;#Qc;%qf{0lC8!_@XcTbktTy>p<%m%TFA;n&v*UYE zQg%+*B|D$54t}wvvePfxU((s-gI;DQgq^XI%zm=oozCWh{o4SYoju&R)nSsb@9aI3 zd2#pI!Q)Oz`hD6Ps?m#Q!`4PV?@yxS61O;PaU2M!f!6}Jwa|v^{|MH?KBXmDUpR&_ zj-#6_G(WDR8C^}ln%iN~W+`%(=i}F@m4xd!t`tzCU6~hyKa8yuH^@fu_T66G57Wub HFFT{Z8jqJo delta 73 zcmZp8z|`=7X@WGP&_o$$Mxl)fOZeFs`7bc=U)U_DaEyQQ1$mRrECFx%Cx6rz21-0< b;D5eZFyJo#iW4 diff --git a/apps/models.py b/apps/models.py index 808f2760..f3fcc89e 100644 --- a/apps/models.py +++ b/apps/models.py @@ -37,6 +37,10 @@ def __repr__(self): @classmethod def find_by_id(cls, _id: int) -> "Product": return cls.query.filter_by(id=_id).first() + + @classmethod + def get_list(cls): + return cls.query.all() def save(self) -> None: try: diff --git a/templates/authentication/login.html b/templates/authentication/login.html index e95897c5..703d48cc 100644 --- a/templates/authentication/login.html +++ b/templates/authentication/login.html @@ -16,23 +16,24 @@ Welcome back