Exemplo n.º 1
0
def news_view(req, pk):
    ne = news.get_one_news(pk)
    if not ne:
        return HttpResponse(status=404)
    new_list = News.objects.all()[0:6]
    news_content = news.process_content_newline(ne.context)

    context = {"name": req.session.get("name", ''), "news": ne, "news_list": new_list, "news_content": news_content}
    return render_to_response("news.html", context)
Exemplo n.º 2
0
def delete_news(req):
    news_id = req.GET.get("id", None)
    try:
        news_id = int(news_id)
    except (TypeError, ValueError):
        return HttpResponse(status=400)
    the_news = news.get_one_news(news_id)
    if the_news is None:
        return HttpResponse(status=404)
    the_news.delete()
    return SimpleResponse(True)
Exemplo n.º 3
0
def manage_check_news(req):
    news_id = req.GET.get("id", None)
    try:
        news_id = int(news_id)
    except (ValueError, TypeError):
        return HttpResponse(status=400)
    the_news = news.get_one_news(news_id)
    if the_news is None:
        return HttpResponse(status=404)
    news_content = news.process_content_newline(the_news.context)
    return render_to_response("admins/check_news.html", {"news": the_news, "news_content": news_content})
Exemplo n.º 4
0
def delete_news(req):
    news_id = req.GET.get("id", None)
    try:
        news_id = int(news_id)
    except (TypeError, ValueError):
        return HttpResponse(status=400)
    the_news = news.get_one_news(news_id)
    if the_news is None:
        return HttpResponse(status=404)
    the_news.delete()
    return SimpleResponse(True)
Exemplo n.º 5
0
def update_news(req):
    news_id = req.POST.get("id", None)
    try:
        news_id = int(news_id)
    except (TypeError, ValueError):
        return HttpResponse(status=400)
    the_news = news.get_one_news(news_id)
    if the_news is None:
        return HttpResponse(status=404)
    ser = NewsSerializer(the_news)
    ser.update(the_news, req.data)
    return SimpleResponse(True)
Exemplo n.º 6
0
def update_news(req):
    news_id = req.POST.get("id", None)
    try:
        news_id = int(news_id)
    except (TypeError, ValueError):
        return HttpResponse(status=400)
    the_news = news.get_one_news(news_id)
    if the_news is None:
        return HttpResponse(status=404)
    ser = NewsSerializer(the_news)
    ser.update(the_news, req.data)
    return SimpleResponse(True)
Exemplo n.º 7
0
def news_view(req, pk):
    ne = news.get_one_news(pk)
    if not ne:
        return HttpResponse(status=404)
    new_list = News.objects.all()[0:6]
    news_content = news.process_content_newline(ne.context)

    context = {
        "name": req.session.get("name", ''),
        "news": ne,
        "news_list": new_list,
        "news_content": news_content
    }
    return render_to_response("news.html", context)
Exemplo n.º 8
0
def manage_check_news(req):
    news_id = req.GET.get("id", None)
    try:
        news_id = int(news_id)
    except (ValueError, TypeError):
        return HttpResponse(status=400)
    the_news = news.get_one_news(news_id)
    if the_news is None:
        return HttpResponse(status=404)
    news_content = news.process_content_newline(the_news.context)
    return render_to_response("admins/check_news.html", {
        "news": the_news,
        "news_content": news_content
    })