diff --git a/config.sample.py b/config.sample.py index fcbcf6f..b13cf30 100644 --- a/config.sample.py +++ b/config.sample.py @@ -1,6 +1,14 @@ from definitions.attributes import * - +# Branding Configuration +class BrandingConfig: + APP_NAME = "Inventory Manager" + TAGLINE = "Inventory management system" + + # Logo paths (relative to static folder) + LOGIN_LOGO = "images/logo_large.png" # ~400x200px recommended + HEADER_LOGO = "images/logo_small.png" # ~100x50px recommended + # MySQL information class sql_conf: SQL_USER = "assetadmin" diff --git a/routes/create.py b/routes/create.py index e939956..21fab5f 100644 --- a/routes/create.py +++ b/routes/create.py @@ -4,6 +4,7 @@ from config import item_attributes from sqlalchemy import exc # Import exc for database exceptions from functions.validate_values import validate_values # Form validation from functions.auth import login_required +from config import BrandingConfig addasset_bp = Blueprint('addasset', __name__) @@ -12,7 +13,7 @@ addasset_bp = Blueprint('addasset', __name__) def create(): if request.method == 'GET': # Render the "add item" form - return render_template('item_form.html', item_attributes=item_attributes, item=None) + return render_template('item_form.html', item_attributes=item_attributes, item=None, brandingconfig=BrandingConfig) # Process submitted form if request.method == 'POST': @@ -22,7 +23,7 @@ def create(): # Form validation error = validate_values(form_data) if error: - return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error) + return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error, brandingconfig=BrandingConfig) # Create the Asset object item = Asset(**form_data) @@ -37,15 +38,15 @@ def create(): error = f"An entry with {primary_attrib.display_name} '{form_data[primary_attrib.attrib_name]}' already exists." else: error = "An entry with the same primary key already exists." - return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error) + return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error, brandingconfig=BrandingConfig) except exc.StatementError as e: # Handle other database errors error = f"Database error: {str(e)}" - return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error) + return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error, brandingconfig=BrandingConfig) except Exception as e: # Handle unexpected errors error = f"An unexpected error occurred: {str(e)}" - return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error) + return render_template('item_form.html', item_attributes=item_attributes, item=None, error=error, brandingconfig=BrandingConfig) # Redirect to /viewall on success return redirect('/viewall') \ No newline at end of file diff --git a/routes/delete.py b/routes/delete.py index 374d022..fc8404d 100644 --- a/routes/delete.py +++ b/routes/delete.py @@ -2,6 +2,7 @@ from flask import Blueprint, request, render_template, redirect, flash from definitions.models import Asset, db from config import item_attributes from functions.auth import login_required +from config import BrandingConfig delete_bp = Blueprint('deleteasset', __name__) @@ -34,5 +35,6 @@ def delete(primary_value): return render_template( 'delete.html', item=item, - item_attributes=item_attributes + item_attributes=item_attributes, + brandingconfig=BrandingConfig ) \ No newline at end of file diff --git a/routes/homepage.py b/routes/homepage.py index fb89d01..d258f9a 100644 --- a/routes/homepage.py +++ b/routes/homepage.py @@ -1,5 +1,6 @@ from flask import Blueprint, render_template, redirect, url_for, session, request, flash from definitions.models import db, User +from config import BrandingConfig homepage_bp = Blueprint('homepage', __name__) @@ -31,7 +32,7 @@ def login(): else: flash('Invalid username or password', 'error') - return render_template('login.html') + return render_template('login.html', brandingconfig=BrandingConfig) @homepage_bp.route('/logout/') def logout(): diff --git a/routes/update.py b/routes/update.py index b41b3e6..bd04e59 100644 --- a/routes/update.py +++ b/routes/update.py @@ -4,6 +4,7 @@ from config import item_attributes from sqlalchemy import exc # Import exc for database exceptions from functions.validate_values import validate_values # Form validation from functions.auth import login_required +from config import BrandingConfig update_bp = Blueprint('editasset', __name__) @@ -22,7 +23,7 @@ def update(primary_value): if request.method == 'GET': # Render the update form with the current item data - return render_template('item_form.html', item=item, item_attributes=item_attributes) + return render_template('item_form.html', item=item, item_attributes=item_attributes, brandingconfig=BrandingConfig) if request.method == 'POST': # Get data from form @@ -31,7 +32,7 @@ def update(primary_value): # Form validation error = validate_values(form_data) if error: - return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error) + return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error, brandingconfig=BrandingConfig) # Update the item with the new data for attrib in item_attributes: @@ -42,15 +43,15 @@ def update(primary_value): except exc.IntegrityError: # Handle duplicate primary key or unique constraint errors error = f"An entry with {primary_attrib.display_name} '{form_data[primary_attrib.attrib_name]}' already exists." - return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error) + return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error, brandingconfig=BrandingConfig) except exc.StatementError as e: # Handle other database errors error = f"Database error: {str(e)}" - return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error) + return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error, brandingconfig=BrandingConfig) except Exception as e: # Handle unexpected errors error = f"An unexpected error occurred: {str(e)}" - return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error) + return render_template('item_form.html', item=item, item_attributes=item_attributes, error=error, brandingconfig=BrandingConfig) # Redirect to /viewall on success return redirect('/viewall') \ No newline at end of file diff --git a/routes/upload.py b/routes/upload.py index a60929f..dd9416f 100644 --- a/routes/upload.py +++ b/routes/upload.py @@ -4,6 +4,7 @@ from functions.process_csv import get_csv_data from functions.validate_values import validate_values from config import item_attributes from functions.auth import login_required +from config import BrandingConfig upload_bp = Blueprint('uploadcsv', __name__) @@ -89,7 +90,8 @@ def import_from_csv(): mode='import', new_entries=result['new_entries'], invalid_entries=result['invalid_entries'], - item_attributes=item_attributes + item_attributes=item_attributes, + brandingconfig=BrandingConfig ) # Render the upload page for GET requests @@ -129,7 +131,8 @@ def edit_using_csv(): mode='edit', existing_entries=result['existing_entries'], invalid_entries=result['invalid_entries'], - item_attributes=item_attributes + item_attributes=item_attributes, + brandingconfig=BrandingConfig ) # Render the upload page for GET requests diff --git a/routes/viewall.py b/routes/viewall.py index 9f97a39..5477110 100644 --- a/routes/viewall.py +++ b/routes/viewall.py @@ -2,6 +2,7 @@ from flask import Blueprint, render_template from definitions.models import Asset from config import item_attributes from functions.auth import login_required +from config import BrandingConfig viewall_bp = Blueprint('viewall', __name__) @@ -21,5 +22,6 @@ def view_list(): 'viewList.html', items=items, item_attributes=item_attributes, - primary_attrib=primary_attrib.attrib_name + primary_attrib=primary_attrib.attrib_name, + brandingconfig=BrandingConfig ) \ No newline at end of file diff --git a/static/images/logo_large.png b/static/images/logo_large.png new file mode 100644 index 0000000..a513dda Binary files /dev/null and b/static/images/logo_large.png differ diff --git a/static/images/logo_small.png b/static/images/logo_small.png new file mode 100644 index 0000000..d8dd137 Binary files /dev/null and b/static/images/logo_small.png differ diff --git a/templates/header.html b/templates/header.html index 29f2c22..f9e006a 100644 --- a/templates/header.html +++ b/templates/header.html @@ -1,6 +1,11 @@