Пример #1
0
def create():
    form = CreateAgentForm()
    if form.validate_on_submit():
        flash('Login requested for OpenID="%s"' % form.name)
        insert(form)  # Insert agent
        return redirect('/index')
    return render_template('create.html', title='Sign In', form=form)
Пример #2
0
def add_bank():
    form = Addbank()
    if(form.validate_on_submit()):
        length = query_db('select count(*) from bank')
        new_id = 'B_' + str(int(length[0][0]) + 1)
        insert('bank',('bid', 'lat', 'long', 'rateoffr'),(new_id,float(form.lat.data),float(form.long.data),float(form.rateoffr.data)))
        flash("Successfully added")
        return redirect(url_for('add_bank'))
    return render_template('bank.html',title="bank",form=form)
Пример #3
0
def insertintoshopinv():
    insert('shop_inv', ('svid', 'item_name', 'item_price', 'units'),
           ('SV_191', 'rice', 150.00, 100))
    insert('shop_inv', ('svid', 'item_name', 'item_price', 'units'),
           ('SV_191', 'Chicken', 250.00, 123))
    insert('shop_inv', ('svid', 'item_name', 'item_price', 'units'),
           ('SV_192', 'rice', 100.00, 232))
    insert('shop_inv', ('svid', 'item_name', 'item_price', 'units'),
           ('SV_192', 'cotton', 80.00, 111))
    insert('shop_inv', ('svid', 'item_name', 'item_price', 'units'),
           ('SV_193', 'rice', 300.00, 111))
Пример #4
0
def insertintosvcrop():
    insert('svcrop', ('svid', 'cid', 'amount_bought'),
           ('C_101', 'SV_191', 100))
    insert('svcrop', ('svid', 'cid', 'amount_bought'),
           ('C_101', 'SV_192', 232))
    insert('svcrop', ('svid', 'cid', 'amount_bought'),
           ('C_102', 'SV_193', 111))
    insert('svcrop', ('svid', 'cid', 'amount_bought'),
           ('C_103', 'SV_192', 111))
    insert('svcrop', ('svid', 'cid', 'amount_bought'),
           ('C_102', 'SV_191', 123))
Пример #5
0
def add_shop_inv():
    form = AddShopInv()
    if form.validate_on_submit():
        length = query_db(('Select COUNT(*) from shop_inv where svid=\'{}\' and item_name=\'{}\'').format(form.svid.data,form.item_name.data))
        if(length[0][0] == 0):
            insert('shop_inv',('svid','item_name','item_price','units'),(form.svid.data,form.item_name.data,float(form.item_price.data),float(form.units.data)))
        else:
            update_shopinv_amount(float(form.units.data),form.svid.data,form.item_name.data)    
        flash("Successfully added")
        return redirect(url_for('add_shop_inv'))
    return render_template('shop_inv.html',title="shop inventory",form=form)
Пример #6
0
def add_storagefac():
    form = AddStoragefac()
    if form.validate_on_submit():
        length = query_db('Select COUNT(*) from storagefacloc')
        new_id = 'S_' + str(int(length[0][0]) + 1)
        insert('storagefacloc',('sid', 'suitcond', 'size', 'unit', 'price', 'lat', 'long', 'typeoffarming', 'spaceleft', 'availability'),
            (new_id,form.suitcond.data,float(form.size.data),form.unit.data,float(form.price.data),float(form.lat.data),float(form.long.data),form.typeoffarming.data,float(float(form.spaceleft.data)),form.availability.data))
        insert('spstorage',('sid','spid'),(new_id,form.Storageprov_id.data))
        flash("Successfully added")
        return redirect(url_for('add_storagefac'))
    return render_template('storagefac.html',title="storage facility location",form = form)
Пример #7
0
def add_crop():
    form = AddCrop()
    if form.validate_on_submit():
        store_length= query_db('Select COUNT(*) from crop')
        print('Total records before a crop was added: ', store_length[0][0])
        new_id= 'C_'+str(int(store_length[0][0])+1)
        print('New ID allocated to the transporter is: ', new_id)
        insert('crop', ('cid', 'cname', 'units', 'typeoffarming', 'quantity', 'price'), (new_id, form.name.data, int(float(form.units.data)), form.farming.data, float(float(form.quantity.data)), float(float(form.price.data))))
        print('All records for the crop are: ')
        print(query_db("Select * from crop"))
        insert('landcrop',('lid','cid'),(form.land_id.data,new_id))
        flash("Successfully added new crop {}!".format(new_id))
        return redirect(url_for('add_crop'))
    return render_template('crop.html', title="Crop", form=form)
Пример #8
0
def add_shopvendor():
    form = AddShopVendor()
    if form.validate_on_submit():
        print('\n\nIncoming Data: ', (form.name.data, int(form.contact.data), float(float(form.lat.data)), float(float(form.long.data)), 0))
        store_length= query_db('Select COUNT(*) from shopvendor')
        print('Total records before a shopvendor was added: ', store_length[0][0])
        new_id= 'SV_'+str(int(store_length[0][0])+1)
        print('New ID allocated to the transporter is: ', new_id)
        insert('shopvendor', ('svid', 'svname', 'scontact', 'lat', 'long', 'authorized'), (new_id, form.name.data, int(form.contact.data), float(float(form.lat.data)), float(float(form.long.data)), 0))
        print('All records for the shopvendor are: ')
        print(query_db("Select * from shopvendor"))
        flash("Successfully added new shopvendor {}!".format(form.name.data))
        return redirect(url_for('add_shopvendor'))
    return render_template('shopvendor.html', title="Shop Vendor", form=form)
Пример #9
0
def add_storage_provider():
    form = AddStorageProvider()
    if form.validate_on_submit():
        store_length= query_db('Select COUNT(*) from storageprov')
        print('Total records before a storageprov was added: ', store_length[0][0])
        new_id= 'SP_'+str(int(store_length[0][0])+1)
        print('New ID allocated to the storageprov is: ', new_id)
        insert('storageprov', ('spid','sname','contact','lat','long','authorized'), (new_id, form.name.data, int(form.contact.data), float(float(form.lat.data)), float(float(form.long.data)), 0))
        print('All records for the storageprov are: ')
        print(query_db("Select * from storageprov"))
        flash("Successfully added new storageprov {}!".format(new_id))
        return redirect(url_for('add_storage_provider'))
    store_length= query_db('Select COUNT(*) from storageprov')
    print('Total records before loading storageprov: ', store_length[0][0])
    return render_template('storageprov.html', title="Storageprov", form=form)
Пример #10
0
def add_transporter():
    form = AddTransporter()
    if form.validate_on_submit():
        store_length= query_db('Select COUNT(*) from transporter')
        print('Total records before a transporter was added: ', store_length[0][0])
        new_id= 'T_'+str(int(store_length[0][0])+1)
        print('New ID allocated to the transporter is: ', new_id)
        insert('transporter', ('tid', 'tname', 'price', 'mintwht' , 'maxtwht', 'lat', 'long', 'resavl', 'authorized'), (new_id, form.tname.data, float(float(form.price.data)), float(form.mintwht.data), float(form.maxtwht.data), float(float(form.lat.data)), float(float(form.long.data)), float(form.resavl.data), 0))
        print('All records for the transporter are: ')
        print(query_db("Select * from transporter"))
        flash("Successfully added new transporter {}!".format(new_id))
        return redirect(url_for('add_transporter'))
    store_length= query_db('Select COUNT(*) from transporter')
    print('Total records before loading transporter: ', store_length[0][0])
    return render_template('transporter.html', title="Transporter", form=form)
Пример #11
0
def insertintofarmer():
    insert('farmer', ('fid', 'fname', 'fcontact', 'authorized', 'lat', 'long'),
           ('F_102', 'Ramu', 9997712345, 1, 28.613459, 77.176208))
    insert('farmer', ('fid', 'fname', 'fcontact', 'authorized', 'lat', 'long'),
           ('F_104', 'Sahu', 9412345678, 0, 28.603212, 77.188439))
    insert('farmer', ('fid', 'fname', 'fcontact', 'authorized', 'lat', 'long'),
           ('F_105', 'Sid', 7771122333, 1, 28.596580, 77.181745))
Пример #12
0
def insertintoland():
    insert('land', ('lid', 'areaocc', 'lat', 'long'),
           ('LD_1321', 44.12, 28.605548, 77.199597))
    insert('land', ('lid', 'areaocc', 'lat', 'long'),
           ('LD_5412', 12.89, 28.603212, 77.203631))
    insert('land', ('lid', 'areaocc', 'lat', 'long'),
           ('LD_3498', 23.01, 28.598238, 77.207236))
Пример #13
0
def insertintobank():
    insert('bank', ('bid', 'lat', 'long', 'rateoffr', 'authorized'),
           ("B_101", 28.614929, 77.217944, 1500, 1))
    insert('bank', ('bid', 'lat', 'long', 'rateoffr', 'authorized'),
           ("B_103", 28.614062, 77.220604, 2309, 0))
    insert('bank', ('bid', 'lat', 'long', 'rateoffr', 'authorized'),
           ("B-104", 28.610445, 77.222106, 3400, 1))
Пример #14
0
def add_package():
    if request.method == 'POST':
        data = request.form
        for i, j in data.items():
            if j:
                pass
            else:
                return redirect(url_for('register',
                                        error='All the fields are required!')
                                )
        add = insert()
        id = add.add_package(uid=session['user'], **data)
        return redirect(url_for('succ_reg', track_id=id))
    return redirect(url_for('register', error="Unsuccesfull"))
Пример #15
0
def add_admin():
    if request.method == 'POST':
        data = request.form
        if data['password1'] == data['password2']:
            add = insert()
            x = add.add_admin(**data)
            if x:
                return redirect(url_for('admin', error="success"))
            else:
                return redirect(url_for('admin',
                                        error="Username already exist"))
        else:
            return redirect(url_for('admin',
                                    error="Passwords do not match"))
Пример #16
0
def post_user_suggestion(request_data):
    try:
        user_name = request_data['user_name']
    except KeyError as _:
        raise BlankException(
            f'''There is no field [user_name] in the request body''')
    try:
        suggestion = request_data['suggestion']
    except KeyError as _:
        raise BlankException(
            f'''There is no field [suggestion] in the request body''')

    return insert('user_suggestions',
                  user_name=user_name,
                  suggestion=suggestion)
Пример #17
0
def insertintoshopv():
    insert('shopvendor',
           ('svid', 'svname', 'scontact', 'lat', 'long', 'authorized'),
           ('SV_191', 'Shop Benndor', 9898989898, 28.605133, 77.202709, 1))
    insert('shopvendor',
           ('svid', 'svname', 'scontact', 'lat', 'long', 'authorized'),
           ('SV_192', 'Shop Vendoe', 9898989898, 28.604116, 77.204254, 1))
    insert('shopvendor',
           ('svid', 'svname', 'scontact', 'lat', 'long', 'authorized'),
           ('SV_193', 'Shop LOL', 9898989898, 28.598012, 77.204812, 0))
Пример #18
0
def insertintocrop():
    insert('crop',
           ('cid', 'cname', 'units', 'typeoffarming', 'quantity', 'price'),
           ('C_101', 'rice', 'kg', 'commercial farming', 1.6, 30))
    insert('crop',
           ('cid', 'cname', 'units', 'typeoffarming', 'quantity', 'price'),
           ('C_103', 'cotton', 'kg', 'Extensive farming', 34.2, 10))
    insert('crop',
           ('cid', 'cname', 'units', 'typeoffarming', 'quantity', 'price'),
           ('C_102', 'Chicken', 'kg', 'poultry farming', 39.7, 120))
Пример #19
0
def insertintostorageprov():
    insert('storageprov',
           ('spid', 'sname', 'contact', 'lat', 'long', 'authorized'),
           ('SP_101', 'Madhav Thakur', 9999999999, 28.615268, 77.193353, 0))
    insert('storageprov',
           ('spid', 'sname', 'contact', 'lat', 'long', 'authorized'),
           ('SP_102', 'Rajesh Prasad', 9999999888, 28.615155, 77.198460, 1))
    insert('storageprov',
           ('spid', 'sname', 'contact', 'lat', 'long', 'authorized'),
           ('SP_103', 'Astha Malik', 9997879333, 28.613949, 77.202237, 1))
Пример #20
0
def insertintoloan():
    insert('loan',
           ('lid', 'rateoffr', 'dateoffr', 'offrto', 'iniamt', 'pendamt'),
           ('L_1586', 10.35, '22-04-10', 'F_102', 13500.00, 11000.00))
    insert('loan',
           ('lid', 'rateoffr', 'dateoffr', 'offrto', 'iniamt', 'pendamt'),
           ('L_2000', 8.00, '10-04-10', 'F_104', 50000.00, 49000.00))
    insert('loan',
           ('lid', 'rateoffr', 'dateoffr', 'offrto', 'iniamt', 'pendamt'),
           ('L_2314', 9.35, '18-04-10', 'F_105', 20500.00, 20500.00))
Пример #21
0
def add_loan():
    form = AddLoan()
    if form.validate_on_submit():
        length = query_db('Select COUNT(*) from loan')
        new_id= 'L_'+str(int(length[0][0])+1)
        insert('loan',('lid', 'rateoffr', 'dateoffr', 'offrto', 'iniamt', 'pendamt'),(new_id,float(form.rateoffr.data),form.date.data,form.fid.data,float(form.iniamt.data),float(form.pendamt.data)))
        insert('loantrans',('lid','transid'),(new_id,form.trans_id.data))
        insert('bankfloan',('lid','bid','fid'),(new_id,form.bid.data,form.fid.data))
        flash("Successfully added")
        return redirect(url_for('add_loan'))
    return render_template('loan.html',title="loan",form=form)
Пример #22
0
def insertintotransporter():
    insert('transporter', ('tid', 'tname', 'price', 'mintwht', 'maxtwht',
                           'resavl', 'authorized', 'lat', 'long'),
           ('T_101', 'Hardik Kapoor', 1800.00, 100, 1000, 1000, 1, 28.593113,
            77.202516))
    insert('transporter', ('tid', 'tname', 'price', 'mintwht', 'maxtwht',
                           'resavl', 'authorized', 'lat', 'long'),
           ('T_102', 'Raunaq Jha', 4200.00, 1000, 5000, 5000, 1, 28.593867,
            77.193418))
    insert('transporter', ('tid', 'tname', 'price', 'mintwht', 'maxtwht',
                           'resavl', 'authorized', 'lat', 'long'),
           ('T_103', 'Randeep Singh', 1300.00, 10, 500, 500, 0, 28.594018,
            77.198825))
Пример #23
0
def insertintostoragefacloc():
    insert('storagefacloc',
           ('sid', 'suitcond', 'size', 'unit', 'price', 'lat', 'long',
            'typeoffarming', 'spaceleft', 'availability'),
           ('S_145', 'dry', 146, 'kg', 150, 28.600122, 77.210691, 'poultry',
            23, 1))
    insert('storagefacloc',
           ('sid', 'suitcond', 'size', 'unit', 'price', 'lat', 'long',
            'typeoffarming', 'spaceleft', 'availability'),
           ('S_132', 'room temperature', 2345, 'litre', 450, 28.599218,
            77.215326, 'poultry', 300, 0))
    insert('storagefacloc',
           ('sid', 'suitcond', 'size', 'unit', 'price', 'lat', 'long',
            'typeoffarming', 'spaceleft', 'availability'),
           ('S_123', 'cold', 560, 'kg', 786, 28.594508, 77.215540, 'wheat',
            '20', 1))
Пример #24
0
def add_registerland():
    form = AddLand()
    if form.validate_on_submit():
        print('\n\nIncoming Data: ', (float(form.areaocc.data), float(float(form.lat.data)), float(float(form.long.data))))
        store_length= query_db('Select COUNT(*) from land')
        print('Total records before a land was added: ', store_length[0][0])
        new_id= 'LD_'+str(int(store_length[0][0])+1)
        print('New ID allocated to the transporter is: ', new_id)
        insert('land', ('lid', 'areaocc', 'lat', 'long'), (new_id, float(float(form.areaocc.data)), float(float(form.lat.data)), float(float(form.long.data))))
        print('All records for the land are: ')
        print(query_db("Select * from land"))
        flash("Successfully added new land {}!".format(new_id))
        insert('landcrop',('cid','lid'),(form.Crop_id.data,new_id))
        insert('farmerland',('fid','lid'),(form.Farmer_id.data,new_id))
        return redirect(url_for('add_registerland'))
    return render_template('registerland.html', title="Land", form=form)
Пример #25
0
def insertintostoragecrop():
    insert('storagecrop', ('sid', 'cid'), ('S_145', 'C_101'))
    insert('storagecrop', ('sid', 'cid'), ('S_132', 'C_102'))
    insert('storagecrop', ('sid', 'cid'), ('S_123', 'C_103'))
Пример #26
0
def insertintofspt():
    insert('fspt', ('transid', 'fid', 'spid'), ('TR_101', 'F_102', 'SP_101'))
    insert('fspt', ('transid', 'fid', 'spid'), ('TR_102', 'F_104', 'SP_102'))
    insert('fspt', ('transid', 'fid', 'spid'), ('TR_103', 'F_105', 'SP_103'))
Пример #27
0
def add_trans():
    form = Addtrans()
    if(form.validate_on_submit()):
        length = query_db('select count(*) from transactions')
        new_id = 'TR_' + str(int(length[0][0])+1)
        insert('transactions',('transid', 'amount', 'method'),(new_id,float(form.amount.data),form.method.data))
        if(form.identity_from.data == 'Farmer'):
            if(form.identity_to.data == 'transporter'):
                insert('ftt',('transid','fid','tid'),(new_id,form.from_id.data,form.to_id.data))
            if(form.identity_to.data == 'shopvendor'):
                insert('fsvt',('transid','fid','svid'),(new_id,form.from_id.data,form.to_id.data))    
            if(form.identity_to.data == 'storage provider'):
                insert('fspt',('transid','fid','spid'),(new_id,form.from_id.data,form.to_id.data))
        else:
            if(form.identity_from.data == 'transporter'):
                insert('ftt',('transid','fid','tid'),(new_id,form.to_id.data,form.from_id.data))
            if(form.identity_from.data == 'shopvendor'):
                insert('fsvt',('transid','fid','svid'),(new_id,form.to_id.data,form.from_id.data))    
            if(form.identity_from.data == 'storage provider'):
                insert('fspt',('transid','fid','spid'),(new_id,form.to_id.data,form.from_id.data))
                return redirect(url_for('add_trans'))
        flash("Successfully Added")
    return render_template('trans.html',title="trans",form=form)
Пример #28
0
def insertintoftt():
    insert('ftt', ('transid', 'fid', 'tid'), ('TR_110', 'F_102', 'T_101'))
    insert('ftt', ('transid', 'fid', 'tid'), ('TR_111', 'F_104', 'T_102'))
    insert('ftt', ('transid', 'fid', 'tid'), ('TR_112', 'F_105', 'T_103'))
Пример #29
0
def insertintofsvt():
    insert('fsvt', ('transid', 'fid', 'svid'), ('TR_101', 'F_102', 'SV_191'))
    insert('fsvt', ('transid', 'fid', 'svid'), ('TR_102', 'F_104', 'SV_192'))
    insert('fsvt', ('transid', 'fid', 'svid'), ('TR_103', 'F_105', 'SV_193'))
Пример #30
0
def insertintospstorage():
    insert('spstorage', ('sid', 'spid'), ('S_145', 'SP_101'))
    insert('spstorage', ('sid', 'spid'), ('S_132', 'SP_102'))
    insert('spstorage', ('sid', 'spid'), ('S_123', 'SP_103'))