Add: Branding config
- App name - Tagline - Large Logo (for Login page) - Small Logo (for header)
This commit is contained in:
		
							parent
							
								
									55dd86c27c
								
							
						
					
					
						commit
						4ffc68d5f2
					
				@ -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"
 | 
			
		||||
 | 
			
		||||
@ -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')
 | 
			
		||||
@ -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
 | 
			
		||||
    )
 | 
			
		||||
@ -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():
 | 
			
		||||
 | 
			
		||||
@ -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')
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
    )
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								static/images/logo_large.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/images/logo_large.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 4.7 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								static/images/logo_small.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/images/logo_small.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 8.8 KiB  | 
@ -1,6 +1,11 @@
 | 
			
		||||
<!-- Header bar -->
 | 
			
		||||
<div class="header">
 | 
			
		||||
    <h1 class="appname">Inventory Manager</h1>
 | 
			
		||||
    <div class="branding">
 | 
			
		||||
        <img src="{{ url_for('static', filename=brandingconfig.HEADER_LOGO) }}" 
 | 
			
		||||
             alt="{{ brandingconfig.APP_NAME }} Logo"
 | 
			
		||||
             class="header-logo">
 | 
			
		||||
        <h1 class="appname">{{ brandingconfig.APP_NAME }}</h1>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="buttons">
 | 
			
		||||
        <form action="/create" method="get">
 | 
			
		||||
            <button type="submit">Add New Item</button>
 | 
			
		||||
 | 
			
		||||
@ -3,14 +3,16 @@
 | 
			
		||||
	<head>
 | 
			
		||||
		<meta charset="UTF-8">
 | 
			
		||||
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
			
		||||
		<title>Login Page</title>
 | 
			
		||||
		<title>{{ brandingconfig.APP_NAME }} - Login</title>
 | 
			
		||||
	</head>
 | 
			
		||||
	<body>
 | 
			
		||||
 | 
			
		||||
		<div class="left-container">
 | 
			
		||||
			<img src="../images/logo2.png" alt="Company Logo" class="logo">
 | 
			
		||||
			<h1>Inventory Manager</h1>
 | 
			
		||||
			<p>Inventory management system</p>
 | 
			
		||||
			<img src="{{ url_for('static', filename=brandingconfig.LOGIN_LOGO) }}" 
 | 
			
		||||
             alt="{{ brandingconfig.APP_NAME }} Logo" 
 | 
			
		||||
             class="logo">
 | 
			
		||||
			<h1>{{ brandingconfig.APP_NAME }}</h1>
 | 
			
		||||
			<p>{{ brandingconfig.TAGLINE }}</p>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		{% with messages = get_flashed_messages(with_categories=true) %}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user