Fix settings 500
This commit is contained in:
parent
5633ec7898
commit
6724dd9f7e
3 changed files with 25 additions and 38 deletions
|
@ -186,11 +186,7 @@ def _init_db():
|
|||
# Initialize settings if they don't exist
|
||||
# Note: Models already imported above
|
||||
if not Settings.query.first():
|
||||
default_settings = Settings(
|
||||
webhook_enabled=app.config['WEBHOOK_ENABLED'],
|
||||
webhook_url=app.config['WEBHOOK_URL'],
|
||||
webhook_secret=app.config['WEBHOOK_SECRET']
|
||||
)
|
||||
default_settings = Settings()
|
||||
db.session.add(default_settings)
|
||||
db.session.commit()
|
||||
app.logger.info("Default settings initialized.")
|
||||
|
|
|
@ -125,19 +125,21 @@ def admin_settings_password():
|
|||
flash('Password updated successfully', 'success')
|
||||
return redirect(url_for('admin_settings'))
|
||||
|
||||
@app.route('/admin/settings/notification', methods=['POST'])
|
||||
@app.route('/admin/settings/general', methods=['POST'])
|
||||
@admin_required
|
||||
def admin_settings_notification():
|
||||
def admin_settings_general():
|
||||
settings = Settings.query.first()
|
||||
if not settings:
|
||||
settings = Settings()
|
||||
db.session.add(settings)
|
||||
|
||||
# Update general settings
|
||||
settings.auto_delete_hours = request.form.get('auto_delete_hours')
|
||||
settings.notification_show_message = request.form.get('notification_show_message') == 'on'
|
||||
|
||||
db.session.commit()
|
||||
|
||||
flash('Notification settings saved', 'success')
|
||||
flash('General settings saved', 'success')
|
||||
return redirect(url_for('admin_settings'))
|
||||
|
||||
@app.route('/admin/settings/webhook', methods=['POST'])
|
||||
|
|
|
@ -30,44 +30,33 @@
|
|||
|
||||
<br>
|
||||
|
||||
<div class="auto-delete-settings">
|
||||
<h3>Auto-Delete Settings</h3>
|
||||
|
||||
<div style="margin-bottom: 2rem;">
|
||||
<p>Configure how long inquiries are kept before being automatically deleted.</p>
|
||||
</div>
|
||||
<div class="general-settings">
|
||||
<h3>General Settings</h3>
|
||||
|
||||
<form method="POST" action="{{ url_for('admin_settings_auto_delete') }}">
|
||||
<form method="POST" action="{{ url_for('admin_settings_general') }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
|
||||
<div style="margin-top: 1rem;">
|
||||
<label for="auto_delete_hours">Auto-Delete After (hours):</label>
|
||||
<label for="auto_delete_hours">
|
||||
Auto-Delete After (hours):
|
||||
<input type="number" id="auto_delete_hours" name="auto_delete_hours" value="{{ settings.auto_delete_hours }}" min="1" max="8760">
|
||||
<small style="display: block; margin-top: 0.5rem;">Set to how many hours inquiries should be kept before automatic deletion. (1-8760 hours, 8760 = 1 year)</small>
|
||||
</div>
|
||||
<small style="display: block; margin-top: 0.5rem;">
|
||||
Set to how many hours inquiries should be kept before automatic deletion. (1-8760 hours, 8760 = 1 year)
|
||||
<br>
|
||||
This will have no effect on inquiries that are already closed.
|
||||
</small>
|
||||
</label>
|
||||
|
||||
<button type="submit" style="margin-top: 1rem;">Save Auto-Delete Settings</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<div class="notification-settings">
|
||||
<h3>Notification Settings</h3>
|
||||
<label>
|
||||
<input type="checkbox" name="notification_show_message" {% if settings.notification_show_message %}checked{% endif %}>
|
||||
Include message content in email notifications
|
||||
</label>
|
||||
|
||||
<div style="margin-top: 1rem;">
|
||||
<form method="POST" action="{{ url_for('admin_settings_notification') }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<label>
|
||||
<input type="checkbox" name="notification_show_message" {% if settings.notification_show_message %}checked{% endif %}>
|
||||
Include message content in email notifications
|
||||
</label>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<button type="submit">Save Settings</button>
|
||||
</form>
|
||||
</div>
|
||||
<button type="submit">Save Settings</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue