diff options
author | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-11-30 10:49:06 +0100 |
---|---|---|
committer | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-12-21 00:30:48 +0100 |
commit | 5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868 (patch) | |
tree | 6b2ec753c753745ee7964b9544835619b915d0f2 /mediagoblin/templates | |
parent | 7e55bcb898d37010a5e9bd8a666cd3ddfa63de33 (diff) | |
download | mediagoblin-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/templates')
11 files changed, 27 insertions, 27 deletions
diff --git a/mediagoblin/templates/mediagoblin/admin/panel.html b/mediagoblin/templates/mediagoblin/admin/panel.html index d3c6c958..6bcb5c24 100644 --- a/mediagoblin/templates/mediagoblin/admin/panel.html +++ b/mediagoblin/templates/mediagoblin/admin/panel.html @@ -42,7 +42,7 @@ </tr> {% for media_entry in processing_entries %} <tr> - <td>{{ media_entry._id }}</td> + <td>{{ media_entry.id }}</td> <td>{{ media_entry.get_uploader.username }}</td> <td>{{ media_entry.title }}</td> <td>{{ media_entry.created.strftime("%F %R") }}</td> @@ -72,7 +72,7 @@ </tr> {% for media_entry in failed_entries %} <tr> - <td>{{ media_entry._id }}</td> + <td>{{ media_entry.id }}</td> <td>{{ media_entry.get_uploader.username }}</td> <td>{{ media_entry.title }}</td> <td>{{ media_entry.created.strftime("%F %R") }}</td> @@ -101,7 +101,7 @@ </tr> {% for media_entry in processed_entries %} <tr> - <td>{{ media_entry._id }}</td> + <td>{{ media_entry.id }}</td> <td>{{ media_entry.get_uploader.username }}</td> <td><a href="{{ media_entry.url_for_self(request.urlgen) }}">{{ media_entry.title }}</a></td> <td>{{ media_entry.created.strftime("%F %R") }}</td> diff --git a/mediagoblin/templates/mediagoblin/edit/attachments.html b/mediagoblin/templates/mediagoblin/edit/attachments.html index 6e7da0a1..55d446de 100644 --- a/mediagoblin/templates/mediagoblin/edit/attachments.html +++ b/mediagoblin/templates/mediagoblin/edit/attachments.html @@ -28,7 +28,7 @@ {% block mediagoblin_content %} <form action="{{ request.urlgen('mediagoblin.edit.attachments', user= media.get_uploader.username, - media= media._id) }}" + media= media.id) }}" method="POST" enctype="multipart/form-data"> <div class="form_box"> <h1> diff --git a/mediagoblin/templates/mediagoblin/edit/edit.html b/mediagoblin/templates/mediagoblin/edit/edit.html index 144184df..1f5b91f7 100644 --- a/mediagoblin/templates/mediagoblin/edit/edit.html +++ b/mediagoblin/templates/mediagoblin/edit/edit.html @@ -29,7 +29,7 @@ <form action="{{ request.urlgen('mediagoblin.edit.edit_media', user= media.get_uploader.username, - media= media._id) }}" + media= media.id) }}" method="POST" enctype="multipart/form-data"> <div class="form_box_xl edit_box"> <h1>{% trans media_title=media.title %}Editing {{ media_title }}{% endtrans %}</h1> diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection.html b/mediagoblin/templates/mediagoblin/user_pages/collection.html index f53c164f..f1ab7a42 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/collection.html +++ b/mediagoblin/templates/mediagoblin/user_pages/collection.html @@ -44,7 +44,7 @@ {{ collection_title }} by <a href="{{ user_url }}">{{ username }}</a> {%- endtrans %} </h1> - {% if request.user and (collection.creator == request.user._id or + {% if request.user and (collection.creator == request.user.id or request.user.is_admin) %} {% set edit_url = request.urlgen('mediagoblin.edit.edit_collection', user=collection.get_creator.username, diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html index 9be10321..447201cd 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html +++ b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html @@ -24,7 +24,7 @@ <form action="{{ request.urlgen('mediagoblin.user_pages.collection_item_confirm_remove', user=collection_item.in_collection.get_creator.username, collection=collection_item.in_collection.slug, - collection_item=collection_item._id) }}" + collection_item=collection_item.id) }}" method="POST" enctype="multipart/form-data"> <div class="form_box"> <h1> diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index cb06c7ba..11f2a2a1 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -79,15 +79,15 @@ {{ media.title }} </h2> {% if request.user and - (media.uploader == request.user._id or + (media.uploader == request.user.id or request.user.is_admin) %} {% set edit_url = request.urlgen('mediagoblin.edit.edit_media', user= media.get_uploader.username, - media= media._id) %} + media= media.id) %} <a class="button_action" href="{{ edit_url }}">{% trans %}Edit{% endtrans %}</a> {% set delete_url = request.urlgen('mediagoblin.user_pages.media_confirm_delete', user= media.get_uploader.username, - media= media._id) %} + media= media.id) %} <a class="button_action" href="{{ delete_url }}">{% trans %}Delete{% endtrans %}</a> {% endif %} {% autoescape False %} @@ -104,7 +104,7 @@ {% if request.user %} <form action="{{ request.urlgen('mediagoblin.user_pages.media_post_comment', user= media.get_uploader.username, - media=media._id) }}" method="POST" id="form_comment"> + media=media.id) }}" method="POST" id="form_comment"> <p> {% trans %}You can use <a href="http://daringfireball.net/projects/markdown/basics">Markdown</a> for formatting.{% endtrans %} </p> @@ -117,11 +117,11 @@ {% endif %} {% for comment in comments %} {% set comment_author = comment.get_author %} - {% if pagination.active_id == comment._id %} - <div class="comment_wrapper comment_active" id="comment-{{ comment._id }}"> + {% if pagination.active_id == comment.id %} + <div class="comment_wrapper comment_active" id="comment-{{ comment.id }}"> <a name="comment" id="comment"></a> {% else %} - <div class="comment_wrapper" id="comment-{{ comment._id }}"> + <div class="comment_wrapper" id="comment-{{ comment.id }}"> {% endif %} <div class="comment_author"> <img src="{{ request.staticdirect('/images/icon_comment.png') }}" /> @@ -131,7 +131,7 @@ </a> {% trans %}at{% endtrans %} <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment', - comment = comment._id, + comment = comment.id, user = media.get_uploader.username, media = media.slug_or_id) }}#comment"> {{ comment.created.strftime("%I:%M%p %Y-%m-%d") }} @@ -181,7 +181,7 @@ {% endif %} {% if app_config['allow_attachments'] and request.user - and (media.uploader == request.user._id + and (media.uploader == request.user.id or request.user.is_admin) %} {% if not media.attachment_files|count %} <h3>{% trans %}Attachments{% endtrans %}</h3> @@ -189,7 +189,7 @@ <p> <a href="{{ request.urlgen('mediagoblin.edit.attachments', user=media.get_uploader.username, - media=media._id) }}">{% trans %}Add attachment{% endtrans %}</a> + media=media.id) }}">{% trans %}Add attachment{% endtrans %}</a> </p> {% endif %} @@ -197,7 +197,7 @@ <p> <a type="submit" href="{{ request.urlgen('mediagoblin.user_pages.media_collect', user=media.get_uploader.username, - media=media._id) }}" + media=media.id) }}" class="button_action" title="{% trans %}Add media to collection{% endtrans %}"> <img src="{{ request.staticdirect('/images/icon_collect.png') }}" diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_collect.html b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html index cefe638b..4f35dfa3 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media_collect.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html @@ -28,7 +28,7 @@ <form action="{{ request.urlgen('mediagoblin.user_pages.media_collect', user=media.get_uploader.username, - media=media._id) }}" + media=media.id) }}" method="POST" enctype="multipart/form-data"> <div class="form_box"> <h1> diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html index a3cf0210..833f500d 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html @@ -23,7 +23,7 @@ <form action="{{ request.urlgen('mediagoblin.user_pages.media_confirm_delete', user=media.get_uploader.username, - media=media._id) }}" + media=media.id) }}" method="POST" enctype="multipart/form-data"> <div class="form_box"> <h1> diff --git a/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html index e673902b..2a449d45 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html +++ b/mediagoblin/templates/mediagoblin/user_pages/processing_panel.html @@ -41,7 +41,7 @@ </tr> {% for media_entry in processing_entries %} <tr> - <td>{{ media_entry._id }}</td> + <td>{{ media_entry.id }}</td> <td>{{ media_entry.title }}</td> <td>{{ media_entry.created.strftime("%F %R") }}</td> {% if media_entry.transcoding_progress %} @@ -69,7 +69,7 @@ </tr> {% for media_entry in failed_entries %} <tr> - <td>{{ media_entry._id }}</td> + <td>{{ media_entry.id }}</td> <td>{{ media_entry.title }}</td> <td>{{ media_entry.created.strftime("%F %R") }}</td> {% if media_entry.get_fail_exception() %} @@ -97,7 +97,7 @@ </tr> {% for entry in processed_entries %} <tr> - <td>{{ entry._id }}</td> + <td>{{ entry.id }}</td> <td><a href="{{ entry.url_for_self(request.urlgen) }}">{{ entry.title }}</a></td> <td>{{ entry.created.strftime("%F %R") }}</td> </tr> diff --git a/mediagoblin/templates/mediagoblin/user_pages/user.html b/mediagoblin/templates/mediagoblin/user_pages/user.html index 4f7b1208..65c636b9 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/user.html +++ b/mediagoblin/templates/mediagoblin/user_pages/user.html @@ -90,7 +90,7 @@ </h1> {% if not user.url and not user.bio %} - {% if request.user and (request.user._id == user._id) %} + {% if request.user and (request.user.id == user.id) %} <div class="profile_sidebar empty_space"> <p> {% trans %}Here's a spot to tell others about yourself.{% endtrans %} @@ -112,7 +112,7 @@ <div class="profile_sidebar"> {% include "mediagoblin/utils/profile.html" %} {% if request.user and - (request.user._id == user._id or request.user.is_admin) %} + (request.user.id == user.id or request.user.is_admin) %} <a href="{{ request.urlgen('mediagoblin.edit.profile') }}?username={{ user.username }}"> {%- trans %}Edit profile{% endtrans -%} @@ -139,7 +139,7 @@ {% include "mediagoblin/utils/feed_link.html" %} </div> {% else %} - {% if request.user and (request.user._id == user._id) %} + {% if request.user and (request.user.id == user.id) %} <div class="profile_showcase empty_space"> <p> {% trans -%} diff --git a/mediagoblin/templates/mediagoblin/utils/collection_gallery.html b/mediagoblin/templates/mediagoblin/utils/collection_gallery.html index ab5e46ea..dcc59244 100644 --- a/mediagoblin/templates/mediagoblin/utils/collection_gallery.html +++ b/mediagoblin/templates/mediagoblin/utils/collection_gallery.html @@ -38,7 +38,7 @@ <a href="{{ entry_url }}">{{ item.note }}</a> {% endif %} {% if request.user and - (item.in_collection.creator == request.user._id or + (item.in_collection.creator == request.user.id or request.user.is_admin) %} {%- set remove_url=request.urlgen( 'mediagoblin.user_pages.collection_item_confirm_remove', |