- Convert mail messaging from SMTP to Scaleway TEM mails
This commit is contained in:
@@ -51,10 +51,12 @@ class LicenseForm(FlaskForm):
|
||||
yearly_payment = BooleanField('Yearly Payment', default=False)
|
||||
basic_fee = FloatField('Basic Fee', validators=[InputRequired(), NumberRange(min=0)])
|
||||
max_storage_mb = IntegerField('Max Storage (MiB)', validators=[DataRequired(), NumberRange(min=1)])
|
||||
additional_storage_allowed = BooleanField('Additional Storage Allowed', default=True)
|
||||
additional_storage_price = FloatField('Additional Storage Token Fee',
|
||||
validators=[InputRequired(), NumberRange(min=0)])
|
||||
additional_storage_bucket = IntegerField('Additional Storage Bucket Size (MiB)',
|
||||
validators=[DataRequired(), NumberRange(min=1)])
|
||||
additional_embedding_allowed = BooleanField('Additional Embedding Allowed', default=True)
|
||||
included_embedding_mb = IntegerField('Included Embedding Tokens (MiB)',
|
||||
validators=[DataRequired(), NumberRange(min=1)])
|
||||
additional_embedding_price = FloatField('Additional Embedding Token Fee',
|
||||
@@ -63,6 +65,7 @@ class LicenseForm(FlaskForm):
|
||||
validators=[DataRequired(), NumberRange(min=1)])
|
||||
included_interaction_tokens = IntegerField('Included Interaction Tokens (M Tokens)',
|
||||
validators=[DataRequired(), NumberRange(min=1)])
|
||||
additional_interaction_allowed = BooleanField('Additional Interaction Allowed', default=True)
|
||||
additional_interaction_token_price = FloatField('Additional Interaction Token Fee',
|
||||
validators=[InputRequired(), NumberRange(min=0)])
|
||||
additional_interaction_bucket = IntegerField('Additional Interaction Bucket Size (M Tokens)',
|
||||
|
||||
@@ -152,8 +152,9 @@ def create_license(license_tier_id):
|
||||
tenant_id = session.get('tenant').get('id')
|
||||
currency = session.get('tenant').get('currency')
|
||||
|
||||
if current_user_has_role("Partner Admin"): # The Partner Admin can only set the end date
|
||||
readonly_fields = [field.name for field in form if (field.name != 'end_date' and field.name != 'start_date')]
|
||||
if current_user_has_role("Partner Admin"): # The Partner Admin can only set start & end dates, and allowed fields
|
||||
readonly_fields = [field.name for field in form if (field.name != 'end_date' and field.name != 'start_date' and
|
||||
not field.name.endswith('allowed'))]
|
||||
|
||||
if request.method == 'GET':
|
||||
# Fetch the LicenseTier
|
||||
|
||||
@@ -2,10 +2,6 @@ from flask import current_app
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import PasswordField, SubmitField, StringField
|
||||
from wtforms.validators import DataRequired, Length, Email, NumberRange, Optional, EqualTo
|
||||
from flask_security.forms import ForgotPasswordForm
|
||||
from flask_security.utils import send_mail, config_value
|
||||
|
||||
from common.utils.nginx_utils import prefixed_url_for
|
||||
|
||||
|
||||
class SetPasswordForm(FlaskForm):
|
||||
@@ -14,7 +10,7 @@ class SetPasswordForm(FlaskForm):
|
||||
submit = SubmitField('Set Password')
|
||||
|
||||
|
||||
class RequestResetForm(FlaskForm):
|
||||
class ForgotPasswordForm(FlaskForm):
|
||||
email = StringField('Email', validators=[DataRequired(), Email()])
|
||||
submit = SubmitField('Request Password Reset')
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
from common.models.user import User
|
||||
from common.utils.eveai_exceptions import EveAIException, EveAINoActiveLicense
|
||||
from common.utils.nginx_utils import prefixed_url_for
|
||||
from eveai_app.views.security_forms import SetPasswordForm, ResetPasswordForm, RequestResetForm
|
||||
from eveai_app.views.security_forms import SetPasswordForm, ResetPasswordForm, ForgotPasswordForm
|
||||
from common.extensions import db
|
||||
from common.utils.security_utils import confirm_token, send_confirmation_email, send_reset_email
|
||||
from common.utils.security import set_tenant_session_data, is_valid_tenant
|
||||
@@ -111,16 +111,16 @@ def confirm_email(token):
|
||||
return redirect(prefixed_url_for('basic_bp.confirm_email_ok'))
|
||||
|
||||
|
||||
@security_bp.route('/reset_password_request', methods=['GET', 'POST'])
|
||||
def reset_password_request():
|
||||
form = RequestResetForm()
|
||||
@security_bp.route('/forgot_password', methods=['GET', 'POST'])
|
||||
def forgot_password():
|
||||
form = ForgotPasswordForm()
|
||||
if form.validate_on_submit():
|
||||
user = User.query.filter_by(email=form.email.data).first()
|
||||
if user:
|
||||
send_reset_email(user)
|
||||
flash('An email with instructions to reset your password has been sent.', 'info')
|
||||
return redirect(prefixed_url_for('security_bp.login'))
|
||||
return render_template('security/reset_password_request.html', form=form)
|
||||
return render_template('security/forgot_password.html', form=form)
|
||||
|
||||
|
||||
@security_bp.route('/reset_password/<token>', methods=['GET', 'POST'])
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import uuid
|
||||
from datetime import datetime as dt, timezone as tz
|
||||
from flask import request, redirect, flash, render_template, Blueprint, session, current_app
|
||||
from flask_mailman import EmailMessage
|
||||
from flask_security import roles_accepted, current_user
|
||||
from sqlalchemy.exc import SQLAlchemyError, IntegrityError
|
||||
import ast
|
||||
@@ -21,6 +20,7 @@ from common.utils.eveai_exceptions import EveAIException
|
||||
from common.utils.document_utils import set_logging_information, update_logging_information
|
||||
from common.services.tenant_services import TenantServices
|
||||
from common.services.user_services import UserServices
|
||||
from common.utils.mail_utils import send_email
|
||||
|
||||
user_bp = Blueprint('user_bp', __name__, url_prefix='/user')
|
||||
|
||||
@@ -670,20 +670,15 @@ def send_api_key_notification(tenant_id, tenant_name, project_name, api_key, ser
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
# Create email message
|
||||
msg = EmailMessage(
|
||||
msg = send_email(
|
||||
subject='Your new API-key from Ask Eve AI (Evie)',
|
||||
body=render_template('email/api_key_notification.html', **context),
|
||||
from_email=current_app.config['MAIL_DEFAULT_SENDER'],
|
||||
to=[recipient_email]
|
||||
html=render_template('email/api_key_notification.html', **context),
|
||||
to_email=recipient_email,
|
||||
to_name=recipient_email,
|
||||
)
|
||||
|
||||
# Set HTML content type
|
||||
msg.content_subtype = "html"
|
||||
|
||||
# Send email
|
||||
msg.send()
|
||||
|
||||
current_app.logger.info(f"API key notification sent to {recipient_email} for tenant {tenant_id}")
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user