Exemple #1
0
def show_inventory():
    lendydata.initDB()
    allItems = lendydata.get_items()
    inventory = [dict(zip(['name','description'],[item[1],item[2]]))
                 for item in allItems]

    return render_template('items.html', items=inventory)
Exemple #2
0
def show_inventory():
    lendydata.initDB()
    allItems = lendydata.get_items()
    inventory = [dict(zip(['name', 'description'], [item[1], item[2]]))
                 for item in allItems]

    return render_template('items.html', items=inventory)
Exemple #3
0
def get_db():
    ''' Opens a new database connection if one does not exist for our current
    request context (the g object helps with this task)'''

    if not hasattr(g, "sqlite_db"):

        lendydata.initDB()
        g.sqlite_db = lendydata.db

    return g.sqlite_db
Exemple #4
0
 def __init__(self, root):
     self.isDirty = False
     self.top = root
     root['menu'] = self.buildMenus(root)
     mainWin = self.buildNoteBook(root)
     mainWin.pack(fill='both', expand=True)
     self.top.protocol('WM_DELETE_WINDOW', self.evClose)
     self.top.title('Lending Library')
     data.initDB()  # use default file
     self.items = data.get_items()
     self.members = data.get_members()
     self.populateItemList()
     self.populateMemberList()
Exemple #5
0
 def __init__(self, root):
     self.isDirty = False
     self.top = root
     root['menu'] = self.buildMenus(root)
     mainWin = self.buildNoteBook(root)
     mainWin.pack(fill='both', expand=True)
     self.top.protocol('WM_DELETE_WINDOW', self.evClose)
     self.top.title('Lending Library')
     data.initDB()   # use default file
     self.items = data.get_items()
     self.members = data.get_members()
     self.populateItemList()
     self.populateMemberList()
Exemple #6
0
def add_item():
    if not session.get('logged_in'):
        abort(401)

    lendydata.initDB()
    ownerID = [row[0] for row in lendydata.get_members() 
               if row[1] == request.form['owner']]
    try: ownerID = ownerID[0]  
    except IndexError:
        # implies no owners match name
        # should raise eror/create new member
        ownerID = 1      # use default member for now.

    lendydata.insert_item(request.form['name'], 
                          request.form['description'],
                          ownerID,
                          request.form['price'],
                          request.form['condition'])
                         
    lendydata.closeDB()

    flash('New entry was successfully posted')
    return redirect(url_for('show_inventory'))
Exemple #7
0
def add_item():
    if not session.get('logged_in'):
        abort(401)

    lendydata.initDB()
    ownerID = [
        row[0] for row in lendydata.get_members()
        if row[1] == request.form['owner']
    ]
    try:
        ownerID = ownerID[0]
    except IndexError:
        # implies no owners match name
        # should raise eror/create new member
        ownerID = 1  # use default member for now.

    lendydata.insert_item(request.form['name'], request.form['description'],
                          ownerID, request.form['price'],
                          request.form['condition'])

    lendydata.closeDB()

    flash('New entry was successfully posted')
    return redirect(url_for('show_inventory'))
Exemple #8
0
def get_db():
    """Opens a new database connection if one does not exist."""
    if not hasattr(g, 'sqlite_db'):
        lendydata.initDB()
        g.sqlite_db = lendydata.db
    return g.sqlite_db
Exemple #9
0
__author__ = 'Stuart'

"""
any time there is a print, if in console don't print
it would just return normally
"""

import lendydata as ld
ld.initDB()
print(ld.get_members())
print(ld.get_items())

ld.insert_item('Python Projects','Book',6,30,'Excellent')
###
# this should not have worked..... BUT IT DID. WTF PRAGMA?!>!?
###

ld.insert_member('Alan','*****@*****.**')
print(ld.get_members())
ld.insert_item('Python Projects','Book',6,30,'Excellent')
ld.get_items()

ld.update_item(7,Price=25)
ld.get_item_details(7)
ld.get_member_name(6)
ld.update_member(6,Name='Alan Gould')
ld.get_member_details(6)

ld.delete_member(6)  # this also shouldn't work due to referential integrity, but does...
ld.delete_item(7)
ld.delete_member(6)
Exemple #10
0
def get_db():
    if not hasattr(g, 'sqlite_db'):
        lendydata.initDB()
        g.sqlite_db = lendydata.db
        return g.sqlite_db
Exemple #11
0
def get_db():
    """Opens a new database connection if one does not exist."""
    if not hasattr(g, 'sqlite_db'):
        lendydata.initDB()
        g.sqlite_db = lendydata.db
    return g.sqlite_db