Rename a few files and minor cleanup
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 12 Dec 2013 17:56:36 +0000 (18:56 +0100)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 12 Dec 2013 17:56:36 +0000 (18:56 +0100)
Within the blog plugin, rename a few files and clean up a few things
that can be cleaned up.

mediagoblin/media_types/blog/__init__.py
mediagoblin/media_types/blog/templates/mediagoblin/blog/blog_post_listing.html
mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_blogs_dashboard.html
mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_dashboard.html [moved from mediagoblin/media_types/blog/templates/mediagoblin/blog/url_to_blogging.html with 100% similarity]
mediagoblin/media_types/blog/views.py

index 0dd9708cb23b4445b88882c3982aad74ef50d6a7..859c2162381abbbdd3e0e0ef782b2dc9cb9750a2 100644 (file)
@@ -87,7 +87,7 @@ def setup_plugin():
     pluginapi.register_routes(routes)
     pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
     pluginapi.register_template_hooks({"user_profile": "mediagoblin/blog/url_to_blogs_dashboard.html",
-                                        "blog_dashboard_home": "mediagoblin/blog/url_to_blogging.html",
+                                        "blog_dashboard_home": "mediagoblin/blog/url_to_dashboard.html",
                                     })
 
 
index 3ec84006b09ec2b93eb8977ae5fbb9541b007dff..8d7a405e644ab4d39b237073ba28e02c3b7d1c28 100644 (file)
@@ -19,9 +19,9 @@
 
 {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
 {% from "mediagoblin/utils/pagination.html" import render_pagination %}
-
+{% set blog_owner_name = blog_owner.username %}
 {% block title -%}
-  {% trans %}{{ blog_owner }} 's Blog{% endtrans %} &mdash; {{ super() }}
+  {% trans %}{{ blog_owner_name }}'s Blog{% endtrans %} &mdash; {{ super() }}
 {%- endblock %}
 
 {% block mediagoblin_head -%}
@@ -36,7 +36,7 @@
 {%- endblock %}
 
 {% block mediagoblin_content %}
-    <div class="b_list_owner"> <h1><font color="black"> {{ blog.title }} <font size="2">by {{ blog_owner }}</font> </font></h1></div>
+    <div class="b_list_owner"> <h1><font color="black"> {{ blog.title }} <font size="2">by {{ blog_owner_name }}</font> </font></h1></div>
     <div>
         {% for post in blog_posts %}
             <div class="b_listing_title"><a href="{{ post.url_for_self(request.urlgen) }}">
@@ -59,7 +59,7 @@
     <br/>
     <br/>
     {% set blog_about_url = request.urlgen('mediagoblin.media_types.blog.blog_about', 
-                                      blog_slug=blog.slug, user=blog_owner) %}
+                                      blog_slug=blog.slug, user=blog_owner_name) %}
     <a style="text-decoration:underline" href="{{ blog_about_url}}">About Blog</a>
     <br/>
     {{ render_pagination(request, pagination) }}
index cb781b533164ccabd2ef6389efd541dbdc577778..839b8a5a8e03aef95ba853acad592e07f8abbdcf 100644 (file)
@@ -18,7 +18,7 @@
 {%if blogs %}
 <h3>Blog</h3>
 {% set blogs_url = request.urlgen('mediagoblin.media_types.blog.blog_admin_dashboard', 
-                                      blogs=blogs, user=user.username) %}
+                                  user=user.username) %}
                                     
 <p><a href="{{ blogs_url }}"><em>Go to user's blog</em></a></p>
 {%endif%}
index cb34b4909a52b6a86406bf7f6dae21b7dee44a95..042881e4b6796fdfc03c9397566272dd12508bd1 100644 (file)
@@ -209,19 +209,18 @@ def blogpost_edit(request):
         })
 
 
+@active_user_from_url
 @uses_pagination
-def blog_dashboard(request, page):
+def blog_dashboard(request, page, url_user=None):
     """
     Dashboard for a blog, only accessible to
     the owner of the blog.
     """
-    url_user = request.matchdict.get('user')
-    user = request.db.User.query.filter_by(username=url_user).one()
     blog_slug = request.matchdict.get('blog_slug', None)
-    blogs = request.db.Blog.query.filter_by(author=user.id)
+    blogs = request.db.Blog.query.filter_by(author=url_user.id)
     config = pluginapi.get_config('mediagoblin.media_types.blog')
     max_blog_count = config['max_blog_count']
-    if request.user and (request.user.id == user.id or request.user.has_privilege(u'admin')):
+    if request.user and (request.user.id == url_user.id or request.user.has_privilege(u'admin')):
         if blog_slug:
             blog = blogs.filter(Blog.slug==blog_slug).first()
             if not blog:
@@ -238,32 +237,30 @@ def blog_dashboard(request, page):
                         {'blog_posts_list': blog_posts_on_a_page,
                         'blog_slug':blog_slug,
                         'blog':blog,
-                        'user':user,
+                        'user':url_user,
                         'pagination':pagination
                         })
-    if not request.user or request.user.id != user.id or not blog_slug:
+    if not request.user or request.user.id != url_user.id or not blog_slug:
         blogs = blogs.all()
         return render_to_response(
         request,
         'mediagoblin/blog/list_of_blogs.html',
         {
         'blogs':blogs,
-        'user':user,
+        'user':url_user,
         'max_blog_count':max_blog_count
         })
 
 
+@active_user_from_url
 @uses_pagination
-def blog_post_listing(request, page):
+def blog_post_listing(request, page, url_user=None):
     """
     Page, listing all the blog posts of a particular blog.
     """
-    blog_owner = request.matchdict.get('user')
     blog_slug = request.matchdict.get('blog_slug', None)
-    owner_user = User.query.filter_by(username=blog_owner).one()
     blog = request.db.Blog.query.filter_by(slug=blog_slug).first()
-
-    if not owner_user or not blog:
+    if not blog:
         return render_404(request)
 
     all_blog_posts = blog.get_all_blog_posts(u'processed').order_by(MediaEntry.created.desc())
@@ -276,7 +273,7 @@ def blog_post_listing(request, page):
         'mediagoblin/blog/blog_post_listing.html',
         {'blog_posts': blog_posts_on_a_page,
          'pagination': pagination,
-         'blog_owner': blog_owner,
+         'blog_owner': url_user,
          'blog':blog
         })