def profile(request, url): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user form = None age = None invited = False if user.is_authenticated(): #check if we've invited the user to be our friend try: inv = other_user.userprofile.invites.get(sender=user) invited = True except Invite.DoesNotExist: invited = False age = util.get_age(other_user.userprofile.birthdate) # post a comment if util.can_users_interract(user, other_user): form = myforms.CommentForm() else: form = None return render_to_response('profile/profile.html', { 'other_user': other_user, 'form': form, 'invited': invited, 'age': age }, context_instance=RequestContext(request))
def index(): custom_cookie = request.cookies.get('custom_cookie', 'undefined') print(custom_cookie) get1 = request.args.get('get1', 'No name insert') # this route implements forms for comments with a object comment_form comment_form = forms.CommentForm() return render_template('index.html', name=get1, form=comment_form)
def posts(id=None): sign_up_form = forms.SignUpForm() sign_in_form = forms.SignInForm() if sign_up_form.validate_on_submit(): handle_signup(sign_up_form) elif sign_in_form.validate_on_submit(): handle_signin(sign_in_form) if id == None: posts = models.Post.select().limit(100) return render_template('posts.html', posts=posts) else: post_id = int(id) post = models.Post.get(models.Post.id == post_id) comments = post.comments form = forms.CommentForm() if form.validate_on_submit(): models.Comment.create(user=g.user._get_current_object(), commentText=form.commentText.data, post=post) return redirect("/posts/{}".format(post_id)) return render_template('post.html', post=post, form=form, comments=comments, sign_in_form=sign_in_form, sign_up_form=sign_up_form)
def view_post(post_id): """Get all the posts that have this id""" posts = models.Post.select().where(models.Post.id == post_id) form = forms.CommentForm() if posts.count() == 0: abort(404) return render_template('stream.html', stream=posts, form=form)
def index(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): print(comment_form.username.data) print(comment_form.username.email) print(comment_form.username.comment) return render_template( 'form.html', form = comment_form )
def view_post(post_id): posts = models.Post.select().where(models.Post.id == post_id) numberOfComments = posts[0].numComments comments = models.Comments.select().where( models.Comments.post_id == post_id) form = forms.CommentForm() if form.validate_on_submit(): models.Comments.create(user_id=g.user._get_current_object(), post_id=post_id, comment=form.comment.data.strip()) models.Post.update(numComments=numberOfComments + 1).where(models.Post.id == post_id).execute() flash("Comment Posted!", "success") return redirect(request.referrer) if posts.count() == 0: abort(0) return render_template('singlePost.html', stream=posts, format=format, form=form, comments=comments)
def comment(): my_comment_form = forms.CommentForm(request.form) if request.method == 'POST' and my_comment_form.validate(): print('Username: {}\nE-mail: {}\nComment: {}'.format( my_comment_form.username.data, my_comment_form.email.data, my_comment_form.comment.data)) my_title = 'Flask Curse' return rt('comment.html', title=my_title, comment_form=my_comment_form)
def index(): commentform = forms.CommentForm() return render_template("index.html", files=getFileList(), extensions=ALLOWED_EXTENSIONS, max_fs=MAX_FILE, sz=MAX_FOLDER, cform=commentform)
def index(): comment_form = forms.CommentForm() name = 'Bubu' return render_template('09-index.html', name=name, tittle="index", form=comment_form)
def update_comment(movieid): movie_id = int(movieid) form = forms.CommentForm() list_item = models.List.select().where( models.List.user == current_user.id, models.List.movie_id == movie_id).get() list_item.comment = form.comment.data list_item.save() return redirect(url_for('movie', movieid=movieid))
def index(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate() : print (comment_form.username.data) print (comment_form.email.data) print (comment_form.comment.data) name = 'Nacho' return render_template('index.html', name=name, form = comment_form)
def comment_new(post_id): post = models.Post.query.get(post_id) form = forms.CommentForm() if form.validate_on_submit(): comment = models.Comment(form.commenter.data, form.body.data, post_id) db.session.add(comment) db.session.commit() return redirect(url_for('.show', id=post_id)) return render_template('post/show.slim', post=post, form=form)
def comment(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): user_id = session['user_id'] comment = Comment(user_id=user_id, text=comment_form.comment.data) database.session.add(comment) database.session.commit() flash("Muchas gracias por tu comentario!.") return render_template('comment.html', form=comment_form)
def agregarUsuario(): add_user = forms.CommentForm(request.form) if request.method == 'POST': try: user = au.create_user_with_email_and_password( add_user.email.data, add_user.password.data) return redirect(url_for('gestionProductos')) except: return render_template("agregar-usuario.html", form=add_user) return render_template("agregar-usuario.html", form=add_user)
def index(): commet_form = forms.CommentForm(request.form) if request.method == 'POST': print('commet_form.username.data') print('commet_form.email.data') print('commet_form.comment.data') title = "Curso flask" return render_template('index.html', title=title, form=commet_form)
def index(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): print(comment_form.username.data) print(comment_form.email.data) print(comment_form.comment.data) else: print("Error en el formulario") title = "Curso Flask" return render_template('index_form.html.j2', title=title, form = comment_form)
def add_comment(petid): form = forms.CommentForm() specific_pet_id = petid if form.validate_on_submit(): models.Comment.create(user=current_user.id, pet=specific_pet_id, text=form.text.data.strip()) flash('Comment Created!', "editpet") return redirect(f'/showpet/{specific_pet_id}') return render_template("add_comment.html", form=form)
def comment(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): user_id = User.query.filter_by(username=session['username']).first() #print user_id.id comment = Comment(user_id=user_id.id, text=comment_form.comment.data) db.session.add(comment) db.session.commit() title = "comments" return render_template('comment.html', title=title, form=comment_form)
def reset(): comment_form = forms.CommentForm(request.form) if request.method == 'POST': try: #autenticamos el usuario print(comment_form.email.data) user = au.send_password_reset_email(comment_form.email.data) return redirect(url_for('login')) except: print("Correo o Contraseña invalido") return render_template("recuperar-contraseña.html", form=comment_form)
def index(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): print(comment_form.username.data) print(comment_form.email.data) print(comment_form.comment.data) else: print('Error en el formulario') title = 'Curso de flask' return render_template('index2.html', title=title, form=comment_form)
def home(): custom_cookie = request.cookies.get('custom_cookie', 'Undefined') #Si la cookie no existe, devolverá "Undefined" print(custom_cookie) comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): print(comment_form.username.data) print(comment_form.email.data) print(comment_form.comment.data) else: print('Error en el formulario') return render_template('index.html', form = comment_form)
def index(): comment_form = forms.CommentForm(request.form) if request.method == 'POST': id_send = str(comment_form.user_id.data) url= "https://randomuser.me/api/?ud="+id_send print(url) return render_template('result.html', url=url) return render_template('index3.html', form= comment_form)
def comment(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): print comment_form.username.data print comment_form.email.data print comment_form.comment.data else: print "Error en el Formulario" title = 'Curso Flask' return render_template('comment.html', title = title, form = comment_form)
def comment(): titulo = 'Curso Flask.' coment_form = forms.CommentForm(request.form) user_id = session['user_id'] if request.method == 'POST' and coment_form.validate(): comment = Comment(user_id=user_id, text=coment_form.comment.data) db.session.add(comment) db.session.commit() success_message = 'Nuevo Comentario Enviado' flash(success_message) return render_template('comment.html', title=titulo, form=coment_form)
def index(): title = 'Curso de Flask' comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): print(f'{comment_form.user.data}') print(f'{comment_form.email.data}') print(f'{comment_form.comment.data}') else: print('Error in the form') return render_template('index.html', title=title, form=comment_form)
def comment(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): user_id = session['user_id'] comment = Comment(user_id=?, text = comment_form.comment.data) db.session.add(comment) db.session.commit() title = "Curso flask" return render_template('comment.html', title = title form= comment_form)
def login(): #Guarda los datos ingresados en el Formulario comment_form = forms.CommentForm(request.form) if request.method == 'POST': try: #autenticamos el usuario user = au.sign_in_with_email_and_password( comment_form.email.data, comment_form.password.data) print("Login Exitoso") return redirect(url_for('main')) except: print("Correo o Contraseña invalido") return render_template("login.html", form=comment_form)
def comments(): name = 'Sr. Javi Vazz' comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): print(comment_form.username.data) print(comment_form.email.data) print(comment_form.comment.data) else: print('Error en formulario') return render_template('page/comments.html', name = name, form = comment_form )
def comment(): comment_form = forms.CommentForm(request.form) if request.method == 'POST' and comment_form.validate(): username = session['username'] user_id = User.query(id).filter_by(username = username).first() comment = Comment(user_id = user_id, text = comment_form.comment.data) db.session.add(comment) db.session.commit() success_message = 'Se ha creado un nuevo comentario.' flash (success_message) return render_template('comment.html', form = comment_form)
def post(request, url): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user if util.can_users_interract(user, other_user): if request.method == 'POST': comment = Comment.objects.create(author=user, read=False, sent=datetime.datetime.now()) form = myforms.CommentForm(request.POST, instance=comment) comment = form.save() other_user.userprofile.comments.add(comment) return HttpResponseRedirect('/dashboard/')