Пример #1
0
def results():
    #results = db.session.query(Person).\
    results = s.query(Person).\
        join(User, User.person_id==Person.id).\
        join(Evaluation, Evaluation.evaluator_id==Person.id)

    json_results = []

    for result in results:
      d = {'username': result.user.username,
            'id': result.id,
            'type': result.type,
            'comment': result.evaluation.comments},
      json_results.append(d)

    return jsonify(items=json_results)
Пример #2
0
# SQLAlchemy object -> Evaluation of a site
#qEvaluations = db.session.query(Site.address,
qEvaluations = s.query(Site.address,
                                Site.city,
                                Site.zip,
                                Site.neighborhood,
                                Site.raingarden,
                                Geoposition.latitude,
                                Geoposition.longitude,
                                Geoposition.accuracy,
                                Person.firstname,
                                Person.lastname,
                                Evaluation.evaluation_id,
                                Evaluation.eval_type,
                                Evaluation.garden_id,
                                Evaluation.scoresheet,
                                Evaluation.score,
                                Evaluation.rating,
                                Evaluation.ratingyear,
                                Evaluation.comments,
                                Evaluation.date_evaluated,
                                Evaluation.evaluator_id). \
    outerjoin(Evaluation, Site.garden_id == Evaluation.garden_id). \
    outerjoin(Evaluator, Evaluator.evaluator_id == Evaluation.evaluator_id). \
    outerjoin(Person, Evaluator.user_id == Person.user_id). \
    outerjoin(Geoposition, Geoposition.geo_id == Site.geo_id). \
    filter(and_(Evaluation.completed == 1,
                Evaluation.scoresheet != None,
                Evaluation.score.isnot(None)))

'''
Пример #3
0
 def load_user(id):
     #return db.session.query(User).get(int(id))
     return s.query(User).get(int(id))