aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/db/models.py2
-rw-r--r--mediagoblin/edit/forms.py7
-rw-r--r--mediagoblin/edit/routing.py3
-rw-r--r--mediagoblin/edit/views.py21
-rw-r--r--mediagoblin/templates/mediagoblin/base.html2
-rw-r--r--mediagoblin/templates/mediagoblin/edit/edit_profile.html35
-rw-r--r--mediagoblin/templates/mediagoblin/root.html5
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/user.html2
-rw-r--r--mediagoblin/templates/mediagoblin/utils/profile.html35
9 files changed, 110 insertions, 2 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index d77cf619..78bec979 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -46,6 +46,8 @@ class User(Document):
'status': unicode,
'verification_key': unicode,
'is_admin': bool,
+ 'url' : unicode,
+ 'bio' : unicode
}
required_fields = ['username', 'created', 'pw_hash', 'email']
diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py
index ea25141d..fb4930a2 100644
--- a/mediagoblin/edit/forms.py
+++ b/mediagoblin/edit/forms.py
@@ -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)])
diff --git a/mediagoblin/edit/routing.py b/mediagoblin/edit/routing.py
index bf0b2498..9604d214 100644
--- a/mediagoblin/edit/routing.py
+++ b/mediagoblin/edit/routing.py
@@ -19,4 +19,5 @@ 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")]
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index c5f0f435..57c9a118 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -59,3 +59,24 @@ def edit_media(request, media):
'mediagoblin/edit/edit.html',
{'media': media,
'form': form})
+
+@require_active_login
+def edit_profile(request):
+
+ user = request.user
+ form = forms.EditProfileForm(request.POST,
+ url = user.get('url'),
+ bio = user.get('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})
diff --git a/mediagoblin/templates/mediagoblin/base.html b/mediagoblin/templates/mediagoblin/base.html
index c7313173..8e5fd55b 100644
--- a/mediagoblin/templates/mediagoblin/base.html
+++ b/mediagoblin/templates/mediagoblin/base.html
@@ -35,6 +35,8 @@
<div class="mediagoblin_header_right">
{% if request.user %}
{{ request.user['username'] }}'s account
+ <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
+ user= request.user['username']) }}">home</a>
<a href="{{ request.urlgen('mediagoblin.user_pages.user_gallery',
user= request.user['username']) }}">gallery</a>
(<a href="{{ request.urlgen('mediagoblin.auth.logout') }}">logout</a>)
diff --git a/mediagoblin/templates/mediagoblin/edit/edit_profile.html b/mediagoblin/templates/mediagoblin/edit/edit_profile.html
new file mode 100644
index 00000000..63bf013f
--- /dev/null
+++ b/mediagoblin/templates/mediagoblin/edit/edit_profile.html
@@ -0,0 +1,35 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011 Free Software Foundation, Inc
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#}
+{% extends "mediagoblin/base.html" %}
+
+{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
+
+{% block mediagoblin_content %}
+ <h1>Edit details for {{ user['username'] }}</h1>
+
+ <form action="{{ request.urlgen('mediagoblin.edit.profile',
+ user=user.username) }}"
+ method="POST" enctype="multipart/form-data">
+ <div class="submit_box form_box">
+ {{ wtforms_util.render_divs(form) }}
+ <div class="form_submit_buttons">
+ <input type="submit" value="submit" class="button" />
+ </div>
+ </div>
+ </form>
+{% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/root.html b/mediagoblin/templates/mediagoblin/root.html
index e5344e08..697ac15b 100644
--- a/mediagoblin/templates/mediagoblin/root.html
+++ b/mediagoblin/templates/mediagoblin/root.html
@@ -23,7 +23,10 @@
{% if request.user %}
<p>
- <a href="{{ request.urlgen('mediagoblin.submit.start') }}">Submit an item</a>.
+ <a href="{{ request.urlgen('mediagoblin.submit.start') }}">Submit an item</a>
+ <a href="{{ request.urlgen(
+ 'mediagoblin.edit.profile',
+ user=request.user.username) }}">Edit profile</a>
</p>
{% else %}
diff --git a/mediagoblin/templates/mediagoblin/user_pages/user.html b/mediagoblin/templates/mediagoblin/user_pages/user.html
index b3708c85..f7a9f3c9 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/user.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/user.html
@@ -27,6 +27,8 @@
{% block mediagoblin_content -%}
{% if user %}
<h1>User page for '{{ user.username }}'</h1>
+
+ {% include "mediagoblin/utils/profile.html" %}
{% include "mediagoblin/utils/object_gallery.html" %}
diff --git a/mediagoblin/templates/mediagoblin/utils/profile.html b/mediagoblin/templates/mediagoblin/utils/profile.html
new file mode 100644
index 00000000..b3f5f0f8
--- /dev/null
+++ b/mediagoblin/templates/mediagoblin/utils/profile.html
@@ -0,0 +1,35 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011 Free Software Foundation, Inc
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#}
+
+{% block profile_content -%}
+ <div>
+ <ul>
+ {% if user.url %}
+ <li>
+ <a href="{{ user.url }}">homepage</a>
+ </li>
+ {% endif %}
+
+ {% if user.bio %}
+ <li>
+ {{ user.bio }}
+ </li>
+ {% endif %}
+ </ul>
+ </div>
+{% endblock %}