06/05 Optimize app: add email notification
This commit is contained in:
+20
-1
@@ -68,6 +68,7 @@ class ProfileForm(FlaskForm):
|
||||
])
|
||||
currency = SelectField('Currency', choices=CURRENCIES)
|
||||
groq_model = SelectField('AI Model', choices=GROQ_MODELS)
|
||||
budget_alerts_enabled = BooleanField('Email me when a budget category reaches 80% or 100%')
|
||||
submit = SubmitField('Save Profile')
|
||||
|
||||
|
||||
@@ -156,10 +157,28 @@ def profile():
|
||||
current_user.currency = form.currency.data
|
||||
current_user.currency_symbol = CURRENCY_SYMBOLS.get(form.currency.data, '$')
|
||||
current_user.groq_model = form.groq_model.data
|
||||
current_user.budget_alerts_enabled = form.budget_alerts_enabled.data
|
||||
db.session.commit()
|
||||
flash('Profile updated.', 'success')
|
||||
return redirect(url_for('settings.profile'))
|
||||
return render_template('settings/profile.html', form=form)
|
||||
smtp_ok = all([
|
||||
current_app.config.get('SMTP_HOST'),
|
||||
current_app.config.get('SMTP_USER'),
|
||||
current_app.config.get('SMTP_PASSWORD'),
|
||||
current_app.config.get('ALERT_EMAIL'),
|
||||
])
|
||||
return render_template('settings/profile.html', form=form,
|
||||
smtp_ok=smtp_ok,
|
||||
alert_email=current_app.config.get('ALERT_EMAIL', ''))
|
||||
|
||||
|
||||
@settings_bp.route('/test-email', methods=['POST'])
|
||||
@login_required
|
||||
def test_email():
|
||||
from app.services.alert_service import send_test_email
|
||||
ok, msg = send_test_email()
|
||||
flash(msg, 'success' if ok else 'danger')
|
||||
return redirect(url_for('settings.profile'))
|
||||
|
||||
|
||||
@settings_bp.route('/password', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user