aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/edit
diff options
context:
space:
mode:
authorJessica Tallon <jessica@megworld.co.uk>2014-09-15 19:34:42 +0100
committerJessica Tallon <jessica@megworld.co.uk>2014-10-09 19:16:54 +0100
commitc0434db46910e891313495b5ae94cbbe1dd08058 (patch)
tree9f7cfe31ca3bf4c5f49adf2daa964eafe91061dd /mediagoblin/edit
parentd60d686a14d10af3f58867569622735ff9ecd068 (diff)
downloadmediagoblin-c0434db46910e891313495b5ae94cbbe1dd08058.tar.lz
mediagoblin-c0434db46910e891313495b5ae94cbbe1dd08058.tar.xz
mediagoblin-c0434db46910e891313495b5ae94cbbe1dd08058.zip
Add location model and migrations
Diffstat (limited to 'mediagoblin/edit')
-rw-r--r--mediagoblin/edit/forms.py1
-rw-r--r--mediagoblin/edit/views.py21
2 files changed, 19 insertions, 3 deletions
diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py
index c0bece8b..f0a03e04 100644
--- a/mediagoblin/edit/forms.py
+++ b/mediagoblin/edit/forms.py
@@ -61,6 +61,7 @@ class EditProfileForm(wtforms.Form):
[wtforms.validators.Optional(),
wtforms.validators.URL(message=_("This address contains errors"))])
+ location = wtforms.TextField(_('Hometown'))
class EditAccountForm(wtforms.Form):
wants_comment_notification = wtforms.BooleanField(
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index e998d6be..17c83d46 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -45,7 +45,7 @@ from mediagoblin.tools.text import (
convert_to_tag_list_of_dicts, media_tags_as_string)
from mediagoblin.tools.url import slugify
from mediagoblin.db.util import check_media_slug_used, check_collection_slug_used
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, Location
import mimetypes
@@ -200,14 +200,29 @@ def edit_profile(request, url_user=None):
user = url_user
+ # Get the location name
+ if user.location is None:
+ location = ""
+ else:
+ location = user.get_location.name
+
form = forms.EditProfileForm(request.form,
url=user.url,
- bio=user.bio)
+ bio=user.bio,
+ location=location)
if request.method == 'POST' and form.validate():
user.url = unicode(form.url.data)
user.bio = unicode(form.bio.data)
+ # Save location
+ if form.location.data and user.location is None:
+ user.get_location = Location(name=unicode(form.location.data))
+ elif form.location.data:
+ location = user.get_location.name
+ location.name = unicode(form.location.data)
+ location.save()
+
user.save()
messages.add_message(request,
@@ -450,7 +465,7 @@ def edit_metadata(request, media):
json_ld_metadata = compact_and_validate(metadata_dict)
media.media_metadata = json_ld_metadata
media.save()
- return redirect_obj(request, media)
+ return redirect_obj(request, media)
if len(form.media_metadata) == 0:
for identifier, value in media.media_metadata.iteritems():