def add_data():
    u_test = User(
        username="******",
        first_name="Jan",
        last_name="Tester",
        password=make_password("testuser"),
    )
    u_test.save()
    up = UserProfile(
        user=u_test,
        is_member=True,
        blog_name="Zapagaloogah",
        blog_url="https://zapagaloogah.spotblog.unk",
    )
    up.save()

    u_admin = User(
        username="******",
        first_name="Sten",
        last_name="Admin",
        password=make_password("adminuser"),
    )
    u_admin.save()
    up = UserProfile(
        user=u_admin,
        is_member=True,
    )
    up.save()

    n = News(
        title="Dit is nieuws",
        text="En dit is de omschrijving",
        added_by=u_admin,
    )
    n.save()

    q1 = Quote(
        title="Zo hoort het!",
        text="<Habbie> wat een kniesoor\n<Domilijn> Gezondheid!",
        added_by=u_test,
    )
    q1.save()

    q2 = Quote(
        title="Grote jongen",
        text=
        "12:31 < RS-232> Emphyrio: dan nee dank je. ik heb 11\" en wil dat formaat graag houden.",
        added_by=u_test,
    )
    q2.save()
def add_data(): 
    u_test = User(
        username="******",
        first_name="Jan",
        last_name="Tester",
        password=make_password("testuser"),
    )
    u_test.save()
    up = UserProfile(
        user=u_test,
        is_member=True,
        blog_name="Zapagaloogah",
        blog_url="https://zapagaloogah.spotblog.unk",
    )
    up.save()

    u_admin = User(
        username="******",
        first_name="Sten",
        last_name="Admin",
        password=make_password("adminuser"),
    )
    u_admin.save()
    up = UserProfile(
        user=u_admin,
        is_member=True,
    )
    up.save()

    n = News(
        title = "Dit is nieuws",
        text = "En dit is de omschrijving",
        added_by = u_admin,
    )
    n.save()

    q1 = Quote(
        title="Zo hoort het!",
        text="<Habbie> wat een kniesoor\n<Domilijn> Gezondheid!",
        added_by=u_test,
    )
    q1.save()

    q2 = Quote(
        title="Grote jongen",
        text="12:31 < RS-232> Emphyrio: dan nee dank je. ik heb 11\" en wil dat formaat graag houden.",
        added_by=u_test,
    )
    q2.save()
Exemplo n.º 3
0
def news_add(request):
    if not 'news.add_news' in request.user.get_all_permissions():
        return cnq_render_to_response('error.html', request, {
            'error_message': "You are not allowed to add news items.",
        })

    # Nothing was POSTed? Just display the form.
    if not 'news_title' in request.POST:
        return cnq_render_to_response('news_add.html', request, { })

    # News was POSTed. Try to add it.
    error_message = ""

    if len(request.POST['news_title']) == 0:
        error_message = "Please enter the news title."
    elif len(request.POST['news_text']) == 0:
        error_message = "Please enter the news text."

    if len(error_message) > 0:
        return cnq_render_to_response('news_add.html', request, {
            'body_top_error': error_message,
            'news_text': request.POST['news_text'],
            'news_title': request.POST['news_title'],
        })

    n = News()
    n.title = request.POST['news_title']
    n.text = request.POST['news_text']
    n.added_by = request.user
    n.save()

    # We should redirect to /news/<new_id>/ here, with possibly the
    # message "Quote added" at the top.
    return HttpResponseRedirect("/news/")
Exemplo n.º 4
0
def news_add(request):
    if not 'news.add_news' in request.user.get_all_permissions():
        return cnq_render_to_response(
            'error.html', request, {
                'error_message': "You are not allowed to add news items.",
            })

    # Nothing was POSTed? Just display the form.
    if not 'news_title' in request.POST:
        return cnq_render_to_response('news_add.html', request, {})

    # News was POSTed. Try to add it.
    error_message = ""

    if len(request.POST['news_title']) == 0:
        error_message = "Please enter the news title."
    elif len(request.POST['news_text']) == 0:
        error_message = "Please enter the news text."

    if len(error_message) > 0:
        return cnq_render_to_response(
            'news_add.html', request, {
                'body_top_error': error_message,
                'news_text': request.POST['news_text'],
                'news_title': request.POST['news_title'],
            })

    n = News()
    n.title = request.POST['news_title']
    n.text = request.POST['news_text']
    n.added_by = request.user
    n.save()

    # We should redirect to /news/<new_id>/ here, with possibly the
    # message "Quote added" at the top.
    return HttpResponseRedirect("/news/")