Exemplo n.º 1
0
def agregarPost():

    if request.method == 'GET':
        return render_template('add-post.html')
    else:
        if request.method == 'POST':
            post = Blog(titulo=request.form['titulo'],
                        contenido=request.form['contenido'],
                        fecha_creacion=datetime.datetime.now())
            session.add(post)
            session.commit()
            return redirect(url_for('showMain'))
Exemplo n.º 2
0
def createblog():
    if request.method == 'POST':
        print("add a form")
        blogtitle = request.form['blogtitle']
        blogcontent = request.form['blogcontent']
        public = request.form['public']
        new_blog = Blog(title=blogtitle, body=blogcontent, is_public=public, date_uploaded=datetime.now())
        session.add(new_blog)
        session.commit()
        return render_template('createblog.html')
    else:
        print(flask_login.current_user.id)
        return render_template('createblog.html')
Exemplo n.º 3
0
def newBlogPost():
    if login_session['email'] != '*****@*****.**':
        return "<script>function myFunction()" \
               "{alert('You are not allowed access to this page!');}" \
               "</script><body onload='myFunction()'>"
    if request.method == 'POST':
        newBlogPost = Blog(title=request.form['title'],
                           dateValue=request.form['dateValue'],
                           pictureURL="static/img/" +
                           request.form['pictureURL'],
                           story=request.form['story'])
        session.add(newBlogPost)
        session.commit()
        return redirect(url_for('showBlog'))
    else:
        return render_template('newblogpost.html')
Exemplo n.º 4
0
def agregarPost():

    if request.method == 'GET':
        return render_template('add-post.html',
                               consolas=ConsolasNAV,
                               generos=GenerosNAV)
    else:
        if request.method == 'POST':
            if request.form['Search'] == "Busqueda":
                buscar = request.form['Busqueda']
                return redirect(url_for('Verreviewtitu', id=buscar))
            else:
                post = Blog(titulo=request.form['titulo'],
                            contenido=request.form['contenido'],
                            fecha_creacion=datetime.datetime.now())
                session.add(post)
                session.commit()
                return redirect(url_for('showMain'))
Exemplo n.º 5
0
def create_post():
    if request.cookies['admin'] != 'yes':
        return redirect('/')
    if request.method == 'GET':
        return render_template("create_post.html")
    else:
        blog = Blog(blog_author=request.cookies['email'],
                    blog_title=request.form['title'],
                    blog_subtitle=request.form['subtitle'],
                    post_date=datetime.now(),
                    content=request.form['content'],
                    comments=0,
                    likes=0,
                    masthead=request.form['masthead'])

        session.add(blog)
        session.commit()

        return redirect('/')
Exemplo n.º 6
0
def agregarPost():

    if request.method == 'GET':
        if 'username' in login_session:
            username = login_session['username']
            Autor = session.query(User).all()
            idautor = 0
            for user in Autor:
                if username == user.username:
                    idautor = user.id
        return render_template('add-post.html',
                               username=username,
                               idau=idautor)
    else:
        if request.method == 'POST':
            post = Blog(titulo=request.form['titulo'],
                        contenido=request.form['contenido'],
                        fecha_creacion=datetime.datetime.now(),
                        id_autor=request.form['autor'])
            session.add(post)
            session.commit()
            return redirect(
                url_for('showMain', username=login_session['username']))
Exemplo n.º 7
0
def register():
    if request.method == 'POST':
        # validate form
        username = request.form['username']
        first_name = request.form['first_name']
        last_name = request.form['last_name']
        email = request.form['email']
        password1 = request.form['pw']
        password2 = request.form['pw1']

        if password1 == password2:
            print("Passwords Match")
        
            # create salt
            new_salt = make_salt()
            print(new_salt)
        
            # create salted password
            salted_password = create_password(password1, new_salt)
            print(salted_password)
            start_up_blog = Blog(title="My first blog", body="Your blog is a little lonely", date_uploaded=datetime.now(), is_public= False)

            new_user = Users(username=username, first_name=first_name, last_name=last_name, email=email, password=salted_password, salt=new_salt, gender='male', blog=start_up_blog)
            # create a sample blog
            #blog=blog1

            session.add(new_user)
            session.commit()
            redirect('/')

        return render_template("register.html")

    else:
       # {% if current_user.is_authenticated %}
       #     Hi {{ current_user.name }}!
       #     {% endif %}
        return render_template("register.html")