Esempio n. 1
0
def main():
    ''' Delete any residual links in the db and display the main menu
    '''
    # Clear temp database for a new session
    Temp.objects().delete()

    return render_template('main/main.html')
Esempio n. 2
0
def deleteentry():
    '''
    Delete an existing entry from the database

    '''
    if request.method == 'POST':
        # Get desired project
        num = request.form['num']
        # PDelete the record from mongo database
        try:
            Database.objects(num=num).delete()
        except:

            return render_template('engineers/dberror4.html')

        #send delete success
        return render_template('engineers/deleteentry.html')

    # Build list of projects in database and send to selector form

    # Get sa
    sa_list= []
    for sa in Temp.objects():
        sa_list.append(sa.sa)
    sa = sa_list[0]
    sa = sa.encode('utf-8')
    sa=sa.replace(" ", "-")

    entries = []
    for e in Database.objects():
        if e.sa == sa:
            entries.append(e.num)
    return render_template('engineers/entryeditdelete.html', entries=entries)
Esempio n. 3
0
def editentry():
    '''
    Edit an existing entry from the database

    '''
    if request.method == 'POST':
        # Get desired project
        num = request.form['num']
        # PDelete the record from mongo database
        entry = Database.objects(num=num)

        # create list from database entry
        more = {
                "num" : entry[0].num,
                "now" : entry[0].now,
                "sa" : entry[0].sa,
                "message" : entry[0].message,
                "concern" : entry[0].concern
                }
        # rick.append('fail')
        #send form with info list
        return render_template('engineers/editentry.html', more=more)
    # Get sa
    sa_list= []
    for sa in Temp.objects():
        sa_list.append(sa.sa)
    sa = sa_list[0]
    sa = sa.encode('utf-8')
    sa=sa.replace(" ", "-")

    entries = []
    for e in Database.objects():
        if e.sa == sa:
            entries.append(e.num)
    return render_template('engineers/entryeditselect.html', entries=entries)
Esempio n. 4
0
def main_engineer():

    # Get sa
    sa_list = []
    for sa in Temp.objects():
        sa_list.append(sa.sa)
    sa = sa_list[0]
    sa = sa.encode('utf-8')
    sa = sa.replace(" ", "-")

    return render_template('main/engineer.html', sa=sa)
Esempio n. 5
0
def main_select():
    sa = request.form['sa']
    # Stash the user
    # Build record to write to mongo database

    temp = Temp(sa=sa)
    # Save the record
    try:
        temp.save()
    except:
        return render_template('engineers/dberror.html')

    if sa == 'Rick Hawkins':

        # Get engineers
        eng_list = []
        for eng in Engineers.objects():
            eng.name = eng.name.encode('utf-8')
            eng_list.append(eng.name)

        return render_template('main/manager.html', sa=sa, eng=eng_list)
    else:
        return render_template('main/engineer.html', sa=sa)
Esempio n. 6
0
def cloneentry():
    '''
    Clone an existing entry from the database

    '''
    if request.method == 'POST':
        # Get desired project
        num = request.form['num']
        # PDelete the record from mongo database
        entry = Database.objects(num=num)

        # Get next record number and add 1
        num_list= []
        for n in Number.objects():
            num_list.append(n.num)
        num = num_list[0]

        # Get time date stamp
        now = datetime.datetime.now()
        now = now.isoformat()


        # create list from database entry
        more = {
                "num" : num,
                "now" : now,
                "sa" : entry[0].sa,
                "message" : entry[0].message,
                "concern" : entry[0].concern
                }


        #send form with info list
        return render_template('engineers/cloneentry.html', more=more)
    # Get sa
    sa_list= []
    for sa in Temp.objects():
        sa_list.append(sa.sa)
    sa = sa_list[0]
    sa = sa.encode('utf-8')
    sa=sa.replace(" ", "-")

    entries = []
    for e in Database.objects():
        if e.sa == sa:
            entries.append(e.num)
    return render_template('engineers/entrycloneselect.html', entries=entries)
Esempio n. 7
0
def main_manager():

    # Get sa
    sa_list = []
    for sa in Temp.objects():
        sa_list.append(sa.sa)
    sa = sa_list[0]
    sa = sa.encode('utf-8')
    sa = sa.replace(" ", "-")

    # Get engineers
    eng_list = []
    for eng in Engineers.objects():
        eng.name = eng.name.encode('utf-8')
        eng_list.append(eng.name)

    return render_template('main/manager.html', sa=sa, eng=eng_list)
Esempio n. 8
0
def listentry():
    '''
    List all entries from the database by SA

    '''
    # Get sa
    sa_list= []
    for sa in Temp.objects():
        sa_list.append(sa.sa)
    sa = sa_list[0]
    sa = sa.encode('utf-8')
    sa=sa.replace(" ", "-")

    entries = []
    for e in Database.objects():
        if e.sa == sa:
            entries.append(e)
    return render_template('engineers/listentry.html', entries=entries)
Esempio n. 9
0
def newentry():
    '''
    Adds a new entry to the database
    Reads form variables, creates an entry and
    saves it to the mongo database..

    '''
    # Get sa
    sa_list= []
    for sa in Temp.objects():
        sa_list.append(sa.sa)
    sa = sa_list[0]
    sa = sa.encode('utf-8')
    sa=sa.replace(" ", "-")

    # Get time date stamp
    now = datetime.datetime.now()
    now = now.isoformat()


    # Get next record number and add 1
    num_list= []
    for n in Number.objects():
        num_list.append(n.num)
    num = num_list[0]
    more = [sa,now,num]

    # rick.append('fail')
    error='none'
    form = DatabaseForm()
    if form.validate_on_submit():
        message=form.message.data
        concern=form.concern.data

        message = message.encode('utf-8')
        concern = concern.encode('utf-8')

        # Build record to write to mongo database

        entry = Database(sa=sa,message=message,concern=concern,now=now,num=num)
        #rick.append('faiul')

        # Save the record
        try:
            entry.save()
        except:
            return render_template('engineers/dberror2.html',error=error)

        # Increment number for next use
        num = num + 1

        # Clear temp database for a new session
        Number.objects().delete()

        # write the new number
        update = Number(num=num)

        # Save the number record for the next use
        try:
            update.save()
        except:
            return render_template('engineers/dberror3.html')


        return render_template('engineers/savedentry.html')
    return render_template('engineers/newentry.html', form=form, more=more)