Merge branch 'location'
Add Location model which holds textual, geolocation coordiantes or postal addresses. This migrates data off Image model metadata onto the general Location model. It also adds the ability for location to be set on MediaEntry, User, MediaComment and Collection models. The geolocation plugin has been updated so that the location can be displayed in more general places rather than explicitely on the MediaEntry view. If GPS coordiantes are set for the User the profile page will also have the OSM provided by the geolocation plugin.
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -47,7 +47,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, Client, AccessToken
|
||||
from mediagoblin.db.models import User, Client, AccessToken, Location
|
||||
|
||||
import mimetypes
|
||||
|
||||
@@ -202,14 +202,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 = six.text_type(form.url.data)
|
||||
user.bio = six.text_type(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,
|
||||
@@ -480,7 +495,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 six.iteritems(media.media_metadata):
|
||||
|
||||
Reference in New Issue
Block a user