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.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user