コード例 #1
0
def admin(request):
    """
    Show Admin Page
    """
    out_dict = {}
    out_dict["headLinks"] = homepage.genHeadUrls(request)
    out_dict["sideLinks"] = homepage.genSideUrls(request)
    the_user = homepage.getUser(request)
    out_dict["user"] = the_user.username

    out_dict["pgTitle"] = "Admin Interface"

    # get list of users
    the_qry = DBSession.query(models.User)
    user_list = []
    for item in the_qry:
        user_list.append([item.username,
                         item.email,
                         request.route_url("user", id=item.id)])

    out_dict["userList"] = user_list


    return render_to_response('cogentviewer:templates/admin.mak',
                              out_dict,
                              request=request)
コード例 #2
0
def getHouseComfort(request):

    houseId = request.matchdict.get("hid")
    typeId = request.matchdict.get("tid")

    theHouse = DBSession.query(models.House).filter_by(id = houseId).first()
    #if theHouse is None:
    #    log.debug("No Such House")
    #    #Return a 404 if no such house is found
    #    request.response.status = 404
    #    return

    #Run Whatever Query we need to....
    theQry = DBSession.query(models.Reading).filter_by(typeId = typeId)
    theQry = theQry.limit(10)
    print theQry

    #And Turn Into Comfort Stuff

    #....

    #If you can get the data like this we are onto a winner...

    roomData =[{"name":"a Room",
                "data":{"hot":10,
                        "warm":20,
                        "cold":30,
                        }
                },
               {"name":"aother Room",
                "data":{"hot":100,
                        "warm":200,
                        "cold":300,
                        }
                }
               ]

    return roomData