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.
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
#
# 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%}