aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/models.py
diff options
context:
space:
mode:
authorJessica Tallon <tsyesika@tsyesika.se>2015-10-07 13:13:40 +0200
committerJessica Tallon <tsyesika@tsyesika.se>2015-10-07 15:07:54 +0200
commitd216d771f662fc3e0a3417ce06e8355abce99988 (patch)
tree7502682047ad22ec40d13d18ffb84a284d1e92ac /mediagoblin/db/models.py
parentbc75a6532712e4b9b0f6d8b5bbd93db3ef58335d (diff)
downloadmediagoblin-d216d771f662fc3e0a3417ce06e8355abce99988.tar.lz
mediagoblin-d216d771f662fc3e0a3417ce06e8355abce99988.tar.xz
mediagoblin-d216d771f662fc3e0a3417ce06e8355abce99988.zip
Add public_id fixes throughout the code
This adds several things, mainly code which checks for the public id and if it doesn't exist generating it where it can. This is to because we need to keep the public_id to be able to effectively soft delete models. This also adds a public_id field to the Activity along with a migration.
Diffstat (limited to 'mediagoblin/db/models.py')
-rw-r--r--mediagoblin/db/models.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index 73f3c8ce..e52cab82 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -728,7 +728,7 @@ class MediaEntry(Base, MediaEntryMixin):
author = self.get_actor
published = UTC.localize(self.created)
updated = UTC.localize(self.updated)
- public_id = self.get_public_id(request)
+ public_id = self.get_public_id(request.urlgen)
context = {
"id": public_id,
"author": author.serialize(request),
@@ -1034,6 +1034,7 @@ class Collection(Base, CollectionMixin):
__tablename__ = "core__collections"
id = Column(Integer, primary_key=True)
+ public_id = Column(Unicode, unique=True)
title = Column(Unicode, nullable=False)
slug = Column(Unicode)
created = Column(DateTime, nullable=False, default=datetime.datetime.utcnow,
@@ -1492,6 +1493,7 @@ class Activity(Base, ActivityMixin):
__tablename__ = "core__activities"
id = Column(Integer, primary_key=True)
+ public_id = Column(Unicode, unique=True)
actor = Column(Integer,
ForeignKey("core__users.id"),
nullable=False)