# Path: cms_content/settings.py
# ROOT_URL = getattr(settings, 'CMS_CONTENT_ROOT_URL', '/cms/')
# 
# Path: cms_content/settings.py
# ARTICLE_PERPAGE = getattr(settings, 'CMS_CONTENT_ARTICLE_PERPAGE', 10)


from datetime import datetime
from django.http import HttpResponseRedirect
from django.db.models import F
from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.shortcuts import get_list_or_404
from django.template.context import RequestContext
from django.core.paginator import Paginator
from django.core.paginator import InvalidPage
from django.core.paginator import EmptyPage
from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import cache_page
from django.utils.translation import ugettext_lazy as _
from cms_content.models import *
from cms_content.utils.render import render_to
from cms_content.forms import CMSArticleFrontendForm
from cms_content.settings import ROOT_URL
from cms_content.settings import ARTICLE_PERPAGE
            from django.core.exceptions import ValidationError
        'article': article,
        'article_tags': article_tags,
        'hits': article.hits,
    }

@login_required
@render_to('cms_content/article_add.html')
def article_add(request):
    if request.method=="POST":
        form = CMSArticleFrontendForm(request.POST)
        if form.is_valid():
            menu_count = CMSMenuID.objects.count() + 1
            category = form.cleaned_data['category']
            cate = CMSCategory.objects.get(name=category)
            menu = CMSMenuID.objects.create(menuid=menu_count, parent=cate.menu.menuid)
            article = CMSArticle.objects.create(
                title = form.cleaned_data['title'],
                content = form.cleaned_data['content'], 
                slug = form.cleaned_data['slug'], 
                category = category,
                created_by = request.user,
                created_date = datetime.now(),
                last_modified_by = request.user,
                last_modified_date = datetime.now(),
                pub_status = 'pub',
                menu = menu,
            )
            article.save()
        else:
            raise ValidationError('Error')

# Path: cms_content/settings.py
# ROOT_URL = getattr(settings, 'CMS_CONTENT_ROOT_URL', '/cms/')
# 
# Path: cms_content/settings.py
# ARTICLE_PERPAGE = getattr(settings, 'CMS_CONTENT_ARTICLE_PERPAGE', 10)


# Path: cms_content_patch/views.py
from datetime import datetime
from django.http import HttpResponseRedirect
from django.db.models import F
from django.shortcuts import render_to_response
from django.shortcuts import get_object_or_404
from django.shortcuts import get_list_or_404
from django.template.context import RequestContext
from django.core.paginator import Paginator
from django.core.paginator import InvalidPage
from django.core.paginator import EmptyPage
from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import cache_page
from django.utils.translation import ugettext_lazy as _
from cms_content.models import *
from cms_content.utils.render import render_to
from cms_content.forms import CMSArticleFrontendForm
from cms_content.settings import ROOT_URL
from cms_content.settings import ARTICLE_PERPAGE
            from django.core.exceptions import ValidationError

        'article': article,
        'article_tags': article_tags,
        'hits': article.hits,
    }

@login_required
@render_to('cms_content/article_add.html')
def article_add(request):
    if request.method=="POST":
        form = CMSArticleFrontendForm(request.POST)
        if form.is_valid():
            menu_count = CMSMenuID.objects.count() + 1
            category = form.cleaned_data['category']
            cate = CMSCategory.objects.get(name=category)
            menu = CMSMenuID.objects.create(menuid=menu_count, parent=cate.menu.menuid)
            article = CMSArticle.objects.create(
                title = form.cleaned_data['title'],
                content = form.cleaned_data['content'], 
                slug = form.cleaned_data['slug'], 
                category = category,
                created_by = request.user,
                created_date = datetime.now(),
                last_modified_by = request.user,
                last_modified_date = datetime.now(),
                pub_status = 'pub',
                menu = menu,
            )
            article.save()
        else:
            raise ValidationError('Error')

        return HttpResponseRedirect(ROOT_URL)