def store_bookmark(url, description): try: bm = models.Bookmark(user=logged_in_user(), url=url, description=description) db.session.add(bm) db.session.commit() except OperationalError: models.create_db()
def bookmark(): global registered_user if registered_user is None: return redirect(url_for('signup')) book = request.form['bookmark'] bookmark = models.Bookmark(book, registered_user.id) db.session.add(bookmark) db.session.commit() return redirect(url_for('subsec', news=book))
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(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)
def add(): form = BookmarkForm() # On a GET request, the fields are empty and the form variables are also empty. On a POST request, the variables are full. This will likely only work because the action was "", as that means it referring to a still available form to read the values of if form.validate_on_submit(): # This line also checks to make sure the method is not GET url = form.url.data description = form.description.data bm = models.Bookmark(user=logged_in_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) # form=form is sent because the template is actually using the form to populate the DOM with form fields
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(user=current_user, url=url, description=description) db.session.add(bm) db.session.commit() # app.logger.debug('stored url: ' + url) flash("stored '{}' ".format(description)) return redirect(url_for('index')) return render_template("add.html", form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(user=current_user, url=url, description=description) db.session.add(bm) db.session.commit() flash(f'stored bookmark {description}', 'success') return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title="Add form")
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = models.Bookmark(user=logged_user(), url=url, description=description) db.session.add( bm) # TODO the object has been aleady added through manage.initdb db.session.commit() flash('Stored bookmark "{}"'.format(url)) app.logger.debug('strored url: ' + url) # @TODO print in debug mode return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): app.logger.debug("flag") form = BookmarkForm() if request.method == "POST" and form.Ourvalidate(): app.logger.debug("flag") url = form.url.data description = form.description.data bm = models.Bookmark(user=current_user, url=url, description=description) db.session.add(bm) db.session.commit() app.logger.debug('stored url: ' + url) flash("Success : Stored Bookmark '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): task = form.task.data description = form.description.data time = form.time.data company = form.company.data workdate = form.workdate.data bm = models.Bookmark(user=current_user, task=task, description=description, time=time, company=company, workdate=workdate) db.session.add(bm) db.session.commit() # app.logger.debug('stored url: ' + url) flash("stored '{}' ".format(description)) return redirect(url_for('index')) return render_template("add.html", form=form)