Make it possible to edit one’s profile
…even though it’s only one field yet.
This commit is contained in:
parent
1a69928241
commit
c3348d3212
@ -399,5 +399,21 @@ class CalendarSocialApp(Flask):
|
|||||||
|
|
||||||
return render_template('first-steps.html', form=form)
|
return render_template('first-steps.html', form=form)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@route('/edit-profile', methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
def edit_profile():
|
||||||
|
from .forms import ProfileForm
|
||||||
|
from .models import db
|
||||||
|
|
||||||
|
form = ProfileForm(current_user.profile)
|
||||||
|
|
||||||
|
if form.validate_on_submit():
|
||||||
|
form.populate_obj(current_user.profile)
|
||||||
|
db.session.add(current_user.profile)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
return render_template('profile-edit.html', form=form)
|
||||||
|
|
||||||
|
|
||||||
app = CalendarSocialApp(__name__)
|
app = CalendarSocialApp(__name__)
|
||||||
|
@ -335,3 +335,16 @@ class FirstStepsForm(FlaskForm):
|
|||||||
label=_('Your time zone'),
|
label=_('Your time zone'),
|
||||||
validators=[DataRequired()],
|
validators=[DataRequired()],
|
||||||
description=_('The start and end times of events will be displayed in this time zone.'))
|
description=_('The start and end times of events will be displayed in this time zone.'))
|
||||||
|
|
||||||
|
|
||||||
|
class ProfileForm(FlaskForm):
|
||||||
|
"""Form for editing a user profile
|
||||||
|
"""
|
||||||
|
|
||||||
|
display_name = StringField(label=_('Display name'), validators=[DataRequired()])
|
||||||
|
|
||||||
|
def __init__(self, profile, *args, **kwargs):
|
||||||
|
kwargs.update({'display_name': profile.display_name})
|
||||||
|
FlaskForm.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
self.profile = profile
|
||||||
|
17
calsocial/templates/profile-edit.html
Normal file
17
calsocial/templates/profile-edit.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{% extends 'settings-base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ super() }}
|
||||||
|
<h2>{% trans %}Edit profile{% endtrans %}</h2>
|
||||||
|
<form method="post">
|
||||||
|
{{ form.hidden_tag() }}
|
||||||
|
{{ form.errors }}
|
||||||
|
|
||||||
|
{{ form.display_name.errors }}
|
||||||
|
{{ form.display_name.label }}
|
||||||
|
{{ form.display_name }}
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<button type="submit">{% trans %}Save{% endtrans %}</button>
|
||||||
|
</form>
|
||||||
|
{% endblock content %}
|
Loading…
Reference in New Issue
Block a user