aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Spaeth <Sebastian@SSpaeth.de>2013-12-12 18:03:47 +0100
committerSebastian Spaeth <Sebastian@SSpaeth.de>2013-12-12 18:03:47 +0100
commit461cd7c10d67e04cde4155f32bcd13d174318ba2 (patch)
tree06771a1385b6857739619fd332ae75fc2b8f5598
parentc518d5421d2a0861cc3ad3791bae6d3a63ca39bc (diff)
downloadmediagoblin-461cd7c10d67e04cde4155f32bcd13d174318ba2.tar.lz
mediagoblin-461cd7c10d67e04cde4155f32bcd13d174318ba2.tar.xz
mediagoblin-461cd7c10d67e04cde4155f32bcd13d174318ba2.zip
Force evaluation of Query() through count()
Otherwise "blogs" is a query that evaluates to true, even if the user has no blogs. This fixes the bug that the blog link is shown on a user's profile page even if she has no blogs at all.
-rw-r--r--mediagoblin/media_types/blog/__init__.py3
-rw-r--r--mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_blogs_dashboard.html7
2 files changed, 4 insertions, 6 deletions
diff --git a/mediagoblin/media_types/blog/__init__.py b/mediagoblin/media_types/blog/__init__.py
index 8a61c6e0..eca4c8fb 100644
--- a/mediagoblin/media_types/blog/__init__.py
+++ b/mediagoblin/media_types/blog/__init__.py
@@ -103,9 +103,10 @@ class BlogPostMediaManager(MediaManagerBase):
return blog
def add_to_user_home_context(context):
+ """Inject a user's blogs into a (user home page) template context"""
blogs = context['request'].db.Blog.query.filter_by(author=context['user'].id)
- if blogs:
+ if blogs.count():
context['blogs'] = blogs
else:
context['blogs'] = None
diff --git a/mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_blogs_dashboard.html b/mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_blogs_dashboard.html
index 483c1455..cb781b53 100644
--- a/mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_blogs_dashboard.html
+++ b/mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_blogs_dashboard.html
@@ -14,14 +14,11 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#}
-
-{#This injects the URL to a user's blog dashboard on her profile.
-#}
+#}{#This injects the URL to a user's blog dashboard on her profile.#}
{%if blogs %}
<h3>Blog</h3>
{% set blogs_url = request.urlgen('mediagoblin.media_types.blog.blog_admin_dashboard',
blogs=blogs, user=user.username) %}
-<p><a href="{{ blogs_url }}"><em>Go to blogs</em></a></p>
+<p><a href="{{ blogs_url }}"><em>Go to user's blog</em></a></p>
{%endif%}