Ejemplo n.º 1
0
def add_article(type):
    form = ArticlesForm(request.form)

    if request.method == 'POST':
        titleimage=create_embed_link(request.form['titleimage'])
        title=request.form['title']
        description=request.form['description']
        body=request.form['body']

        cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)

        if 'name' in request.form:
            name=request.form['name']
            batchof=request.form['batchof']
            timetoread=request.form['timetoread']

            cur.execute("INSERT INTO articles (name, batchof, titleimage,title, description,timetoread,body,type) values(%s,%s,%s,%s,%s,%s,%s,%s)", (name,batchof,titleimage,title,description,timetoread,body,type));
            conn.commit()
            cur.close()
            return redirect(url_for('index'))
        else:
            cur.execute("INSERT INTO articles (name, batchof, titleimage,title, description,body,type) values('NULL','NULL',%s,%s,%s,%s,%s)", (titleimage,title,description,body,type));
            conn.commit()
            cur.close()
            return redirect(url_for('alumni'))

    return render_template('add_article.html', form=form, type=type)
Ejemplo n.º 2
0
def add_cordi_secretaries():
    form = HallCouncilForm(request.form)

    if request.method == 'POST':
        other_post=request.form['other_post']
        title=request.form['title']
        name=request.form['name']
        mobile=request.form['mobile']
        profilephoto=create_embed_link(request.form['profilephoto'])
        email=request.form['email']
        fbprofile=request.form['fbprofile']
        inprofile=request.form['inprofile']

        # print(name + email)

        cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)

        # if warden_post != '':
        #     cur.execute("UPDATE warden SET name=%s,profilephoto=%s,email=%s,fbprofile=%s,inprofile=%s where post=%s", (name,profilephoto,email,fbprofile,inprofile,warden_post));
        #     conn.commit()
        # else:
        cur.execute("INSERT INTO captains_secretaries(post, title, name, profilephoto,email, mobile, fbprofile,inprofile) values(%s,%s,%s,%s,%s,%s,%s,%s)", (other_post,title,name,profilephoto,email,mobile,fbprofile,inprofile));
        conn.commit()
        # cur.close()
        return redirect(url_for('hallcouncil'))

    return render_template('add_cordi_secretaries.html', form=form)
Ejemplo n.º 3
0
def edit_cordi_secretaries(id):
    # Create cursor
    cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)

    
    result = cur.execute("SELECT * FROM captains_secretaries WHERE id = %s", [id])

    captains_secretaries_data = cur.fetchone()

    form = HallCouncilForm(request.form)

    form.other_post.data = captains_secretaries_data['post']
    form.title.data = captains_secretaries_data['title']
    form.name.data = captains_secretaries_data['name']
    form.mobile.data = captains_secretaries_data['mobile']
    form.profilephoto.data = captains_secretaries_data['profilephoto']
    form.email.data = captains_secretaries_data['email']
    form.fbprofile.data = captains_secretaries_data['fbprofile']
    form.inprofile.data = captains_secretaries_data['inprofile']

    if request.method == 'POST':
        other_post=request.form['other_post']
        title=request.form['title']
        name=request.form['name']
        mobile=request.form['mobile']
        profilephoto=create_embed_link(request.form['profilephoto'])
        email=request.form['email']
        fbprofile=request.form['fbprofile']
        inprofile=request.form['inprofile']

        # print(name + email)

        cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)

        # if warden_post != '':
        #     cur.execute("UPDATE warden SET name=%s,profilephoto=%s,email=%s,fbprofile=%s,inprofile=%s where post=%s", (name,profilephoto,email,fbprofile,inprofile,warden_post));
        #     conn.commit()
        # else:
        cur.execute("UPDATE captains_secretaries SET post=%s, title=%s, name=%s, profilephoto=%s,email=%s, mobile=%s, fbprofile=%s,inprofile=%s where id=%s", (other_post, title, name,profilephoto,email,mobile,fbprofile,inprofile,id));
        conn.commit()
        # cur.close()
        return redirect(url_for('hallcouncil'))

    return render_template('edit_cordi_secretaries.html', form=form, captains_secretaries_data=captains_secretaries_data)
Ejemplo n.º 4
0
def edit_article(id):
    # Create cursor
    cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)

    
    result = cur.execute("SELECT * FROM articles WHERE id = %s", [id])

    article_data = cur.fetchone()

    form = ArticlesForm(request.form)

    form.name.data = article_data['name']
    form.batchof.data = article_data['batchof']
    form.titleimage.data = article_data['titleimage']
    form.title.data = article_data['title']
    form.description.data = article_data['description']
    form.timetoread.data = article_data['timetoread']
    form.body.data = article_data['body']
    form.type.data = article_data['type']

    if request.method == 'POST':
        name=request.form['name']
        batchof=request.form['batchof']
        titleimage=create_embed_link(request.form['titleimage'])
        title=request.form['title']
        description=request.form['description']
        timetoread=request.form['timetoread']
        body=request.form['body']
        type=request.form['type']

        cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)

        # if warden_post != '':
        #     cur.execute("UPDATE warden SET name=%s,profilephoto=%s,email=%s,fbprofile=%s,inprofile=%s where post=%s", (name,profilephoto,email,fbprofile,inprofile,warden_post));
        #     conn.commit()
        # else:
        cur.execute("UPDATE articles SET name=%s, batchof=%s, titleimage=%s, title=%s,description=%s, timetoread=%s,body=%s, type=%s where id=%s", (name, batchof, titleimage,title,description,timetoread,body,type,id));
        conn.commit()
        # cur.close()
        return redirect(url_for('article',id=id))

    return render_template('edit_article.html', form=form, article_data=article_data)
Ejemplo n.º 5
0
def edit_pages(id):
    cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
    #cur = con.cursor()

    result = cur.execute("SELECT * FROM pages WHERE id = %s", (id))

    page_data = cur.fetchone()

    form = PageForm(request.form)

    form.title.data = page_data['title']
    form.videolink.data = page_data['videolink']
    form.videobuttontext.data = page_data['videobuttontext']
    form.backgroungimage.data = page_data['backgroungimage']
    form.body.data=page_data['body']

    if request.method == 'POST':
        title=request.form['title']
        videolink=request.form['videolink']
        videobuttontext=request.form['videobuttontext']
        backgroungimage=create_embed_link(request.form['backgroungimage'])
        body=request.form['body']

        cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
        #cur = con.cursor()

        cur.execute("UPDATE pages SET title=%s, videolink=%s, videobuttontext=%s, backgroungimage=%s, body=%s where id=%s",(title,videolink,videobuttontext,backgroungimage,body,id));
        conn.commit()
        # cur.close()

        if id == '1':
            return redirect(url_for('illu'))
        elif id == '2':
            return redirect(url_for('rangoli'))
        elif id == '3':
            return redirect(url_for('gc'))
        elif id == '4':
            return redirect(url_for('index'))
        elif id == '5':
            return redirect(url_for('alumni'))

    return render_template('edit_pages.html', form=form)
Ejemplo n.º 6
0
def add_photos():
    form = PhotoForm(request.form)

    if request.method == 'POST':
        category=request.form['category']
        title=request.form['title']
        photolink= create_embed_link(request.form['photolink'])
        year=request.form['year']

        # print(name + email)

        cur = conn.cursor(cursor_factory = psycopg2.extras.DictCursor)

        # if warden_post != '':
        #     cur.execute("UPDATE warden SET name=%s,profilephoto=%s,email=%s,fbprofile=%s,inprofile=%s where post=%s", (name,profilephoto,email,fbprofile,inprofile,warden_post));
        #     conn.commit()
        # else:
        cur.execute("INSERT INTO photos(category,title, photolink,year) values(%s,%s,%s,%s)", (category,title,photolink,year));
        conn.commit()
        # cur.close()
        return redirect(url_for('index'))

    return render_template('add_photos.html', form=form)