# GNU MediaGoblin -- federated, autonomous media hosting # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . import logging from mediagoblin.tools import pluginapi from mediagoblin import messages, mg_globals from mediagoblin.media_types.blog import forms as blog_forms from mediagoblin.media_types.blog.models import Blog from mediagoblin.media_types.blog.lib import ( may_edit_blogpost, set_blogpost_state, get_blog_by_slug) from mediagoblin.decorators import ( require_active_login, active_user_from_url, get_media_entry_by_id, uses_pagination) from mediagoblin.tools.pagination import Pagination from mediagoblin.tools.response import (render_to_response, redirect, render_404) from mediagoblin.tools.translate import pass_to_ugettext as _ from mediagoblin.tools.text import ( convert_to_tag_list_of_dicts, media_tags_as_string, cleaned_markdown_conversion) from mediagoblin.db.models import MediaEntry, LocalUser from mediagoblin.notifications import add_comment_subscription _log = logging.getLogger(__name__) @require_active_login def blog_edit(request): """ View for editing an existing blog or creating a new blog if user have not exceeded maximum allowed acount of blogs. """ url_user = request.matchdict.get('user', None) blog_slug = request.matchdict.get('blog_slug', None) config = pluginapi.get_config('mediagoblin.media_types.blog') max_blog_count = config['max_blog_count'] form = blog_forms.BlogEditForm(request.form) # creating a blog if not blog_slug: if Blog.query.filter_by(author=request.user.id).count()