def add_bookmark(): """ Add a bookmark to the database """ add_bookmark = True form = BookmarkForm() if form.validate_on_submit(): bookmark = Bookmark(name=form.name.data, url=form.url.data, description=form.description.data, user_id=current_user.id) try: # add bookmark to the database db.session.add(bookmark) db.session.commit() flash('You have successfully added a new bookmark.') except: # in case bookmark name already exists flash('Error: bookmark name already exists.') # redirect to bookmarks page return redirect(url_for('profile.list_bookmarks')) # load bookmark template return render_template('profile/bookmarks/bookmark.html', action="Add", add_bookmark=add_bookmark, form=form, title="Add Bookmark")
def edit_bookmark(id): """ Edit a bookmark """ add_bookmark = False bookmark = Bookmark.query.get_or_404(id) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): bookmark.name = form.name.data bookmark.url = form.url.data bookmark.description = form.description.data db.session.commit() flash('You have successfully edited the bookmark.') # redirect to the bookmarks page return redirect(url_for('profile.list_bookmarks')) form.description.data = bookmark.description form.url.data = bookmark.url form.name.data = bookmark.name return render_template('profile/bookmarks/bookmark.html', action="Edit", add_bookmark=add_bookmark, form=form, bookmark=bookmark, title="Edit Bookmark")
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data destination = form.destination.data outbound_date = form.outbound_date.data outbound_time = form.outbound_time.data inbound_date = form.inbound_date.data inbound_time = form.inbound_time.data tags = form.tags.data bm = Bookmark(user=current_user, url=url, description=description, destination=destination, tags=tags, outbound_date=outbound_date, outbound_time=outbound_time, inbound_date=inbound_date, inbound_time=inbound_time) db.session.add(bm) db.session.commit() flash("Stored trip '{}'".format(description)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title="Add a Trip")
def add(): user = Users("Debabrata", "Patnaik") form = BookmarkForm() form.userform.data = user.getfullname()[:3] # if request.method == "POST": # url = request.form["url"] # user = request.form.get("user","Deb") # store_bookmarks(url, user) # app.logger.debug("Stored URL: " + url) # flash("Stored URL: " + url) # return redirect(url_for('index')) # return render_template("add.html") if form.validate_on_submit(): print form.url.data, form.description.data try: print form.userform except Exception, exc: print exc url = form.url.data description = form.description.data user = form.userform.data store_bookmarks(url, user, description) app.logger.debug("Stored URL: " + url) flash("Stored URL: {}".format(url)) return redirect(url_for("index"))
def add(): form = BookmarkForm() if form.validate_on_submit(): url, description = form.url.data, form.description.data store_bookmark(url, description) flash(f"stored url: {url}") 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 store_bookmark(url, description) flash("You have successfully bookmarked {}".format(url)) 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 store_bookmark(url, description) flash("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(): url = form.url.data description = form.description.data store_bookmark(url, description) flash("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(): url = form.url.data description = form.description.data store_bookmark(url, description) flash(f'Stored {description}') app.logger.debug(f'Stored {url} as {description}') return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() # If method=GET OR form-content is invalid, then... if form.validate_on_submit(): url = form.url.data description = form.description.data store_bookmark(url, description) flash("Stored bookmark '{}'".format(url)) 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(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() if form.validate_on_submit(): url = form.url.data description = form.description.data #url = request.form['url'] #getting data from 'form' dictionary(works with request reference) store_bookmark(url, description) flash('Bookmark saved: {}'.format(description)) #app.logger.debug('stored url:' + url) 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 store_bookmark(url, description) # app.logger.debug('stored_url: ' + url) flash("store_bookmark '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form)
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 Trip")
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("Store '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): db.session.add( Bookmark(user=logged_in_user(), url=form.obj.data, description=form.description.data)) db.session.commit() flash("Stored description {}".format(form.description.data)) return redirect(url_for('index')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = request.form['url'] bm = Bookmark(user=current_user, url=url) db.session.add(bm) db.session.commit() application.logger.debug('URL:' + url) flash("Stored url: {}".format(url)) return redirect(url_for('return_200')) return render_template('add.html', form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description=form.description.data store_bookmark(url,description) # app.logger.debug('stored url %s' % url) flash("Stored bookmark '{}'".format(description)) return redirect(url_for('index')) return render_template('add.html',Text="1232",form=form)
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 %s" % bookmark.description) return redirect(url_for('user',username=current_user.username)) return render_template('edit.html',form=form,title='Edit Bookmark')
def add(): form = BookmarkForm() if form.validate_on_submit(): url = form.url.data description = form.description.data bm = Bookmark(user=logged_in_user(), url=url, description=description) db.session.add(bm) db.session.commit() flash("Stored bookmak '{}'.".format(description)) return redirect(url_for("index")) return render_template("add.html", form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): # url = request.form['url'] # store_bookmark(url) url = form.url.data description = form.description.data store_bookmark(url, description) flash("please find below list of URLs.") flash("Bookmark is :- '{}'".format(url)) return redirect(url_for('hello')) return render_template('Add.html', form=form)
def add_bookmark(): form = BookmarkForm() # checks http request and form if form.validate_on_submit(): url = form.url.data description = form.description.data bm = Bookmark(url=url, description=description) db.session.add(bm) db.session.commit() flash(f"stored bookmark: {url}") 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 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(bm.description)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title="Add a bookmark")
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("Bookmark Successfully Added") return redirect(url_for('index')) return render_template('add.html',form=form)
def editUrl(bookmarkid): bookmark = bookmarkDB.query.get(bookmarkid) form = BookmarkForm(obj=bookmark) if form.validate_on_submit(): form.populate_obj(bookmark) db.session.commit() flash("Successfully edited the bookmark") return redirect(url_for("user", userid=current_user.id)) return render_template('addUrlForm.html', form=form, user=current_user, title="Edit bookmark")
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 = Bookmark(url=url, description=description, user=current_user) db.session.add(bm) db.session.commit() flash('Stored bookmark: {}'.format(url)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title='Add Bookmark')
def edit_bookmark(id): b = g.user.bid(id) form = BookmarkForm(obj=b) if not b: abort(403) if form.validate_on_submit(): form.populate_obj(b) b.updated = datetime.utcnow() db.session.add(b) db.session.commit() flash("Bookmark %s updated" % (form.title.data), category="info") return redirect(url_for("index")) return render_template("edit.html", title="Edit", form=form)
def edit_bookmark(id): b = g.user.bid(id) form = BookmarkForm(obj=b) if not b: abort(403) if form.validate_on_submit(): form.populate_obj(b) b.updated = datetime.utcnow() db.session.add(b) db.session.commit() flash('Bookmark %s updated' % (form.title.data), category='info') return redirect(url_for('index')) return render_template('edit.html', title='Edit', form=form)
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('Your bookmark was saved succesfully') return redirect(url_for('main.user', username=current_user.username)) return render_template('bookmark_form.html', form=form, title='Edit Bookmark')
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 = Bookmark(url=url, description=description, user=current_user) db.session.add(bm) db.session.commit() app.logger.debug('stored url ' + url) flash("Stored '{0}'".format(description)) return redirect(url_for('index')) return render_template('bookmark_form.html', form=form, title='Add new bookmark')
def edit_bookmark(bookmark_id): bookmark = models.Bookmark.query.get_or_404(bookmark_id) print(type(bookmark)) 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), "success") return redirect(url_for('user', username=current_user.username)) return render_template('bookmark_form.html', form=form, title='Edit Bookmark')
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("Bookmark Successfully Added") 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 with open('test.txt', 'w') as f: f.write(url) f.write(description) bm = Bookmark(user=current_user, url=url, description=description) db.session.add(bm) db.session.commit() app.logger.debug('stored url: {} {}'.format(url, description)) 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=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 new_bookmark(): form = BookmarkForm() if form.validate_on_submit(): b = Bookmark() form.populate_obj(b) b.owner_id = g.user.id b.created = datetime.utcnow() b.tags = " ".join([t.strip() for t in form.tags.data.strip().split(",")]).lower() b.clicks = 0 if not form.title.data: soup = BSoup(urlopen(form.url.data)) b.title = soup.title.string db.session.add(b) db.session.commit() flash("New bookmark %s added" % (b.title), category="info") return redirect(url_for("index")) return render_template("new.html", title="New", form=form)
def add(): form = BookmarkForm() if form.validate_on_submit(): # time_of_day = form.time_of_day.data food_word_1 = form.food_word_1.data food_word_2 = form.food_word_2.data food_word_3 = form.food_word_3.data amount_1 = form.amount_1.data amount_2 = form.amount_2.data amount_3 = form.amount_3.data weather = form.weather.data mood = form.mood.data bm = Bookmark(user=current_user, food_word_1=food_word_1, food_word_2=food_word_2, food_word_3=food_word_3, amount_1=amount_1, amount_2=amount_2, amount_3=amount_3, weather=weather, mood=mood) db.session.add(bm) db.session.commit() # flash("Stored '{}'".format(food_word_1, food_word_2, food_word_3 )) return redirect(url_for('index')) return render_template('add.html', form=form)