Esempio n. 1
0
def updategraph():
    import json
    rep = abhomeclass.abDB()
    bstats = abhomeclass.getTechStats()
    hometemps = rep.getGoogleTableDataHomeTemps(6)
    boilertemps = rep.getGoogleTableDataBoilerTemps(6)
    print json.dumps({'hometemps':hometemps, 'boilertemps':boilertemps})
    return json.dumps({'hometemps':hometemps, 'boilertemps':boilertemps})
Esempio n. 2
0
def users():
    if session.get('permissions')!=1:
        return render_template('error.html', error='Not authorized', message='page restricted to admin users')

    currentuser = session.get('username')

    rep = abhomeclass.abDB()
    users = rep.getAllWebUsers()
    message = "Number of users: {}".format(len(users))
    return render_template('users.html',users=users, user=currentuser, message = message)
Esempio n. 3
0
def gasMeter():
    pager = getPageParam('page')
    if pager=="":
        pager="3"
    currentuser = session.get('username')
    rep = abhomeclass.abDB()
    readings = rep.getLastGasMeter(int(pager))

    return render_template('gasMeter.html', user=currentuser,
                           var=pager, readings=readings)
Esempio n. 4
0
def userHome():
    timeParam = getPageParam('time')
    currentuser = session.get('username')
    rep = abhomeclass.abDB()
    stats = abhomeclass.MakeStatsHTMLBlock(rep, timeParam)
    bstats = abhomeclass.getTechStats()
    hometemps = rep.getGoogleTableDataHomeTemps(timeParam)
    boilertemps = rep.getGoogleTableDataBoilerTemps(timeParam)

    return render_template('userHome.html', user=currentuser,
                           chart1=hometemps, chart2=boilertemps,
                           stats=stats, bstats=bstats)
Esempio n. 5
0
def deleteUser():

    if session.get('permissions')==1:
        param_id = getPageParam('id')
        rep = abhomeclass.abDB()
        ### check if user in database
        #print ("at delete user: ",param_id)
        response = rep.deleteUserById(param_id)
        #print (response)
        return json.dumps({'status':'ok', 'message': 'User deleted'})
    else:
        return render_template('error.html', error='Not authorized', message='page restricted to admin users')
Esempio n. 6
0
def boilerSettings():
    # return render_template('error.html', error='page not impemented.', message='work in progress')
    timeParam = getPageParam('time')
    currentuser = session.get('username')
    rep = abhomeclass.abDB()
    stats = abhomeclass.MakeStatsHTMLBlock(rep, timeParam)
    bstats = abhomeclass.getTechStats()
    hometemps = rep.getGoogleTableDataHomeTemps(timeParam)
    boilertemps = rep.getGoogleTableDataBoilerTemps(timeParam)

    return render_template('boilerSettings.html', user=currentuser,
                           var=timeParam,
                           chart1=hometemps, chart2=boilertemps, stats=stats, bstats=bstats)
Esempio n. 7
0
def submitReading():
    perm = session.get('permissions')
    if perm !=1:
        return render_template('error.html', error='Not allowed to submit reading', message='page restricted to admin users')
    form = request.form
    param = form["reading"]

    value = float(param)
    rep = abhomeclass.abDB()
    readings = rep.getLastGasMeter(1)
    last = readings[0].get_reading()
    date = datetime.datetime.now()  #.strftime("%Y-%m-%d %H:%M")
    if (value > last):
        currentuser=session.get('user')
        record = abhomeclass.GasMeter(gm_reading=value, gm_submitter =currentuser, gm_date=date)
        status = rep.appendGasMeterRecord(record)
        message = "reading accepted: {}\n DB status:{}".format(param,status)
        return json.dumps({'status': 'ok', 'message': message})
    else:
        message = "reading rejected: submitted:{} (last:{})".format(param,last)
        return json.dumps({'status': 'error', 'message': message})