baby step towards enabling profile edits
adds * url and bio fields to database * form for editing the user profile * route to the edit profile controller * view for the profile editing page * template for the profile editing page * link to edit profile in the welcome page still needs * thorough inspection to see if it makes sense * tests * ?
This commit is contained in:
@@ -25,3 +25,10 @@ class EditForm(wtforms.Form):
|
||||
slug = wtforms.TextField(
|
||||
'Slug')
|
||||
description = wtforms.TextAreaField('Description of this work')
|
||||
|
||||
class EditProfileForm(wtforms.Form):
|
||||
url = wtforms.TextField(
|
||||
'website URL',
|
||||
[wtforms.validators.URL(message='Improperly formed URL')])
|
||||
bio = wtforms.TextAreaField('bio',
|
||||
[wtforms.validators.Length(min=0, max=500)])
|
||||
|
||||
@@ -19,4 +19,6 @@ from routes.route import Route
|
||||
|
||||
edit_routes = [
|
||||
# Media editing view handled in user_pages/routing.py
|
||||
Route('mediagoblin.edit.profile', '/{user}/profile/',
|
||||
controller="mediagoblin.edit.views:edit_profile")
|
||||
]
|
||||
|
||||
@@ -59,3 +59,23 @@ def edit_media(request, media):
|
||||
'mediagoblin/edit/edit.html',
|
||||
{'media': media,
|
||||
'form': form})
|
||||
|
||||
@require_active_login
|
||||
def edit_profile(request):
|
||||
|
||||
form = forms.EditProfileForm(request.POST,
|
||||
url = user['url'],
|
||||
bio = user['bio'])
|
||||
|
||||
if request.method == 'POST' and form.validate():
|
||||
user['url'] = request.POST['url']
|
||||
user['bio'] = request.POST['bio']
|
||||
user.save()
|
||||
|
||||
return redirect(request, "index", user=user.username)
|
||||
|
||||
return render_to_response(
|
||||
request,
|
||||
'mediagoblin/edit/edit_profile.html',
|
||||
{'user': user,
|
||||
'form': form})
|
||||
|
||||
Reference in New Issue
Block a user