Online Art Gallery Management System in Flask

Online Art Gallery Management System is aimed to manage data of a series of art galleries. Data is also managed about exhibitions organized in these art galleries exhibiting various paintings already added in the Online Art Gallery Management System. This system is used to keep records about artists, paintings, customers, art galleries and exhibitions.

Scope of the Project

This software project is aimed to create a platform where artists, exhibition organizers and customers can interact. Artists can display their artistic skills to attract the potential customers.

The platform manages and displays exhibition details so that the art lovers can know about the upcoming exhibitions.

The artists can maintain their stock of uploaded paintings details. The customers and admin can see the details of all the paintings by all the artists. An artist can see the stock of his own paintings.

Customers can see the purchasing transactions done by them. The admin can see the purchase details of all the customers and evaluate the sales. 

Technical Details-Online Art Gallery Management System

Types of users

  • Administrator-can add/ update gallery, exhibition, issue paintings to gallery and return them back to stock
  • Artists- can register, add personal details and upload painting details
  • Customers- can register, view and buy paintings

Activities

  • Information about galleries managed by the organizations which may be located at different places.
  • Details about the exhibitions organized and to be organized. This included the location, duration and name of the organizing person for the exhibition.
  • Details about the artists whose paintings make the stock of the Art Gallery. The details include the contact details of the artist and the genre
  • Details of the Paintings by all the artists that include the type, genre, medium, size and price of the painting. If a painting is issued for an exhibition it is shown as issued and will not be available to be exhibited for another exhibition.
  • Customers who are interested in purchasing paintings from the Art gallery.
  • Issuing paintings for an exhibition and its return back to the stock.
  • The users need to be registered before logging in and doing the activities.
  • The administrator has all the rights to add/update customers, artists, paintings, art galleries and exhibitions in Online Art Gallery Management System.
  • Artists can login to check the details about their paintings.
  • Customers can login and see the available paintings for purchasing.

Database

The following tables are used in the application

CREATE TABLE public.artist_tbl
(
    artist_id integer NOT NULL DEFAULT nextval('artist_tbl_artist_id_seq'::regclass),
    artist_name character varying(50) COLLATE pg_catalog."default",
    address character varying(200) COLLATE pg_catalog."default",
    city_id smallint,
    contact_no character varying(15) COLLATE pg_catalog."default",
    art_genre character varying(20) COLLATE pg_catalog."default",
    uid smallint,
    CONSTRAINT artist_tbl_pkey PRIMARY KEY (artist_id),
    CONSTRAINT art_city_fk FOREIGN KEY (city_id)
        REFERENCES public.cities (city_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
CREATE TABLE public.cities
(
    city_id smallint NOT NULL DEFAULT nextval('cities_city_id_seq'::regclass),
    city_name character varying(50) COLLATE pg_catalog."default",
    CONSTRAINT cities_pkey PRIMARY KEY (city_id)
)
CREATE TABLE public.cust_tbl
(
    cust_id smallint NOT NULL DEFAULT nextval('cust_tbl_cust_id_seq'::regclass),
    cust_name character varying(50) COLLATE pg_catalog."default",
    cust_address character varying(200) COLLATE pg_catalog."default",
    cust_city smallint,
    cust_phone character varying(15) COLLATE pg_catalog."default",
    cust_email character varying(50) COLLATE pg_catalog."default",
    uid smallint,
    CONSTRAINT cust_tbl_pkey PRIMARY KEY (cust_id),
    CONSTRAINT cust_city_fk FOREIGN KEY (cust_city)
        REFERENCES public.cities (city_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID
)
CREATE TABLE public.exhibition_tbl
(
    exb_id bigint NOT NULL DEFAULT nextval('exhibition_tbl_exb_id_seq'::regclass),
    exb_title character varying(200) COLLATE pg_catalog."default",
    exb_city smallint,
    gallery_id smallint,
    organised_by character varying(200) COLLATE pg_catalog."default",
    exb_from_date date,
    exb_to_date date,
    managed_by character varying(50) COLLATE pg_catalog."default",
    CONSTRAINT exhibition_tbl_pkey PRIMARY KEY (exb_id),
    CONSTRAINT fk_city_id FOREIGN KEY (exb_city)
        REFERENCES public.cities (city_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT fk_gallery_id FOREIGN KEY (gallery_id)
        REFERENCES public.gallery_tbl (gallery_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

CREATE TABLE public.gallery_tbl
(
    gallery_id smallint NOT NULL DEFAULT nextval('gallery_tbl_gallery_id_seq'::regclass),
    gallery_name character varying(200) COLLATE pg_catalog."default" NOT NULL,
    city_id integer,
    loc_add character varying(200) COLLATE pg_catalog."default",
    contact_name character varying(50) COLLATE pg_catalog."default",
    contact_no character varying(15) COLLATE pg_catalog."default",
    CONSTRAINT gallery_tbl_pkey PRIMARY KEY (gallery_id),
    CONSTRAINT fk_city FOREIGN KEY (city_id)
        REFERENCES public.cities (city_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID
)
CREATE TABLE public.issue_tbl
(
    exb_id smallint,
    painting_id smallint,
    "Issue_date" date,
    tid smallint NOT NULL DEFAULT nextval('issue_tbl_tid_seq'::regclass),
    CONSTRAINT issue_tbl_pkey PRIMARY KEY (tid),
    CONSTRAINT fk_exb_id FOREIGN KEY (exb_id)
        REFERENCES public.exhibition_tbl (exb_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT fk_pnt_id FOREIGN KEY (painting_id)
        REFERENCES public.paintings_tbl (painting_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
CREATE TABLE public.paintings_tbl
(
    painting_id smallint NOT NULL DEFAULT nextval('paintings_tbl_painting_id_seq'::regclass),
    artist_id smallint NOT NULL,
    in_date date,
    price integer,
    lenth smallint,
    width smallint,
    painting_type character varying(20) COLLATE pg_catalog."default",
    img_path character varying(150) COLLATE pg_catalog."default",
    caption character varying(200) COLLATE pg_catalog."default",
    genre character varying(100) COLLATE pg_catalog."default",
    status character varying(1) COLLATE pg_catalog."default",
    CONSTRAINT paintings_tbl_pkey PRIMARY KEY (painting_id)
)

CREATE TABLE public.sales_tbl
(
    sale_id integer NOT NULL DEFAULT nextval('sales_tbl_sale_id_seq'::regclass),
    painting_id integer,
    cust_id integer,
    amount_paid integer,
    pur_date date,
    CONSTRAINT sales_tbl_pkey PRIMARY KEY (sale_id),
    CONSTRAINT fk_cust_id FOREIGN KEY (cust_id)
        REFERENCES public.cust_tbl (cust_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT fk_paint_id FOREIGN KEY (painting_id)
        REFERENCES public.paintings_tbl (painting_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
CREATE TABLE public.users_tbl
(
    user_id smallint NOT NULL DEFAULT nextval('users_tbl_user_id_seq'::regclass),
    user_name character varying(50) COLLATE pg_catalog."default" NOT NULL,
    user_type character varying(20) COLLATE pg_catalog."default",
    user_pass character varying(20) COLLATE pg_catalog."default",
    CONSTRAINT users_tbl_pkey PRIMARY KEY (user_id)
)

Software tools used

Front end:         Flask, HTML, BootStrap

Back end:          PostgreSQL

Future Enhancement

  • In current implementation of Online Art Gallery Management System, admin, customers or artists cannot filter the paintings on the basis of type of painting, genre, artists or other parameters.
  • An alert window displaying the upcoming exhibitions can be added to the system to inform admin, customers or artists.

index.html

<HTML>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.6.0/dist/umd/popper.min.js" integrity="sha384-KsvD1yqQ1/1+IA7gi3P0tyJcT3vR+NdBTt13hSJ2lnve8agRGXTTyNaBYmCR/Nwi" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.min.js" integrity="sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG" crossorigin="anonymous"></script>
</head>
<body>
<div class="row" style="height:50%; margin-top:5%; ">
 	
	<div class="col-4" >
	
	</div>
	<div class="col-4" style="border-style:solid; border-color:grey; border-width:1px;box-shadow: 10px 10px 10px grey;padding-top:10px">
	<form action="{{ url_for('dashboard')}}" method="POST"> 
	
	<div class="col-4" >
	</div>
    <div class="form-group mx-sm-3 mb-2">
    <label for="username" class="sr-only">User Name</label>
    <input type="text" class="form-control" name="username" placeholder="User Name">
	</div>
	<div class="form-group mx-sm-3 mb-2">
    <label for="inputPassword2" class="sr-only">Password</label>
    <input type="password" class="form-control" name="password" placeholder="Password">
	</div>
	<button type="submit" class="btn btn-primary mb-2">Login</button>
	<a href="{{url_for('register')}}"><button type="Button" class="btn btn-primary mb-2">Register</button></a>
	<p>{{text}}</p>
	</form>
	</div>

<body>
Online Art gallery Management System Login

register.html

<HTML>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.6.0/dist/umd/popper.min.js" integrity="sha384-KsvD1yqQ1/1+IA7gi3P0tyJcT3vR+NdBTt13hSJ2lnve8agRGXTTyNaBYmCR/Nwi" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.min.js" integrity="sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG" crossorigin="anonymous"></script>
</head>
<body>
<div class="row" style="height:50%; margin-top:5%; ">
 	
	<div class="col-4" >
	
	</div>
	<div class="col-4" style="border-style:solid; border-color:grey; border-width:1px;box-shadow: 10px 10px 10px grey;padding-top:10px">
	<form action="{{ url_for('saveUser')}}" method="post"> 
	<div class="col-4" >
	</div>
	<div class="form-check form-check-inline">
	  <input class="form-check-input" type="radio" name="usertype" id="inlineRadio1" value="Admin">
	  <label class="form-check-label" for="inlineRadio1">Admin</label>
	</div>
	<div class="form-check form-check-inline">
	  <input class="form-check-input" type="radio" name="usertype" id="inlineRadio2" value="Artist">
	  <label class="form-check-label" for="inlineRadio2">Artist</label>
	</div>
	<div class="form-check form-check-inline">
	  <input class="form-check-input" type="radio" name="usertype" id="inlineRadio3" value="Customer" >
	  <label class="form-check-label" for="inlineRadio3">Customer</label>
	</div>
	
	
    <div class="form-group mx-sm-3 mb-2">
    <label for="username" class="sr-only">User Name</label>
    <input type="text" class="form-control" name="username" placeholder="User Name">
	</div>
	<div class="form-group mx-sm-3 mb-2">
    <label for="inputPassword2" class="sr-only">Password</label>
    <input type="password" class="form-control" name="password" placeholder="Password">
	</div>
	<div style="display: flex; justify-content: center;"><button type="Submit" class="btn btn-primary mb-2">Register</button></div>
	
	</form>
	</div>
<body>
</HTML>

models.py

import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()

class users_tbl(db.Model):
    __tablename__="users_tbl"
    user_id=db.Column(db.Integer, primary_key=True)
    user_name=db.Column(db.String,nullable=False)
    user_type=db.Column(db.String,nullable=False)
    user_pass=db.Column(db.String,nullable=False)  
    
class cities(db.Model):
    __tablename__="cities"
    city_id=db.Column(db.Integer, primary_key=True)
    city_name=db.Column(db.String,nullable=False)
    
class gallery_tbl(db.Model):
    __tablename__="gallery_tbl"
    gallery_id=db.Column(db.Integer, primary_key=True)
    gallery_name=db.Column(db.String,nullable=False)    
    city_id=db.Column(db.Integer,db.ForeignKey("cities.city_id"), nullable=False)  
    loc_add=db.Column(db.String,nullable=False)  
    contact_name=db.Column(db.String,nullable=False)
    contact_no=db.Column(db.String,nullable=False)    
    city= db.relationship("cities", backref="city", lazy=True) 

class artist_tbl(db.Model):
    __tablename__="artist_tbl"
    artist_id=db.Column(db.Integer, primary_key=True)
    artist_name=db.Column(db.String,nullable=False)    
    art_genre=db.Column(db.String,nullable=False)  
    address=db.Column(db.String,nullable=False)  
    city_id=db.Column(db.Integer,db.ForeignKey("cities.city_id"), nullable=False) 
    contact_no=db.Column(db.String,nullable=False)    
    uid=db.Column(db.Integer,nullable=False)  
    artcity= db.relationship("cities", backref="artcity", lazy=True)     
    
class cust_tbl(db.Model):
    __tablename__="cust_tbl"
    cust_id=db.Column(db.Integer, primary_key=True)
    cust_name=db.Column(db.String,nullable=False)    
    cust_address=db.Column(db.String,nullable=False)  
    cust_city=db.Column(db.Integer,db.ForeignKey("cities.city_id"), nullable=False) 
    cust_phone=db.Column(db.String,nullable=False)
    cust_email=db.Column(db.String,nullable=False)  
    uid=db.Column(db.Integer,nullable=False)
    custcity= db.relationship("cities", backref="custcity", lazy=True) 
    
class exhibition_tbl(db.Model):
    __tablename__="exhibition_tbl"
    exb_id=db.Column(db.Integer, primary_key=True)
    exb_title=db.Column(db.String,nullable=False)    
    exb_city=db.Column(db.Integer,db.ForeignKey("cities.city_id"), nullable=False) 
    gallery_id=db.Column(db.Integer,db.ForeignKey("gallery_tbl.gallery_id"), nullable=False) 
    organised_by=db.Column(db.String,nullable=False)  
    exb_from_date=db.Column(db.Date,nullable=False)   
    exb_to_date=db.Column(db.Date,nullable=False)  
    managed_by=db.Column(db.String,nullable=False)    
    exbcity= db.relationship("cities", backref="exbcity", lazy=True)  
    exbgallery= db.relationship("gallery_tbl", backref="exbgallery", lazy=True) 
    
class paintings_tbl(db.Model):
    __tablename__="paintings_tbl"
    painting_id=db.Column(db.Integer, primary_key=True)
    artist_id=db.Column(db.Integer,db.ForeignKey("artist_tbl.artist_id"), nullable=False) 
    in_date=db.Column(db.Date,nullable=False)    
    genre=db.Column(db.String,nullable=False)
    price=db.Column(db.Integer,nullable=False)  
    lenth=db.Column(db.Integer,nullable=False)  
    width=db.Column(db.Integer,nullable=False)  
    painting_type=db.Column(db.String,nullable=False)   
    img_path=db.Column(db.String,nullable=False)  
    caption=db.Column(db.String,nullable=False) 
    status=db.Column(db.String,nullable=False)     
    part= db.relationship("artist_tbl", backref="part", lazy=True) 
    
class issue_tbl(db.Model):
    __tablename__="issue_tbl"
    tid=db.Column(db.Integer, primary_key=True)
    exb_id=db.Column(db.Integer, db.ForeignKey("exhibition_tbl.exb_id"), nullable=False)
    painting_id=db.Column(db.Integer, db.ForeignKey("paintings_tbl.painting_id"), nullable=False)
    Issue_date=db.Column(db.Date, nullable=False)
    iexb= db.relationship("exhibition_tbl", backref="iexb", lazy=True)
    ipnt= db.relationship("paintings_tbl", backref="ipnt", lazy=True)
    
class sales_tbl(db.Model):
    __tablename__="sales_tbl"
    sale_id=db.Column(db.Integer, primary_key=True)
    painting_id=db.Column(db.Integer, db.ForeignKey("paintings_tbl.painting_id"), nullable=False)
    cust_id=db.Column(db.Integer, db.ForeignKey("cust_tbl.cust_id"), nullable=False)
    amount_paid=db.Column(db.Integer,nullable=False)
    pur_date=db.Column(db.Date, nullable=False)    

dashboard.html

<HTML>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.6.0/dist/umd/popper.min.js" integrity="sha384-KsvD1yqQ1/1+IA7gi3P0tyJcT3vR+NdBTt13hSJ2lnve8agRGXTTyNaBYmCR/Nwi" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.min.js" integrity="sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG" crossorigin="anonymous"></script>
</head>


<div class="container-fluid" style="background-color:#DBE3E2; width:80%">


<div style="height: 50px; border-style:outset;">
<div class="col-12" style="text-align:center;padding-top:5px;">
<h5>Art Gallery Management </h5>
</div>
</div>
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
{% if session['utype'] =='Admin' %}
<div class="btn-group me-2" role="group" aria-label="Second group">
    <a href="{{url_for('galleries')}}"><button type="button" class="btn btn-info">Galleries</button></a>
    <a href="{{url_for('artists')}}"><button type="button" class="btn btn-info">Artists</button></a>
	<a href="{{url_for('customers')}}"><button type="button" class="btn btn-info">Customers</button></a>
	<a href="{{url_for('exhibitions')}}"><button type="button" class="btn btn-info">Exhibitions</button></a>
	<a href="{{url_for('paintings')}}"><button type="button" class="btn btn-info">Paintings</button></a>
	<a href="#"><button type="button" class="btn btn-info">Users</button></a>
</div>
<span style="
		float:right;		
		text-align:right;
		padding-left:50px;
		padding-top:10px;
		">{% block p %}{{uname}}{% endblock %}</span><div style="float:right"><a href="{{url_for('logout')}}"><button type="button" class="btn btn-warning" >Logout</button> </div></a> 
{% else %}
<div style="float:right"><a href="{{url_for('logout')}}"><button type="button" class="btn btn-warning" >Logout</button></div></a>
{% endif %}
</div>
<div style="height:100%; background-color:#F4F6F6;">
<div class="col-12" style="height:40px; 
		background-color:white;
		float:left;		
		text-align:right;
		padding-right:50px;
		padding-top:10px;
		border-style:solid;
		border-width:1px;
		border-color:#adb5bd">
	
		{% if session['utype'] =='Admin' %}
		<a href="{{url_for('AddGallery')}}" data-bs-toggle="tooltip" data-bs-placement="top" title="Add a Gallery" style="padding-right:10px;"><img src='/static/icons/images.svg' width="24" height="24"/></a>
		<a href="{{url_for('AddExhibition')}}"  data-bs-toggle="tooltip" data-bs-placement="top" title="Add an Exhibition" style="padding-right:10px;"><img src='/static/icons/calendar.svg' width="24" height="24"/></a>
		{% endif %}
		{% if session['utype'] =='Artist' %}
		<a href="{{url_for('AddArtist')}}" data-bs-toggle="tooltip" data-bs-placement="top" title="Add an Artist" style="padding-right:10px;"><img src='/static/icons/people.svg' width="24" height="24"/></a>
		<a href="{{url_for('AddPainting')}}"  data-bs-toggle="tooltip" data-bs-placement="top" title="Add a Painting" style="padding-right:10px;"><img src='/static/icons/palette.svg' width="24" height="24"/></a>
		{% endif %}
		{% if session['utype'] =='Customer' %}
		<a href="{{url_for('AddCustomer')}}" data-bs-toggle="tooltip" data-bs-placement="top" title="Add a Customer" style="padding-right:10px;"><img src='/static/icons/people-fill.svg' width="24" height="24"/></a>
		{% endif %}
</div>
<div class="col-12" style="padding:20px">	
{% block body %}
{{text}}
{% endblock %}
</div>
</div>
</HTML> 
dashboard

application.py

import os
from flask import Flask, render_template, jsonify, request,redirect,flash, Markup,url_for, session
from models import *
from datetime import date, timedelta,datetime
from werkzeug.utils import secure_filename
import forms


folder_name="static\paintings"

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://postgres:password@localhost:5432/artgallery"
'''give your own DB name and password'''
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["UPLOAD_FOLDER"]=folder_name
ALLOWED_EXTENSIONS = {'pdf', 'png', 'jpg', 'jpeg', 'gif'}
app.secret_key = b'hkahs3720/'
db.init_app(app)

def checkNull(a):
    if a==None:
        return '--'
    else:
        return a

@app.route("/")
def index():
    return render_template("index.html")
    
@app.route("/register")
def register():
    return render_template("register.html")
    
@app.route("/logout")    
def logout():
    session.clear()
    return render_template("index.html")    
    
@app.route("/saveUser", methods=["POST"])
def saveUser():
    uname = request.form.get("username")
    utype = request.form.get("usertype")
    upass = request.form.get("password") 
    urec = users_tbl(user_name=uname, user_type=utype, user_pass=upass)
    db.session.add(urec)  
    db.session.commit()
    return redirect(url_for('index'))     
    
@app.route("/dashboard", methods=["POST"])
def dashboard():
    unam = request.form.get("username")
    pwd = request.form.get("password")
    ulist = users_tbl.query.filter_by(user_name=unam).first()
    text="Hello "+unam+"!!"
    if ulist!=None and ulist.user_pass==pwd:
        session['userName']= unam
        session['userid']= ulist.user_id
        session['utype']= ulist.user_type
        if session['utype']=='Artist':
            tlist=artist_tbl.query.filter_by(uid=session['userid']).first()
            if tlist!=None:
                session['said']=tlist.artist_id
                
        else:
            if session['utype']=='Customer':
                tlist=cust_tbl.query.filter_by(uid=session['userid']).first()
                if tlist!=None:
                    session['scid']=tlist.cust_id
        return redirect(url_for('paintings'))    
    else:  
        text="Incorrect credentials"
        return render_template("index.html", uname=text)     

#---------------------Gallery-------------------------------------------
@app.route("/AddGallery")
def AddGallery():
    text=Markup(forms.NewGallery(getCities()))
    return render_template("dashboard.html", text=text)   

@app.route("/saveGallery", methods=["POST"])
def saveGallery():
    gallery_name = request.form.get("gallery_name")
    cid = request.form.get("city")
    loc_add = request.form.get("loc_add") 
    contact_name = request.form.get("contact_name")
    contact_no=request.form.get("contact_no")
    grec = gallery_tbl(gallery_name=gallery_name, city_id=cid, loc_add=loc_add, contact_name=contact_name,contact_no=contact_no)
    db.session.add(grec)  
    db.session.commit()
    text=gallery_name+" saved"+ str(cid)
    return redirect(url_for('galleries'))  
    
    
@app.route("/galleries")    
def galleries():
    gList=gallery_tbl.query.order_by("gallery_id").all()
    tabl='''<Table class="table table-striped table-hover" ><TR>
            <TD>Gallery ID</TD>
            <TD>Gallery Name</TD>
            <TD>Address</TD>
            <TD>Location</TD>
            <TD>Contact Person</TD>
            <TD>Phone No</TD>
            <TD></TD>
            </TR>'''  
    for itm in gList:
        edtBtn='<a href="'+url_for('DispGallery',gid=itm.gallery_id)+'"><input type="button" value="Update Gallery Details"></a>'
        
        tabl=tabl+"<TR ><TD>"+str(itm.gallery_id)+'</TD><TD>'+itm.gallery_name+"</TD><TD>"+itm.loc_add+"</TD><TD>"+itm.city.city_name+"</TD><TD>"+itm.contact_name+"</TD><TD>"+itm.contact_no+"</TD><TD>"+edtBtn+"</TD></TR>"
    tabl=tabl+"</Table>"    
    
    text= Markup(tabl)
    return render_template("dashboard.html", text=text)    

@app.route("/DispGallery/<int:gid>")    
def DispGallery(gid):   
    glist=gallery_tbl.query.filter_by(gallery_id=gid).first()
    gal='''<h5 style="text-align:center">Gallery Details</h5><HR>
    <form class="row g-3" action="/updtGallery" method="post">
    <div class="col-md-6">
    <label for="gallery_id" class="form-label">Gallery ID</label>
    <input type="number" class="form-control" Name="gallery_id" value='''+str(glist.gallery_id)+''' >
    </div>
    <div class="col-md-6">
    <label for="gallery_name" class="form-label">Gallery Name</label>
    <input type="text" class="form-control" Name="gallery_name" value='''+glist.gallery_name+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="loc_add" class="form-label">Address</label>
    <input type="text" class="form-control" Name="loc_add" value='''+glist.loc_add+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="city" class="form-label">City Name</label>
    <input type="text" class="form-control" Name="city" value='''+glist.city.city_name+" "+''' disabled>
    </div>
    <div class="col-md-6">
    <label for="contact_name" class="form-label">Contact Person</label>
    <input type="text" class="form-control" Name="contact_name" value='''+glist.contact_name+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="contact_no" class="form-label">Contact Number</label>
    <input type="text" class="form-control" Name="contact_no" value='''+glist.contact_no+" "+''' >
    </div>
    <div class="col-12">
    <button type="submit" class="btn  btn-secondary">Update Gallery</button>
    </div>
</FORM>'''
    text= Markup(gal)
    return render_template("dashboard.html", text=text)      
    
@app.route("/updtGallery", methods=["POST"]) 
def updtGallery():
    gid = request.form.get("gallery_id")
    glist=gallery_tbl.query.filter_by(gallery_id=gid).first()
    gname= request.form.get("gallery_name") 
    glist.gallery_name = request.form.get("gallery_name") 
    glist.loc_add = request.form.get("loc_add") 
    glist.contact_name = request.form.get("contact_name")
    glist.contact_no=request.form.get("contact_no")
    db.session.commit()
    text=gname+" updated"+ str(gid)
    return redirect(url_for('galleries')) 
     

#----------------------end Gallery------------------------------------  

#---------------------Begin Artist-------------------------------------------
@app.route("/AddArtist")
def AddArtist():
    text=Markup(forms.NewArtist(getCities()))
    return render_template("dashboard.html", text=text)   

@app.route("/saveArtist", methods=["POST"])
def saveArtist():
    artist_name = request.form.get("artist_name")
    cid = request.form.get("city")
    address = request.form.get("address") 
    art_genre = request.form.get("art_genre")
    contact_no=request.form.get("contact_no")
    arec = artist_tbl(artist_name=artist_name, city_id=cid, art_genre=art_genre, address=address,contact_no=contact_no,uid=session['userid'])
    db.session.add(arec)  
    db.session.commit()
    text=artist_name+" saved"
    return redirect(url_for('artists'))  
    
    
@app.route("/artists")    
def artists():
    aList=artist_tbl.query.order_by("artist_id").all()
    tabl='''<Table class="table table-striped table-hover" ><TR>
            <TD>Artist ID</TD>
            <TD>Artist Name</TD>
            <TD>Genre</TD>
            <TD>Address</TD>
            <TD>Location</TD>
            <TD>Phone No</TD>
            <TD></TD>
            </TR>'''  
    for itm in aList:
        edtBtn='<a href="'+url_for('DispArtist',aid=itm.artist_id)+'"><input type="button" value="Update Artist Details"></a>'
        tabl=tabl+"<TR ><TD>"+str(itm.artist_id)+'</TD><TD>'+itm.artist_name+"</TD><TD>"+itm.art_genre+"</TD><TD>"+itm.address+"</TD><TD>"+itm.artcity.city_name+"</TD><TD>"+itm.contact_no+"</TD><TD>"+edtBtn+"</TD></TR>"
    tabl=tabl+"</Table>"    
    
    text= Markup(tabl)
    return render_template("dashboard.html", text=text)    

@app.route("/DispArtist/<int:aid>")    
def DispArtist(aid):   
    alist=artist_tbl.query.filter_by(artist_id=aid).first()
    artd='''<h5 style="text-align:center">Artist Details</h5><HR>
    <form class="row g-3" action="/updtArtist" method="post">
    <div class="col-md-6">
    <label for="artist_id" class="form-label">Artist ID</label>
    <input type="number" class="form-control" Name="artist_id" value='''+str(alist.artist_id)+''' >
    </div>
    <div class="col-md-6">
    <label for="artist_name" class="form-label">Artist Name</label>
    <input type="text" class="form-control" Name="artist_name" value='''+alist.artist_name+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="art_genre" class="form-label">Artist Genre</label>
    <input type="text" class="form-control" Name="art_genre" value='''+alist.art_genre+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="address" class="form-label">Address</label>
    <input type="text" class="form-control" Name="address" value='''+alist.address+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="city" class="form-label">City Name</label>
    <input type="text" class="form-control" Name="city" value='''+alist.artcity.city_name+" "+''' disabled>
    </div>
    <div class="col-md-6">
    <label for="contact_no" class="form-label">Contact Number</label>
    <input type="text" class="form-control" Name="contact_no" value='''+alist.contact_no+" "+''' >
    </div>
    <div class="col-12">
    <button type="submit" class="btn  btn-secondary">Update Artist</button>
    </div>
</FORM>'''
    text= Markup(artd)
    return render_template("dashboard.html", text=text)      
    
@app.route("/updtArtist", methods=["POST"]) 
def updtArtist():
    aid = request.form.get("artist_id")
    alist=artist_tbl.query.filter_by(artist_id=aid).first()
    aname= request.form.get("artist_name") 
    alist.artist_name = request.form.get("artist_name") 
    alist.address = request.form.get("address") 
    alist.art_genre = request.form.get("art_genre") 
    alist.contact_no=request.form.get("contact_no")
    db.session.commit()
    return redirect(url_for('artists')) 
    
#--------------------------end artists------------------------------------  

#---------------------Begin customer-------------------------------------------
@app.route("/AddCustomer")
def AddCustomer():
    text=Markup(forms.NewCust(getCities()))
    return render_template("dashboard.html", text=text)   

@app.route("/saveCust", methods=["POST"])
def saveCust():
    cust_name = request.form.get("cust_name")
    cid = request.form.get("city")
    cust_address = request.form.get("cust_address") 
    cust_phone = request.form.get("cust_phone")
    cust_email=request.form.get("cust_email")
    crec = cust_tbl(cust_name=cust_name, cust_city=cid, cust_address=cust_address, cust_phone=cust_phone,cust_email=cust_email,uid=session['userid'])
    db.session.add(crec)  
    db.session.commit()
    #text=cust_name+" saved"
    return redirect(url_for('customers'))  
    
    
@app.route("/customers")    
def customers():
    cList=cust_tbl.query.order_by("cust_id").all()
    tabl='''<Table class="table table-striped table-hover" ><TR>
            <TD>Customer ID</TD>
            <TD>Customer Name</TD>
            <TD>Address</TD>
            <TD>City</TD>
            <TD>Phone No</TD>
            <TD>Email ID</TD>
            <TD></TD>
            </TR>'''  
    for itm in cList:
        edtBtn='<a href="'+url_for('DispCustomer',cid=itm.cust_id)+'"><input type="button" value="Update Customer Details"></a>'
        
        tabl=tabl+"<TR ><TD>"+str(itm.cust_id)+'</TD><TD>'+itm.cust_name+"</TD><TD>"+itm.cust_address+"</TD><TD>"+itm.custcity.city_name+"</TD><TD>"+itm.cust_phone+"</TD><TD>"+itm.cust_email+"</TD><TD>"+edtBtn+"</TD></TR>"
    tabl=tabl+"</Table>"    
    
    text= Markup(tabl)
    return render_template("dashboard.html", text=text)    

@app.route("/DispCustomer/<int:cid>")    
def DispCustomer(cid):   
    clist=cust_tbl.query.filter_by(cust_id=cid).first()
    custd='''<h5 style="text-align:center">Artist Details</h5><HR>
    <form class="row g-3" action="/updtCust" method="post">
    <div class="col-md-6">
    <label for="cust_id" class="form-label">Customer ID</label>
    <input type="number" class="form-control" Name="cust_id" value='''+str(clist.cust_id)+''' >
    </div>
    <div class="col-md-6">
    <label for="cust_name" class="form-label">Artist Name</label>
    <input type="text" class="form-control" Name="cust_name" value='''+clist.cust_name+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="cust_address" class="form-label">Customer Address</label>
    <input type="text" class="form-control" Name="cust_address" value='''+clist.cust_address+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="city" class="form-label">City Name</label>
    <input type="text" class="form-control" Name="city" value='''+clist.custcity.city_name+" "+''' disabled>
    </div>
    <div class="col-md-6">
    <label for="cust_phone" class="form-label">Contact Number</label>
    <input type="text" class="form-control" Name="cust_phone" value='''+clist.cust_phone+" "+''' >
    </div>
    <div class="col-md-6">
    <label for="cust_email" class="form-label">Email ID</label>
    <input type="text" class="form-control" Name="cust_email" value='''+clist.cust_email+" "+''' >
    </div>
    <div class="col-12">
    <button type="submit" class="btn  btn-secondary">Update Customer</button>
    </div>
</FORM>'''
    text= Markup(custd)
    return render_template("dashboard.html", text=text)      
    
@app.route("/updtCust", methods=["POST"]) 
def updtCust():
    cid = request.form.get("cust_id")
    clist=cust_tbl.query.filter_by(cust_id=cid).first()
    cname= request.form.get("cust_name") 
    clist.cust_name = request.form.get("cust_name") 
    clist.cust_address = request.form.get("cust_address") 
    clist.cust_phone = request.form.get("cust_phone") 
    clist.cust_email=request.form.get("cust_email")
    db.session.commit()
    return redirect(url_for('customers')) 
    
#--------------------------end customer------------------------------------ 

#---------------------Begin exhibition-------------------------------------------
@app.route("/AddExhibition")
def AddExhibition():
    text=Markup(forms.NewExhibition(getCities(),getGalleries()))
    return render_template("dashboard.html", text=text)   

@app.route("/saveExhibition", methods=["POST"])
def saveExhibition():
    exb_title = request.form.get("exb_title")
    cid = request.form.get("city")
    gid = request.form.get("gallery")
    exb_organised = request.form.get("exb_organised") 
    exb_managed = request.form.get("exb_managed") 
    exbs_date = request.form.get("exb_from_date")
    exbe_date = request.form.get("exb_end_date")
    erec = exhibition_tbl(exb_title=exb_title, exb_city=cid, gallery_id=gid, organised_by=exb_organised,managed_by=exb_managed,exb_from_date=exbs_date,exb_to_date=exbe_date)
    db.session.add(erec)  
    db.session.commit()
    #text=cust_name+" saved"
    return redirect(url_for('exhibitions'))  
        
@app.route("/exhibitions")    
def exhibitions():
    eList=exhibition_tbl.query.order_by("exb_id").all()
    tabl='''<Table class="table table-striped table-hover" ><TR>
            <TD>Exhibition ID</TD>
            <TD>Exhibition Title</TD>
            <TD>Gallery</TD>
            <TD>City</TD>
            <TD>Organised By</TD>
            <TD>Starts From</TD>
            <TD>Ends On</TD>
            <TD>Managed By</TD>
            <TD></TD>
            </TR>'''  
    for itm in eList:
        edtBtn='<a href="'+url_for('DispExhibition',eid=itm.exb_id)+'"><input type="button" value="Update Exhibition Details"></a>'
        pntBtn='<a href="'+url_for('addPntExhibition',eid=itm.exb_id)+'"><input type="button" value="Issue Paintings"></a>'
        shPntBtn='<a href="'+url_for('showPntExhibition',eid=itm.exb_id)+'"><input type="button" value="Show Issued Paintings"></a>'
        tabl=tabl+"<TR ><TD>"+str(itm.exb_id)+'</TD><TD>'+itm.exb_title+"</TD><TD>"+itm.exbgallery.gallery_name+"</TD><TD>"+itm.exbcity.city_name+"</TD><TD>"+itm.organised_by+"</TD><TD>"+str(itm.exb_from_date)+"</TD><TD>"+str(itm.exb_to_date)+"</TD><TD>"+itm.managed_by+"</TD><TD>"+edtBtn+pntBtn+shPntBtn+"</TD></TR>"
    tabl=tabl+"</Table>"    
    
    text= Markup(tabl)
    return render_template("dashboard.html", text=text)  

@app.route("/addPntExhibition/<int:eid>")    
def addPntExhibition(eid):
    pList=paintings_tbl.query.filter_by(status='A').all()
    tabl='<Table class="table table-striped table-hover" >'
    for itm in pList:
        adPntBtn='<a href="'+url_for('AddPaintExb',eid=eid,pid=itm.painting_id)+'"><input type="button" value="Issue for Exhibition"></a>'
        tabl=tabl+"<TR ><TD>"+str(itm.painting_id)+'</TD><TD>'+itm.caption+"</TD><TD>"+itm.part.artist_name+"</TD><TD>"+adPntBtn+"</TD></TR>"   
    tabl=tabl+'</TABLE>'                
    text= Markup(tabl)
    return render_template("dashboard.html", text=text)  
    
@app.route("/AddPaintExb/<int:eid>,<int:pid>")    
def AddPaintExb(pid,eid):  
    pe_rec=issue_tbl(exb_id=eid, painting_id=pid,Issue_date=str(date.today()))
    prec=paintings_tbl.query.filter_by(painting_id=pid).first()
    db.session.add(pe_rec)  
    prec.status='I'
    db.session.commit()
    return redirect(url_for('addPntExhibition',eid=eid)) 
   
    
@app.route("/showPntExhibition/<int:eid>")    
def showPntExhibition(eid):
    pList=issue_tbl.query.filter_by(exb_id=eid).all()
    tabl='<Table class="table table-striped table-hover" >'
    for itm in pList:
        if (itm.ipnt.status=="I"):
            retPntBtn='<a href="'+url_for('RetPaintExb',eid=eid,pid=itm.painting_id)+'"><input type="button" value="Return the Painting"></a>'
            tabl=tabl+"<TR ><TD>"+str(itm.painting_id)+'</TD><TD>'+itm.ipnt.caption+"</TD><TD>"+itm.ipnt.part.artist_name+"</TD><TD>"+retPntBtn+"</TD></TR>"   
    tabl=tabl+'</TABLE>'                
    text= Markup(tabl)
    return render_template("dashboard.html", text=text)      
    
@app.route("/RetPaintExb/<int:eid>,<int:pid>")    
def RetPaintExb(pid,eid):  
    prec=paintings_tbl.query.filter_by(painting_id=pid).first()
    prec.status='A'
    db.session.commit()
    return redirect(url_for('showPntExhibition',eid=eid)) 
    

@app.route("/DispExhibition/<int:eid>")    
def DispExhibition(eid):   
    elist=exhibition_tbl.query.filter_by(exb_id=eid).first()
    exbd='''<h5 style="text-align:center">Exhibition Details</h5><HR>
    <form class="row g-3" action="/updtExb" method="post">
    <div class="col-md-6">
    <label for="exb_id" class="form-label">Exhibition ID</label>
    <input type="number" class="form-control" Name="exb_id" value='''+str(elist.exb_id)+''' >
    </div>
    <div class="col-md-6">
    <label for="exb_title" class="form-label">Artist Name</label>
    <input type="text" class="form-control" Name="exb_title" value="'''+elist.exb_title+" "+'''" >
    </div>
    <div class="col-md-6">
    <label for="exb_gall" class="form-label">Gallary Name</label>
    <input type="text" class="form-control" Name="exb_gall" value="'''+elist.exbgallery.gallery_name+" "+'''" disabled >
    </div>
    <div class="col-md-6">
    <label for="exb_city" class="form-label">Location</label>
    <input type="text" class="form-control" Name="exb_city" value="'''+elist.exbcity.city_name+" "+'''" disabled >
    </div>
    <div class="col-md-6">
    <label for="organised_by" class="form-label">Organiser's  Name</label>
    <input type="text" class="form-control" Name="organised_by" value="'''+elist.organised_by+" "+'''" >
    </div>
    <div class="col-md-6">
    <label for="managed_by" class="form-label">Manager's  Name</label>
    <input type="text" class="form-control" Name="managed_by" value="'''+elist.managed_by+" "+'''" >
    </div>
    <div class="col-md-6">
    <label for="exb_from_date" class="form-label">Start Date</label>
    <input type="date" class="form-control" Name="exb_from_date" value='''+str(elist.exb_from_date)+''' >
    </div>
    <div class="col-md-6">
    <label for="exb_to_date" class="form-label">End Date</label>
    <input type="date" class="form-control" Name="exb_to_date" value='''+str(elist.exb_to_date)+''' >
    </div>
    <div class="col-12">
    <button type="submit" class="btn  btn-secondary">Update Exhibition</button>
    </div>
</FORM>'''
    text= Markup(exbd)
    return render_template("dashboard.html", text=text)      
    
@app.route("/updtExb", methods=["POST"]) 
def updtExb():
    eid = request.form.get("exb_id")
    elist=exhibition_tbl.query.filter_by(exb_id=eid).first()
    elist.exb_title= request.form.get("exb_title") 
    elist.managed_by = request.form.get("managed_by") 
    elist.organised_by = request.form.get("organised_by") 
    elist.exb_from_date = request.form.get("exb_from_date") 
    elist.exb_to_date = request.form.get("exb_to_date") 
    db.session.commit()
    return redirect(url_for('exhibitions')) 
   
#---------------------End exhibition-------------------------------------------

#---------------------Begin Painting-------------------------------------------
@app.route("/AddPainting")
def AddPainting():
    text=Markup(forms.NewPainting())
    return render_template("dashboard.html", text=text)   
    
@app.route("/savePainting", methods=["POST"])
def savePainting():
    f = request.files['file']
    in_date = request.form.get("in_date")
    genre = request.form.get("genre")
    price = request.form.get("price")
    fileLink=f.filename
    lenth = request.form.get("lenth") 
    width = request.form.get("width") 
    painting_type = request.form.get("painting_type")
    caption = request.form.get("caption")
    prec = paintings_tbl(artist_id=session['said'],in_date=str(in_date), genre=genre, price=price, lenth=lenth,width=width,painting_type=painting_type,img_path=fileLink,caption=caption,status='A')
    db.session.add(prec)  
    db.session.commit()
    filename = secure_filename(f.filename)
    f.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
    return redirect(url_for('paintings'))  
    
      
@app.route("/paintings")    
def paintings():
    rno=0
    if session.get('said') is None:
        pList=paintings_tbl.query.order_by("painting_id").all()
    else:
        pList=paintings_tbl.query.filter_by(artist_id=session['said']).order_by("painting_id").all()
    tabl='<div class="container">'
    for itm in pList:
        if (rno%4)==0:
            tabl=tabl+'<div class="row" >'
        tabl=tabl+'''<div class="col" style="border-style: solid; border-width:1px; text-align:center; padding:10px;margin:2px; border-color:lightgray;">
                    <img src="'''+folder_name+'''\\'''+itm.img_path+'''" height=100px width=100px alt="...">
                    <h5>'''+itm.caption+'''</h5>
                    <p>Artist:'''+itm.part.artist_name+'''</p>
                    <p>Size: '''+str(itm.lenth)+'''X'''+str(itm.width)+''' cm.('''+itm.painting_type+''')</p>
                    <p><b>Price: '''+str(itm.price)+'''</b></p>
                    '''
        if session.get('scid') is not None:
            tabl=tabl+'<a href="'+url_for('BuyPainting',pid=itm.painting_id, cid=session['scid'],prc=itm.price)+'"><input type="button" value="Buy"></a>'
        tabl=tabl+'</DIV>'  
        rno=rno+1   
           
    tabl=tabl+'</DIV>'                
    text= Markup(tabl)
    return render_template("dashboard.html", text=text)   

@app.route("/BuyPainting/<int:pid>,<int:cid>,<int:prc>")    
def BuyPainting(pid,cid,prc):  
    salRec = sales_tbl(painting_id=pid,cust_id=cid,amount_paid=prc,pur_date=date.today())
    db.session.add(salRec)  
    db.session.commit()
    return redirect(url_for('paintings'))  

@app.route("/DispPainting/<int:eid>")    
def DispPainting(eid):   
    elist=exhibition_tbl.query.filter_by(exb_id=eid).first()
    exbd='''<h5 style="text-align:center">Exhibition Details</h5><HR>
    <form class="row g-3" action="/updtExb" method="post">
    <div class="col-md-6">
    <label for="exb_id" class="form-label">Exhibition ID</label>
    <input type="number" class="form-control" Name="exb_id" value='''+str(elist.exb_id)+''' >
    </div>
    <div class="col-md-6">
    <label for="exb_title" class="form-label">Artist Name</label>
    <input type="text" class="form-control" Name="exb_title" value="'''+elist.exb_title+" "+'''" >
    </div>
    <div class="col-md-6">
    <label for="exb_gall" class="form-label">Gallary Name</label>
    <input type="text" class="form-control" Name="exb_gall" value="'''+elist.exbgallery.gallery_name+" "+'''" disabled >
    </div>
    <div class="col-md-6">
    <label for="exb_city" class="form-label">Location</label>
    <input type="text" class="form-control" Name="exb_city" value="'''+elist.exbcity.city_name+" "+'''" disabled >
    </div>
    <div class="col-md-6">
    <label for="organised_by" class="form-label">Organiser's  Name</label>
    <input type="text" class="form-control" Name="organised_by" value="'''+elist.organised_by+" "+'''" >
    </div>
    <div class="col-md-6">
    <label for="managed_by" class="form-label">Manager's  Name</label>
    <input type="text" class="form-control" Name="managed_by" value="'''+elist.managed_by+" "+'''" >
    </div>
    <div class="col-md-6">
    <label for="exb_from_date" class="form-label">Start Date</label>
    <input type="date" class="form-control" Name="exb_from_date" value='''+str(elist.exb_from_date)+''' >
    </div>
    <div class="col-md-6">
    <label for="exb_to_date" class="form-label">End Date</label>
    <input type="date" class="form-control" Name="exb_to_date" value='''+str(elist.exb_to_date)+''' >
    </div>
    <div class="col-12">
    <button type="submit" class="btn  btn-secondary">Update Exhibition</button>
    </div>
</FORM>'''
    text= Markup(exbd)
    return render_template("dashboard.html", text=text)      
    
@app.route("/updtPainting", methods=["POST"]) 
def updtPainting():
    eid = request.form.get("exb_id")
    elist=exhibition_tbl.query.filter_by(exb_id=eid).first()
    elist.exb_title= request.form.get("exb_title") 
    elist.managed_by = request.form.get("managed_by") 
    elist.organised_by = request.form.get("organised_by") 
    elist.exb_from_date = request.form.get("exb_from_date") 
    elist.exb_to_date = request.form.get("exb_to_date") 
    db.session.commit()
    return redirect(url_for('exhibitions')) 
   
#---------------------End Painting-------------------------------------------

#---------------------cities dropdown-------------------------------------------
def getCities():
    cList=cities.query.order_by("city_name").all()
    cdd='''<div class="form-group">
            <select class="form-control" name="city" id="city">'''
    for itm in cList:
        cdd=cdd+"<option value=\""+str(itm.city_id)+"\">"+itm.city_name +"</option>"
    cdd=cdd+  '''</select>
    </div>'''
    return cdd
#---------------------galleries dropdown-------------------------------------------
def getGalleries():
    gList=gallery_tbl.query.order_by("gallery_name").all()
    gdd='''<div class="form-group">
            <select class="form-control" name="gallery" id="gallery">'''
    for itm in gList:
        gdd=gdd+"<option value=\""+str(itm.gallery_id)+"\">"+itm.gallery_name +"</option>"
    gdd=gdd+  '''</select>
    </div>'''
    return gdd    

forms.py

def NewGallery(cdd):
    galler='''<h5 style="text-align:center">Gallery Details</h5><HR>
    <form class="row g-3" action="/saveGallery" method="post">
    <div class="col-md-6">
    <label for="gallery_name" class="form-label">Gallery Name</label>
    <input type="text" class="form-control" Name="gallery_name">
    </div>
    <div class="col-md-6">
    <label for="city_id" class="form-label">Select City</label>
    '''+cdd+'''
    </div>
    <div class="col-md-6">
    <label for="loc_add" class="form-label">Location Address </label>
    <input type="text" class="form-control" Name="loc_add">
    </div>
    <div class="col-md-6">
    <label for="contact_name" class="form-label">Contact Person</label>
    <input type="text" class="form-control" Name="contact_name">
    </div>
    <div class="col-md-6">
    <label for="contact_no" class="form-label">Contact No.</label>
    <input type="text" class="form-control" Name="contact_no">
    </div>
    <HR>
    <div class="col-12" style="display:flex; justify-content:center;">
    <button type="submit" class="btn  btn-secondary">Save Gallery Details</button>
    </div>
</FORM>'''
    return galler

def NewArtist(cdd):
    artst='''<h5 style="text-align:center">Artist Details</h5><HR>
    <form class="row g-3" action="/saveArtist" method="post">
    <div class="col-md-6">
    <label for="artist_name" class="form-label">Artist Name</label>
    <input type="text" class="form-control" Name="artist_name">
    </div>
    <div class="col-md-6">
    <label for="art_genre" class="form-label">Artist Genre </label>
    <input type="text" class="form-control" Name="art_genre">
    </div>
    <div class="col-md-6">
    <label for="address" class="form-label">Address </label>
    <input type="text" class="form-control" Name="address">
    </div>
    <div class="col-md-6">
    <label for="city_id" class="form-label">Select City</label>
    '''+cdd+'''
    </div>
    <div class="col-md-6">
    <label for="contact_no" class="form-label">Contact No.</label>
    <input type="text" class="form-control" Name="contact_no">
    </div>
    <HR>
    <div class="col-12" style="display:flex; justify-content:center;">
    <button type="submit" class="btn  btn-secondary">Save Artist Details</button>
    </div>
    </FORM>'''
    return artst

def NewCust(cdd):
    custtxt='''<h5 style="text-align:center">Add Customer Details</h5><HR>
    <form class="row g-3" action="/saveCust" method="post">
    <div class="col-md-6">
    <label for="cust_name" class="form-label">Customer Name</label>
    <input type="text" class="form-control" Name="cust_name">
    </div>
    <div class="col-md-6">
    <label for="cust_address" class="form-label">Address </label>
    <input type="text" class="form-control" Name="cust_address">
    </div>
    <div class="col-md-6">
    <label for="city" class="form-label">Select City</label>
    '''+cdd+'''
    </div>
    <div class="col-md-6">
    <label for="cust_phone" class="form-label">Contact No.</label>
    <input type="text" class="form-control" Name="cust_phone">
    </div>
    <div class="col-md-6">
    <label for="cust_email" class="form-label">Email ID</label>
    <input type="text" class="form-control" Name="cust_email">
    </div>
    <HR>
    <div class="col-12" style="display:flex; justify-content:center;">
    <button type="submit" class="btn  btn-secondary">Save Customer Details</button>
    </div>
    </FORM>'''
    return custtxt
    
def NewExhibition(cdd,gdd):
    exbtxt='''<h5 style="text-align:center">Exhibition Details</h5><HR>
    <form class="row g-3" action="/saveExhibition" method="post">
    <div class="col-md-6">
    <label for="exb_title" class="form-label">Exhibition Title</label>
    <input type="text" class="form-control" Name="exb_title">
    </div>
    <div class="col-md-6">
    <label for="city" class="form-label">Select City</label>
    '''+cdd+'''
    </div>
    <div class="col-md-6">
    <label for="gallery" class="form-label">Choose Gallery</label>
    '''+gdd+'''
    </div>
    <div class="col-md-6">
    <label for="exb_organised" class="form-label">Organised By </label>
    <input type="text" class="form-control" Name="exb_organised">
    </div>
    <div class="col-md-6">
    <label for="exb_from_date" class="form-label">Exhibition Start Date</label>
    <input type="date" class="form-control" Name="exb_from_date">
    </div>
    <div class="col-md-6">
    <label for="exb_end_date" class="form-label">Exhibition End Date</label>
    <input type="date" class="form-control" Name="exb_end_date">
    </div>
    <div class="col-md-6">
    <label for="exb_managed" class="form-label">Managed by</label>
    <input type="text" class="form-control" Name="exb_managed">
    </div>
    <HR>
    <div class="col-12" style="display:flex; justify-content:center;">
    <button type="submit" class="btn  btn-secondary">Save Exhibition Details</button>
    </div>
    </FORM>'''
    return exbtxt    

def NewPainting():
    paint='''<h5 style="text-align:center">Painting Details</h5><HR>
    <form class="row g-3" action="/savePainting" method="post" enctype = "multipart/form-data">
    <div class="col-md-6">
    <label for="caption" class="form-label">Painting Caption</label>
    <input type="text" class="form-control" Name="caption">
    </div>
    <div class="col-md-6">
    <label for="in_date" class="form-label">Date of Entry </label>
    <input type="date" class="form-control" Name="in_date">
    </div>
    <div class="col-md-6">
    <label for="painting_type" class="form-label">Painting Type </label>
    <input type="text" class="form-control" Name="painting_type">
    </div>
    <div class="col-md-6">
    <label for="genre" class="form-label">Genre </label>
    <input type="text" class="form-control" Name="genre">
    </div>
    <div class="col-md-6">
    <label for="lenth" class="form-label">Length in cms.</label>
    <input type="number" class="form-control" Name="lenth">
    </div>
    <div class="col-md-6">
    <label for="width" class="form-label">Width in cms.</label>
    <input type="number" class="form-control" Name="width">
    </div>
    <div class="col-md-6">
    <label for="price" class="form-label">Price</label>
    <input type="number" class="form-control" Name="price">
    </div>
    <div class="col-md-6">
    <label for="file" class="form-label">Upload Painting Thumbnail</label>
    <input type = "file" name = "file" style="margin:10px"/>
    </div>
    <HR>
    <div class="col-12" style="display:flex; justify-content:center;">
    <button type="submit" class="btn  btn-secondary">Save Painting Details</button>
    </div>
    </FORM>'''
    return paint

Software tools used

Front end:         Flask, HTML, BootStrap

Back end:          PostgreSQL

Future Enhancement

  • In current implementation of Online Art Gallery Management System, admin, customers or artists cannot filter the paintings on the basis of type of painting, genre, artists or other parameters.
  • An alert window displaying the upcoming exhibitions can be added to the system to inform admin, customers or artists.

Be First to Comment

Leave a Reply

Your email address will not be published.