aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/edit
diff options
context:
space:
mode:
authorSebastian Spaeth <Sebastian@SSpaeth.de>2012-11-30 10:49:06 +0100
committerSebastian Spaeth <Sebastian@SSpaeth.de>2012-12-21 00:30:48 +0100
commit5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868 (patch)
tree6b2ec753c753745ee7964b9544835619b915d0f2 /mediagoblin/edit
parent7e55bcb898d37010a5e9bd8a666cd3ddfa63de33 (diff)
downloadmediagoblin-5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868.tar.lz
mediagoblin-5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868.tar.xz
mediagoblin-5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868.zip
Move DBModel._id -> DBModel.id
We were refering to model._id in most of the code base as this is what Mongo uses. However, each use of _id required a) fixup of queries: e.g. what we did in our find() and find_one() functions moving all '_id' to 'id'. It also required using AliasFields to make the ._id attribute available. This all means lots of superfluous fixing and transitioning in a SQL world. It will also not work in the long run. Much newer code already refers to the objects by model.id (e.g. in the oauth plugin), which will break with Mongo. So let's be honest, rip out the _id mongoism and live with .id as the one canonical way to address objects. This commit modifies all users and providers of model._id to use model.id instead. This patch works with or without Mongo removed first, but will break Mongo usage (even more than before) I have not bothered to fixup db.mongo.* and db.sql.convert (which converts from Mongo to SQL) Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'mediagoblin/edit')
-rw-r--r--mediagoblin/edit/lib.py2
-rw-r--r--mediagoblin/edit/views.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/mediagoblin/edit/lib.py b/mediagoblin/edit/lib.py
index b4715134..aab537a0 100644
--- a/mediagoblin/edit/lib.py
+++ b/mediagoblin/edit/lib.py
@@ -17,7 +17,7 @@
def may_edit_media(request, media):
"""Check, if the request's user may edit the media details"""
- if media.uploader == request.user._id:
+ if media.uploader == request.user.id:
return True
if request.user.is_admin:
return True
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index 111f9ae8..6d938f7c 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -79,7 +79,7 @@ def edit_media(request, media):
location=media.url_for_self(request.urlgen))
if request.user.is_admin \
- and media.uploader != request.user._id \
+ and media.uploader != request.user.id \
and request.method != 'POST':
messages.add_message(
request, messages.WARNING,
@@ -130,7 +130,7 @@ def edit_attachments(request, media):
attachment_public_filepath \
= mg_globals.public_store.get_unique_filepath(
- ['media_entries', unicode(media._id), 'attachment',
+ ['media_entries', unicode(media.id), 'attachment',
public_filename])
attachment_public_file = mg_globals.public_store.get_file(
@@ -278,7 +278,7 @@ def edit_collection(request, collection):
# Make sure there isn't already a Collection with this title
existing_collection = request.db.Collection.find_one({
- 'creator': request.user._id,
+ 'creator': request.user.id,
'title':request.form['title']})
if existing_collection and existing_collection.id != collection.id:
@@ -301,7 +301,7 @@ def edit_collection(request, collection):
collection=collection.slug)
if request.user.is_admin \
- and collection.creator != request.user._id \
+ and collection.creator != request.user.id \
and request.method != 'POST':
messages.add_message(
request, messages.WARNING,