Ejemplo n.º 1
0
def edit(request,aid):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()


    if request.POST.has_key('ok'):
        articleInfo=Article.objects.get(id=aid)
        
        articleInfo.category=Category.objects.get(id=GetPostData(request,'category'))
        articleInfo.title = GetPostData(request,'title')
        articleInfo.pic = GetPostData(request,'pic')
        articleInfo.tags=GetPostData(request,'tags')
        articleInfo.summary=GetPostData(request,'summary')
        articleInfo.content = GetPostData(request,'content')

        articleInfo.save()

        return HttpResponseRedirect('/')
    else:
        articleInfo=Article.objects.get(id=aid)
        title=articleInfo.title
        content=articleInfo.content
        return my_render_to_response(request,"editarticle.html",locals())
Ejemplo n.º 2
0
def edit(request,aid):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()


    if request.POST.has_key('ok'):
        articleInfo=Article.objects.get(id=aid)
        
        articleInfo.category=Category.objects.get(id=GetPostData(request,'category'))
        articleInfo.title = GetPostData(request,'title')
        articleInfo.pic = GetPostData(request,'pic')
        articleInfo.tags=GetPostData(request,'tags')
        articleInfo.summary=GetPostData(request,'summary')
        articleInfo.content = GetPostData(request,'content')

        articleInfo.save()

        return HttpResponseRedirect('/')
    else:
        articleInfo=Article.objects.get(id=aid)
        title=articleInfo.title
        content=articleInfo.content
        return my_render_to_response(request,"editarticle.html",locals())
Ejemplo n.º 3
0
def home(request):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()

    articleList=Article.objects.order_by("-createtime").all()

    return my_render_to_response(request,"home.html",locals())
Ejemplo n.º 4
0
def home(request):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()

    articleList=Article.objects.order_by("-createtime").all()

    return my_render_to_response(request,"home.html",locals())
Ejemplo n.º 5
0
def show(request,aid):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()

    articleInfo=Article.objects.get(id=aid)
    title=articleInfo.title
    content=articleInfo.content
    articleInfo.views+=1
    if not articleInfo.createtime:
        articleInfo.createtime=datetime.datetime.now()

    articleInfo.save()

    return my_render_to_response(request,"articleshow.html",locals())
Ejemplo n.º 6
0
def show(request,aid):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()

    articleInfo=Article.objects.get(id=aid)
    title=articleInfo.title
    content=articleInfo.content
    articleInfo.views+=1
    if not articleInfo.createtime:
        articleInfo.createtime=datetime.datetime.now()

    articleInfo.save()

    return my_render_to_response(request,"articleshow.html",locals())
Ejemplo n.º 7
0
def category(request, action="", cid=-1):
    viewsTopArticles = common.viewsTopArticles()
    remarkTopArticles = common.remarkTopArticles()
    newTopArticles = common.newTopArticles()
    categoryList = common.categoryList()

    if request.POST.has_key('ok'):
        name = request.POST['name']
        if cid != -1:
            categoryInfo = Category(name=name)
        else:
            categoryInfo = Category.objects.get(id=cid)
            categoryInfo.name = name
        categoryInfo.save()

        return HttpResponseRedirect('/')
    else:

        return my_render_to_response(request, "category.html", locals())
Ejemplo n.º 8
0
def category(request,action="",cid=-1):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()
    

    if request.POST.has_key('ok'):
        name = request.POST['name']
        if cid!=-1:
            categoryInfo=Category(name=name)
        else:
            categoryInfo=Category.objects.get(id=cid)
            categoryInfo.name=name
        categoryInfo.save()

        return HttpResponseRedirect('/')
    else:

        return my_render_to_response(request,"category.html",locals())
Ejemplo n.º 9
0
def add(request):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()

    if request.POST.has_key('ok'):
        category=Category.objects.get(id=GetPostData(request,'category'))
        title = GetPostData(request,'title')
        pic = GetPostData(request,'pic')
        tags=GetPostData(request,'tags')
        summary=GetPostData(request,'summary')
        content = GetPostData(request,'content')
        
        if len(summary)==0:
            summary=summary[1:80] if len(summary)>80 else summary

        articleInfo = Article(category=category,
                              title = title,
                              pic="",
                              tags=tags,
                              summary=summary,
                              content = content,
                              createtime=datetime.datetime.now(),
                              views=0,
                              comments=0,
                              goods=0,
                              bads=0,
                              status=1,
                              user_id=1,
                              user_name="admin")
        articleInfo.save()

        return HttpResponseRedirect('/')
    else:
        return my_render_to_response(request,"addarticle.html",locals())
Ejemplo n.º 10
0
def add(request):
    viewsTopArticles=common.viewsTopArticles()
    remarkTopArticles=common.remarkTopArticles()
    newTopArticles=common.newTopArticles()
    categoryList=common.categoryList()

    if request.POST.has_key('ok'):
        category=Category.objects.get(id=GetPostData(request,'category'))
        title = GetPostData(request,'title')
        pic = GetPostData(request,'pic')
        tags=GetPostData(request,'tags')
        summary=GetPostData(request,'summary')
        content = GetPostData(request,'content')
        
        if len(summary)==0:
            summary=summary[1:80] if len(summary)>80 else summary

        articleInfo = Article(category=category,
                              title = title,
                              pic="",
                              tags=tags,
                              summary=summary,
                              content = content,
                              createtime=datetime.datetime.now(),
                              views=0,
                              comments=0,
                              goods=0,
                              bads=0,
                              status=1,
                              user_id=1,
                              user_name="admin")
        articleInfo.save()

        return HttpResponseRedirect('/')
    else:
        return my_render_to_response(request,"addarticle.html",locals())