Add company info to the settings
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,50 @@
|
||||
"""Add company information fields to SiteSettings
|
||||
|
||||
Revision ID: 787468cfea77
|
||||
Revises: 9faab7ef6036
|
||||
Create Date: 2025-05-26 10:42:17.287566
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '787468cfea77'
|
||||
down_revision = '9faab7ef6036'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('site_settings', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('company_website', sa.String(length=200), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_email', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_phone', sa.String(length=20), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_address', sa.String(length=200), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_city', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_state', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_zip', sa.String(length=20), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_country', sa.String(length=100), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_description', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('company_industry', sa.String(length=100), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('site_settings', schema=None) as batch_op:
|
||||
batch_op.drop_column('company_industry')
|
||||
batch_op.drop_column('company_description')
|
||||
batch_op.drop_column('company_country')
|
||||
batch_op.drop_column('company_zip')
|
||||
batch_op.drop_column('company_state')
|
||||
batch_op.drop_column('company_city')
|
||||
batch_op.drop_column('company_address')
|
||||
batch_op.drop_column('company_phone')
|
||||
batch_op.drop_column('company_email')
|
||||
batch_op.drop_column('company_website')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
Binary file not shown.
11
models.py
11
models.py
@@ -130,6 +130,17 @@ class SiteSettings(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
primary_color = db.Column(db.String(7), default='#16767b') # Default from colors.css
|
||||
secondary_color = db.Column(db.String(7), default='#741b5f') # Default from colors.css
|
||||
company_name = db.Column(db.String(100))
|
||||
company_website = db.Column(db.String(200))
|
||||
company_email = db.Column(db.String(100))
|
||||
company_phone = db.Column(db.String(20))
|
||||
company_address = db.Column(db.String(200))
|
||||
company_city = db.Column(db.String(100))
|
||||
company_state = db.Column(db.String(100))
|
||||
company_zip = db.Column(db.String(20))
|
||||
company_country = db.Column(db.String(100))
|
||||
company_description = db.Column(db.Text)
|
||||
company_industry = db.Column(db.String(100))
|
||||
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
@classmethod
|
||||
|
||||
Binary file not shown.
@@ -335,7 +335,8 @@ def init_routes(main_bp):
|
||||
return render_template('settings/settings.html',
|
||||
primary_color=site_settings.primary_color,
|
||||
secondary_color=site_settings.secondary_color,
|
||||
active_tab=active_tab)
|
||||
active_tab=active_tab,
|
||||
site_settings=site_settings)
|
||||
|
||||
@main_bp.route('/settings/colors', methods=['POST'])
|
||||
@login_required
|
||||
@@ -384,6 +385,37 @@ def init_routes(main_bp):
|
||||
|
||||
return redirect(url_for('main.settings'))
|
||||
|
||||
@main_bp.route('/settings/company', methods=['POST'])
|
||||
@login_required
|
||||
def update_company_settings():
|
||||
if not current_user.is_admin:
|
||||
flash('Only administrators can update settings.', 'error')
|
||||
return redirect(url_for('main.dashboard'))
|
||||
|
||||
site_settings = SiteSettings.get_settings()
|
||||
|
||||
# Update all company fields
|
||||
site_settings.company_name = request.form.get('company_name')
|
||||
site_settings.company_website = request.form.get('company_website')
|
||||
site_settings.company_email = request.form.get('company_email')
|
||||
site_settings.company_phone = request.form.get('company_phone')
|
||||
site_settings.company_address = request.form.get('company_address')
|
||||
site_settings.company_city = request.form.get('company_city')
|
||||
site_settings.company_state = request.form.get('company_state')
|
||||
site_settings.company_zip = request.form.get('company_zip')
|
||||
site_settings.company_country = request.form.get('company_country')
|
||||
site_settings.company_description = request.form.get('company_description')
|
||||
site_settings.company_industry = request.form.get('company_industry')
|
||||
|
||||
try:
|
||||
db.session.commit()
|
||||
flash('Company settings updated successfully!', 'success')
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
flash('An error occurred while updating company settings.', 'error')
|
||||
|
||||
return redirect(url_for('main.settings', tab='general'))
|
||||
|
||||
@main_bp.route('/dynamic-colors.css')
|
||||
def dynamic_colors():
|
||||
site_settings = SiteSettings.get_settings()
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<!-- General Tab -->
|
||||
<div class="tab-pane fade {% if active_tab == 'general' %}show active{% endif %}" id="general" role="tabpanel" aria-labelledby="general-tab">
|
||||
{{ general_tab() }}
|
||||
{{ general_tab(site_settings, csrf_token) }}
|
||||
</div>
|
||||
|
||||
<!-- Security Tab -->
|
||||
|
||||
@@ -1,6 +1,143 @@
|
||||
{% macro general_tab() %}
|
||||
<div class="alert alert-info">
|
||||
<i class="fas fa-info-circle me-2"></i>
|
||||
General settings will be available soon.
|
||||
{% macro general_tab(site_settings, csrf_token) %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<!-- Company Settings Section -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header bg-white">
|
||||
<h5 class="card-title mb-0">
|
||||
<i class="fas fa-building me-2"></i>Company Settings
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url_for('main.update_company_settings') }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
|
||||
<div class="row">
|
||||
<!-- Basic Information -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<h6 class="mb-3">Basic Information</h6>
|
||||
<div class="mb-3">
|
||||
<label for="company_name" class="form-label">Company Name</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="company_name"
|
||||
name="company_name"
|
||||
value="{{ site_settings.company_name or '' }}"
|
||||
placeholder="Enter your company name">
|
||||
<div class="form-text">This name will be displayed in the website title and navigation bar.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="company_website" class="form-label">Website</label>
|
||||
<input type="url"
|
||||
class="form-control"
|
||||
id="company_website"
|
||||
name="company_website"
|
||||
value="{{ site_settings.company_website or '' }}"
|
||||
placeholder="https://example.com">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="company_email" class="form-label">Email</label>
|
||||
<input type="email"
|
||||
class="form-control"
|
||||
id="company_email"
|
||||
name="company_email"
|
||||
value="{{ site_settings.company_email or '' }}"
|
||||
placeholder="contact@company.com">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="company_phone" class="form-label">Phone</label>
|
||||
<input type="tel"
|
||||
class="form-control"
|
||||
id="company_phone"
|
||||
name="company_phone"
|
||||
value="{{ site_settings.company_phone or '' }}"
|
||||
placeholder="+1 (555) 123-4567">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Address Information -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<h6 class="mb-3">Address Information</h6>
|
||||
<div class="mb-3">
|
||||
<label for="company_address" class="form-label">Street Address</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="company_address"
|
||||
name="company_address"
|
||||
value="{{ site_settings.company_address or '' }}"
|
||||
placeholder="123 Business Street">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="company_city" class="form-label">City</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="company_city"
|
||||
name="company_city"
|
||||
value="{{ site_settings.company_city or '' }}"
|
||||
placeholder="City">
|
||||
</div>
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="company_state" class="form-label">State</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="company_state"
|
||||
name="company_state"
|
||||
value="{{ site_settings.company_state or '' }}"
|
||||
placeholder="State">
|
||||
</div>
|
||||
<div class="col-md-3 mb-3">
|
||||
<label for="company_zip" class="form-label">ZIP Code</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="company_zip"
|
||||
name="company_zip"
|
||||
value="{{ site_settings.company_zip or '' }}"
|
||||
placeholder="ZIP">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="company_country" class="form-label">Country</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="company_country"
|
||||
name="company_country"
|
||||
value="{{ site_settings.company_country or '' }}"
|
||||
placeholder="Country">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Additional Information -->
|
||||
<div class="col-12 mb-4">
|
||||
<h6 class="mb-3">Additional Information</h6>
|
||||
<div class="mb-3">
|
||||
<label for="company_description" class="form-label">Company Description</label>
|
||||
<textarea class="form-control"
|
||||
id="company_description"
|
||||
name="company_description"
|
||||
rows="3"
|
||||
placeholder="Brief description of your company">{{ site_settings.company_description or '' }}</textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="company_industry" class="form-label">Industry</label>
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
id="company_industry"
|
||||
name="company_industry"
|
||||
value="{{ site_settings.company_industry or '' }}"
|
||||
placeholder="e.g., Technology, Healthcare, Finance">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-save me-1"></i> Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user