Beispiel #1
0
def submitlink(request):
    """
    Submit a link.
    """
    # TODO check if not already submit by user

    tags = [tag.strip() for tag in request.POST['tags'].split(',')]

    link = Link()
    link.url = request.POST['link'].strip()
    link.title = request.POST['title'].strip()
    link.created = datetime.datetime.now()
    link.comment = request.POST['comment'].strip()
    link.userID = request.session['login']
    link.username = request.session['username']
    link.private = False  # TODO
    link.tags = tags

    if 'private' in request.POST:
        link.private = True

    link.save()

    if not link.private:
        user = User.get(request.session['login'])
        user.links[link._id] = link.created
        user.save()

    request.session.flash("link added !")
    return HTTPFound(location=request.route_path('home'))