From 6a59a8abd49d921c2316fb4bd4cddf55a322b2fb Mon Sep 17 00:00:00 2001 From: Elrond Date: Mon, 2 Jan 2012 16:02:02 +0100 Subject: [PATCH 1/2] Import MigrationManager from mongo in mongo backend. Inside the mongo db backend, use the mongo MigrationManager. This is hopefully the last reference to the generic MigrationManager reference on db.util. --- mediagoblin/db/mongo/open.py | 2 +- mediagoblin/db/util.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediagoblin/db/mongo/open.py b/mediagoblin/db/mongo/open.py index 8016ced9..48c909d9 100644 --- a/mediagoblin/db/mongo/open.py +++ b/mediagoblin/db/mongo/open.py @@ -18,7 +18,7 @@ import pymongo import mongokit from paste.deploy.converters import asint from mediagoblin.db.mongo import models -from mediagoblin.db.util import MigrationManager +from mediagoblin.db.mongo.util import MigrationManager def connect_database_from_config(app_config, use_pymongo=False): diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index 3fd96a1d..1df9494c 100644 --- a/mediagoblin/db/util.py +++ b/mediagoblin/db/util.py @@ -14,5 +14,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.db.mongo.util import (MigrationManager, ObjectId, InvalidId, +from mediagoblin.db.mongo.util import (ObjectId, InvalidId, DESCENDING) From f1cdd278e7cf195e485567ed0d0d8a90cad81e48 Mon Sep 17 00:00:00 2001 From: Elrond Date: Wed, 4 Jan 2012 23:48:55 +0100 Subject: [PATCH 2/2] f691: Use StrictUndefined for templates and fix some issues References to undefined variables in templates were silently ignored/converted to None/empty strings. This makes coding lazy stuff easy, but it makes catching typos harder. (It would have catched one of the SQL things earlier!) But on the other hand it might make the current templates error out everywhere. In fact, early testing has shown two instances, that errored out. Those are fixed with this commit too. If this turns out to make things more complex and useless than actually solving any problems, it can easily be dropped again. --- mediagoblin/templates/mediagoblin/user_pages/media.html | 5 +++-- mediagoblin/templates/mediagoblin/user_pages/user.html | 3 ++- mediagoblin/tools/template.py | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index 9b331789..4b5c9337 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -60,8 +60,9 @@ {% trans date=media.created.strftime("%Y-%m-%d") -%} Added on {{ date }}. {%- endtrans %} - {% if media['uploader'] == request.user._id or - request.user['is_admin'] %} + {% if request.user and + (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) %} diff --git a/mediagoblin/templates/mediagoblin/user_pages/user.html b/mediagoblin/templates/mediagoblin/user_pages/user.html index b952e88c..78bbaf8c 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/user.html +++ b/mediagoblin/templates/mediagoblin/user_pages/user.html @@ -113,7 +113,8 @@ {% else %}