Exemplo n.º 1
0
def add():
    form = BookmarkForm()
    application.logger.info('Route to /add')
    application.logger.debug('no reroute from root to /add')
    if form.validate_on_submit():
        url = form.url.data
        description = form.description.data
        user = form.user.data
        application.logger.info(str(url), str(description), str(user))
        print(db.session)
        bkusr = User.query.filter_by(username=user).first()
        if not bkusr and user:
            bkusr = User(username=user, email=user + "@thermos.com")
            db.session.add(bkusr)
        tags = form.tags.data
        bkm = Bookmark(url=url,
                       description=description,
                       user=bkusr or current_user,
                       bkmrkusername=bkusr.username,
                       tags=tags)
        db.session.add(bkm)
        db.session.commit()
        storebookmark(url, user, description)
        # if request.method == "POST":
        #     url = request.form.get("url")
        #     user = request.form.get("user")
        #     storebookmark(url, user)
        application.logger.info("Added url for user url: {}, user: {}".format(
            url, user or "Debabrata"))
        flash("Bookmarked url: {} for user: {}".format(
            url, user if user else "Debabrata(Default)"))
        return redirect(url_for("index"))
    return render_template("bookmarkform.html", form=form)
Exemplo n.º 2
0
def editBookmark(bookmark_id):
	bookmark = Bookmark.query.get_or_404(bookmark_id)
	if current_user != bookmark.user:
		abort(403)
	form  = BookmarkForm(obj=bookmark)
	if form.validate_on_submit():
		form.populate_obj(bookmark)
		db.session.commit()
		flash("Stored '{}'".format(bookmark.description))
		return redirect(url_for('.user', username=current_user.username))
	return render_template('bookmark_form.html', form=form, title="Edit bookmark")
Exemplo n.º 3
0
def add():
    form = BookmarkForm()
    if form.validate_on_submit():
        url = form.url.data
        description = form.description.data
        bm = Bookmark(user=current_user, url=url, description=description)
        db.session.add(bm)
        db.session.commit()
        flash(f"stored : {description}")
        return redirect(url_for('index'))
    return render_template('add.html', form=form)
Exemplo n.º 4
0
def add():
    form = BookmarkForm()
    if form.validate_on_submit():
        url = form.url.data
        description = form.description.data
        bm = Bookmark(user=current_user, url=url, description=description)
        db.session.add(bm)
        db.session.commit()
        flash("Stored '{}'".format(description))
        return redirect(url_for('index'))
    return render_template('bookmark_form.html', form=form, title="Add a bookmark")
Exemplo n.º 5
0
def edit_bookmark(bookmark_id):
    bookmark = Bookmark.query.get_or_404(bookmark_id)
    if current_user != bookmark.user:
        abort(403)
    form = BookmarkForm(obj=bookmark)
    if form.validate_on_submit():
        form.populate_obj(bookmark)
        db.session.commit()
        flash('Stored "{}"'.format(bookmark.description))
        return redirect(url_for('user', username=current_user.username))
    return render_template('bookmark_form.html', form=form, title='Edit bookmark')
Exemplo n.º 6
0
def add():
    form = BookmarkForm()
    if form.validate_on_submit():
        url = form.url.data
        description = form.description.data
        tags = form.tags.data
        bm = Bookmark(user=current_user, url=url, description=description, tags=tags)
        db.session.add(bm)
        db.session.commit()
        flash('Stored "{}"'.format(description))
        return redirect(url_for('index'))
    return render_template('bookmark_form.html', form=form, title='Add a bookmark')
Exemplo n.º 7
0
def add():
	form = BookmarkForm()
	# Checks the http request method and the user submitted data in the form
	if form.validate_on_submit():
		url = form.url.data
		description = form.description.data
		tags = form.tags.data
		bm = Bookmark(user=current_user, url=url, description=description, tags=tags)
		db.session.add(bm)
		db.session.commit()
		flash("Stored '{}'".format(description))
		return redirect(url_for('main.index'))
	return render_template('bookmark_form.html', form=form, title="Add a bookmark")
Exemplo n.º 8
0
def add():
    form = BookmarkForm()
    if form.validate_on_submit():
        url = form.url.data
        description = form.description.data
        bm = Bookmark(user=current_user,
                      url=url,
                      description=description)
        db.session.add(bm)
        db.session.commit()
        flash("Stored '{}'".format(description))
        return redirect(url_for('index'))
    return render_template('add.html', form=form)
Exemplo n.º 9
0
def add():
    form = BookmarkForm()
    if form.validate_on_submit():
        url = form.url.data
        description = form.description.data
        tags = form.tags.data
        bookmark = Bookmark(user=current_user,
                            url=url,
                            description=description,
                            tags=tags)
        db.session.add(bookmark)
        db.session.commit()
        flash(f'Stored "{description}"')
        return redirect(url_for('index'))
    return render_template('bookmark_form.html',
                           form=form,
                           title='Add a new bookmark')