This commit is contained in:
Aaron Kimbre 2022-05-11 13:05:18 -05:00
parent 1dbe0ce980
commit 07136ef283
4 changed files with 57 additions and 2 deletions

View File

@ -18,7 +18,7 @@ from app.models import (
) )
from app.schemas import AccountSchema from app.schemas import AccountSchema
from app import gm_level, log_audit from app import gm_level, log_audit
from app.forms import EditGMLevelForm from app.forms import EditGMLevelForm, EditEmailForm
accounts_blueprint = Blueprint('accounts', __name__) accounts_blueprint = Blueprint('accounts', __name__)
@ -69,6 +69,22 @@ def edit_gm_level(id):
return render_template('accounts/edit_gm_level.html.j2', form=form, username=account_data.username) return render_template('accounts/edit_gm_level.html.j2', form=form, username=account_data.username)
@accounts_blueprint.route('/edit_email/<id>', methods=('GET', 'POST'))
@login_required
@gm_level(8)
def edit_email(id):
account_data = Account.query.filter(Account.id == id).first()
form = EditEmailForm()
if form.validate_on_submit():
log_audit(f"Changed ({account_data.id}){account_data.username}'s Email from {account_data.email} to {form.email.data}")
account_data.email = form.email.data
account_data.save()
return redirect(url_for('accounts.view', id=account_data.id))
form.email.data = account_data.email
return render_template('accounts/edit_email.html.j2', form=form, username=account_data.username)
@accounts_blueprint.route('/lock/<id>', methods=['GET']) @accounts_blueprint.route('/lock/<id>', methods=['GET'])
@login_required @login_required
@gm_level(3) @gm_level(3)

View File

@ -119,7 +119,7 @@ class EditPlayKeyForm(FlaskForm):
class EditGMLevelForm(FlaskForm): class EditGMLevelForm(FlaskForm):
gm_level = IntegerField( email = IntegerField(
'GM Level', 'GM Level',
widget=NumberInput(min=0, max=9) widget=NumberInput(min=0, max=9)
) )
@ -127,6 +127,18 @@ class EditGMLevelForm(FlaskForm):
submit = SubmitField('Submit') submit = SubmitField('Submit')
class EditEmailForm(FlaskForm):
email = StringField(
'E-Mail',
validators=[
Optional(),
validators.Email('Invalid email address'),
unique_email_validator,
]
)
submit = SubmitField('Submit')
class ResolveBugReportForm(FlaskForm): class ResolveBugReportForm(FlaskForm):
resolution = StringField( resolution = StringField(

View File

@ -0,0 +1,21 @@
{% extends 'base.html.j2' %}
{% block title %}
Edit E-mail for User {{ username }}
{% endblock title %}
{% block content_before %}
Edit E-mail for User {{ username }}
{% endblock content_before %}
{% block content %}
<form method=post>
{{ form.csrf_token }}
<div class="card shadow-sm mx-auto pb-3 bg-dark border-primary" style="width: 20rem;">
<div class="card-body">
{{ helper.render_field(form.email) }}
{{ helper.render_submit_field(form.submit) }}
</div>
</div>
</form>
{% endblock content %}

View File

@ -23,6 +23,12 @@
<br/> <br/>
<div class="col"> <div class="col">
{{ account_data.email }} {{ account_data.email }}
{% if current_user.gm_level >= 8 and not(current_user.gm_level == 8 and account_data.gm_level == 8)%}
<a role="button" class="btn btn-primary"
href='{{ url_for('accounts.edit_email', id=account_data.id) }}'>
Edit
</a>
{% endif %}
</div> </div>
</div> </div>
{% endif %} {% endif %}