aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/user_pages
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/user_pages
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/user_pages')
-rw-r--r--mediagoblin/user_pages/views.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py
index 4ee601b3..f1c8a622 100644
--- a/mediagoblin/user_pages/views.py
+++ b/mediagoblin/user_pages/views.py
@@ -267,6 +267,7 @@ def media_collect(request, media):
collection.actor = request.user.id
collection.type = Collection.USER_DEFINED_TYPE
collection.generate_slug()
+ collection.get_public_id(request.urlgen)
create_activity("create", collection, collection.actor)
collection.save()
@@ -318,6 +319,12 @@ def media_confirm_delete(request, media):
if form.confirm.data is True:
username = media.get_actor.username
+ # This probably is already filled but just in case it has slipped
+ # through the net somehow, we need to try and make sure the
+ # MediaEntry has a public ID so it gets properly soft-deleted.
+ media.get_public_id(request.urlgen)
+
+ # Decrement the users uploaded quota.
media.get_actor.uploaded = media.get_actor.uploaded - \
media.file_size
media.get_actor.save()
@@ -453,6 +460,10 @@ def collection_confirm_delete(request, collection):
if form.confirm.data is True:
collection_title = collection.title
+ # Firstly like with the MediaEntry delete, lets ensure the
+ # public_id is populated as this is really important!
+ collection.get_public_id(request.urlgen)
+
# Delete all the associated collection items
for item in collection.get_collection_items():
obj = item.get_object()
@@ -727,6 +738,10 @@ def activity_view(request):
author=user.id
).first()
+ # There isn't many places to check that the public_id is filled so this
+ # will do, it really should be, lets try and fix that if it isn't.
+ activity.get_public_id(request.urlgen)
+
if activity is None:
return render_404(request)