aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/migrations.py
diff options
context:
space:
mode:
authorJessica Tallon <jessica@megworld.co.uk>2014-10-09 19:20:13 +0100
committerJessica Tallon <jessica@megworld.co.uk>2014-10-09 19:20:13 +0100
commited48454558a91961b6e03fc51b8a4bf785d48d1e (patch)
tree792294c842fe5643a2d8f66be366805f621d4ece /mediagoblin/db/migrations.py
parent9a1fc423ac298c2ddf078d91ea1302c135285781 (diff)
parentc0434db46910e891313495b5ae94cbbe1dd08058 (diff)
downloadmediagoblin-ed48454558a91961b6e03fc51b8a4bf785d48d1e.tar.lz
mediagoblin-ed48454558a91961b6e03fc51b8a4bf785d48d1e.tar.xz
mediagoblin-ed48454558a91961b6e03fc51b8a4bf785d48d1e.zip
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.
Diffstat (limited to 'mediagoblin/db/migrations.py')
-rw-r--r--mediagoblin/db/migrations.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 31b8333e..0e0ee6be 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -1086,3 +1086,40 @@ def activity_migration(db):
).where(collection_table.c.id==collection.id))
db.commit()
+
+class Location_V0(declarative_base()):
+ __tablename__ = "core__locations"
+ id = Column(Integer, primary_key=True)
+ name = Column(Unicode)
+ position = Column(MutationDict.as_mutable(JSONEncoded))
+ address = Column(MutationDict.as_mutable(JSONEncoded))
+
+@RegisterMigration(25, MIGRATIONS)
+def add_location_model(db):
+ """ Add location model """
+ metadata = MetaData(bind=db.bind)
+
+ # Create location table
+ Location_V0.__table__.create(db.bind)
+ db.commit()
+
+ # Inspect the tables we need
+ user = inspect_table(metadata, "core__users")
+ collections = inspect_table(metadata, "core__collections")
+ media_entry = inspect_table(metadata, "core__media_entries")
+ media_comments = inspect_table(metadata, "core__media_comments")
+
+ # Now add location support to the various models
+ col = Column("location", Integer, ForeignKey(Location_V0.id))
+ col.create(user)
+
+ col = Column("location", Integer, ForeignKey(Location_V0.id))
+ col.create(collections)
+
+ col = Column("location", Integer, ForeignKey(Location_V0.id))
+ col.create(media_entry)
+
+ col = Column("location", Integer, ForeignKey(Location_V0.id))
+ col.create(media_comments)
+
+ db.commit()