Ejemplo n.º 1
0
def user_add(request):

    form = Form(request, schema=RegistrationSchema)

    if 'form.submitted' in request.POST and form.validate():
        session = DBSession()
        username = form.data['username']
        user = User(username=username,
                    password=form.data['password'],
                    name=form.data['name'],
                    email=form.data['email'])
        session.add(user)

        headers = remember(request, username)

        redirect_url = route_url('main', request)

        return HTTPFound(location=redirect_url, headers=headers)

    login_form = login_form_view(request)

    return {
        'form': FormRenderer(form),
        'toolbar': toolbar_view(request),
        'cloud': cloud_view(request),
        'latest': latest_view(request),
        'login_form': login_form,
    }
Ejemplo n.º 2
0
def user_add(request):

    form = Form(request, schema=RegistrationSchema)

    if 'form.submitted' in request.POST and form.validate():
        session = DBSession()
        username=form.data['username']
        user = User(
            username=username,
            password=form.data['password'],
            name=form.data['name'],
            email=form.data['email']
        )
        session.add(user)

        headers = remember(request, username)

        redirect_url = route_url('main', request)

        return HTTPFound(location=redirect_url, headers=headers)

    login_form = login_form_view(request)

    return {
        'form': FormRenderer(form),
        'toolbar': toolbar_view(request),
        'cloud': cloud_view(request),
        'latest': latest_view(request),
        'login_form': login_form,
    }
Ejemplo n.º 3
0
def user_add(request):

    form = Form(request, schema=RegistrationSchema)

    if "form.submitted" in request.POST and form.validate():
        session = DBSession()
        username = form.data["username"]
        user = User(username=username, password=form.data["password"], name=form.data["name"], email=form.data["email"])
        session.add(user)

        headers = remember(request, username)

        redirect_url = request.route_url("main")

        return HTTPFound(location=redirect_url, headers=headers)

    login_form = login_form_view(request)

    return {
        "form": FormRenderer(form),
        "toolbar": toolbar_view(request),
        "cloud": cloud_view(request),
        "latest": latest_view(request),
        "login_form": login_form,
    }
Ejemplo n.º 4
0
def idea_add(request):
    target = request.GET.get('target')
    session = DBSession()
    if target:
        target = Idea.get_by_id(target)
        if not target:
            return HTTPNotFound()
        kind = 'comment'
    else:
        kind = 'idea'

    form = Form(request, schema=AddIdeaSchema)

    if 'form.submitted' in request.POST and form.validate():
        author_username = authenticated_userid(request)
        author = User.get_by_username(author_username)

        idea = Idea(
            target=target,
            author=author,
            title=form.data['title'],
            text=form.data['text']
        )

        tags = Tag.create_tags(form.data['tags'])
        if tags:
            idea.tags = tags

        session.add(idea)            
        redirect_url = route_url('idea', request, idea_id=idea.idea_id)

        return HTTPFound(location=redirect_url)

    login_form = login_form_view(request)

    return {
        'form': FormRenderer(form),
        'toolbar': toolbar_view(request),
        'cloud': cloud_view(request),
        'latest': latest_view(request),
        'login_form': login_form,
        'target': target,
        'kind': kind,
    }
Ejemplo n.º 5
0
def idea_add(request):
    target = request.GET.get('target')
    session = DBSession()
    if target:
        target = Idea.get_by_id(target, with_joinedload=False)
        if not target:
            return HTTPNotFound()
        kind = 'comment'
    else:
        kind = 'idea'

    form = Form(request, schema=AddIdeaSchema)

    if 'form.submitted' in request.POST and form.validate():
        author_username = authenticated_userid(request)
        author = User.get_by_username(author_username)

        idea = Idea(target=target,
                    author=author,
                    title=form.data['title'],
                    text=form.data['text'])

        tags = Tag.create_tags(form.data['tags'])
        if tags:
            idea.tags = tags

        session.add(idea)
        redirect_url = route_url('idea', request, idea_id=idea.idea_id)

        return HTTPFound(location=redirect_url)

    login_form = login_form_view(request)

    return {
        'form': FormRenderer(form),
        'toolbar': toolbar_view(request),
        'cloud': cloud_view(request),
        'latest': latest_view(request),
        'login_form': login_form,
        'target': target,
        'kind': kind,
    }
Ejemplo n.º 6
0
def idea_add(request):
    target = request.params.get("target")
    session = DBSession()
    if target:
        target = Idea.get_by_id(target, with_joinedload=False)
        if not target:
            return HTTPNotFound()
        kind = "comment"
    else:
        kind = "idea"

    form = Form(request, schema=AddIdeaSchema)

    if "form.submitted" in request.POST and form.validate():
        author_username = authenticated_userid(request)
        author = User.get_by_username(author_username)

        idea = Idea(target=target, author=author, title=form.data["title"], text=form.data["text"])

        tags = Tag.create_tags(form.data["tags"])
        if tags:
            idea.tags = tags

        session.add(idea)
        redirect_url = request.route_url("idea", idea_id=idea.idea_id)

        return HTTPFound(location=redirect_url)

    login_form = login_form_view(request)

    return {
        "form": FormRenderer(form),
        "toolbar": toolbar_view(request),
        "cloud": cloud_view(request),
        "latest": latest_view(request),
        "login_form": login_form,
        "target": target,
        "kind": kind,
    }