mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-25 15:07:18 +00:00
Resolves #30
This commit is contained in:
parent
1dbe0ce980
commit
07136ef283
@ -18,7 +18,7 @@ from app.models import (
|
||||
)
|
||||
from app.schemas import AccountSchema
|
||||
from app import gm_level, log_audit
|
||||
from app.forms import EditGMLevelForm
|
||||
from app.forms import EditGMLevelForm, EditEmailForm
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@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'])
|
||||
@login_required
|
||||
@gm_level(3)
|
||||
|
14
app/forms.py
14
app/forms.py
@ -119,7 +119,7 @@ class EditPlayKeyForm(FlaskForm):
|
||||
|
||||
class EditGMLevelForm(FlaskForm):
|
||||
|
||||
gm_level = IntegerField(
|
||||
email = IntegerField(
|
||||
'GM Level',
|
||||
widget=NumberInput(min=0, max=9)
|
||||
)
|
||||
@ -127,6 +127,18 @@ class EditGMLevelForm(FlaskForm):
|
||||
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):
|
||||
|
||||
resolution = StringField(
|
||||
|
21
app/templates/accounts/edit_email.html.j2
Normal file
21
app/templates/accounts/edit_email.html.j2
Normal 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 %}
|
@ -23,6 +23,12 @@
|
||||
<br/>
|
||||
<div class="col">
|
||||
{{ 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>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user