コード例 #1
0
def read_user_pools(user_id):
    """
    This function responds to a request for /api/people
    with the complete lists of people

    :return:        json string of list of people
    """
    # Create the list of people from our data
    user = (User.query.filter(User.user_id == user_id).one_or_none())

    # Did we find a person?
    if user is not None:

        pools = Pool.query\
            .filter(Transaction.user_id == user_id)\
            .outerjoin(Pool, Transaction.pool_id == Pool.pool_id)\
            .order_by(db.desc(Pool.pool_tmodified)).all()

        # Serialize the list of notes from our data
        pool_schema = PoolSchema(many=True, exclude=[])
        data = pool_schema.dump(pools).data
        return data

    # Otherwise, nope, didn't find that person
    else:
        abort(404, "Pool not found for user ID: {user_id}")
コード例 #2
0
def get_all():
    # Query the database for all the notes
    coms = Commentaire.query.order_by(db.desc(Commentaire.timestamp)).all()

    # Serialize the list of notes from our data
    com_schema = ComSchema(many=True)
    return com_schema.dump(coms)
コード例 #3
0
def read_all():

    notes = Note.query.order_by(db.desc(Note.timestamp)).all()

    note_schema = NoteSchema(many=True)
    data = note_schema.dump(notes)
    return data
コード例 #4
0
def get_activity_comments(id_sortie):
    coms = Commentaire.query.filter(
        Commentaire.id_sortie == id_sortie).order_by(
            db.desc(Commentaire.timestamp)).all()

    com_schema = ComSchema(many=True)
    return com_schema.dump(coms)
コード例 #5
0
def get_all():
    stories = History.query.order_by(db.desc(History.created_at)).all()

    if stories is not None:
        stories_schema = HistorySchema(many=True)
        return stories_schema.dump(stories)

    else:
        abort(404, "Nothing found")
コード例 #6
0
def get_max_ms(family_id):
    material = (Material.query.filter(
        Material.family_id == family_id).outerjoin(Family).order_by(
            db.desc(Material.masse_surfacique)).first())
    if material is not None:

        return material.masse_surfacique
    else:

        abort(404, f"Family not found for Id: {family_id}")
コード例 #7
0
ファイル: notes.py プロジェクト: Sneh1999/Peoples-database
def read_all():
    """
    This function responds to a request for /api/people/notes
    with the complete list of notes, sorted by note timestamp
    :return: json list of all notes for all people
    """
    notes = Note.query.order_by(db.desc(Note.timestamp)).all()
    note_schema = NoteSchema(many=True, exclude=["person.notes"])
    data = note_schema.dump(notes)
    return data
コード例 #8
0
def read_all():
    """
    This function responds to a request for /api/people/notes
    with the complete list of notes, sorted by note timestamp
    :return:                json list of all notes for all people
    """
    # Query the database for all the notes
    notes = Note.query.order_by(db.desc(Note.timestamp)).all()

    # Serialize the list of notes from our data
    note_schema = NoteSchema(many=True)
    data = note_schema.dump(notes)
    return data
コード例 #9
0
ファイル: notes.py プロジェクト: free4m/realpython
def read_all():
    """
    refers to /api/people/notes

    :return: json list of all notes for all people
    """
    # query for the notes
    notes = Note.query.order_by(db.desc(Note.timestamp)).all()

    # serialize the list
    note_schema = NoteSchema(many=True, exclude=["person.notes"])
    data = note_schema.dump(notes)
    return data
コード例 #10
0
ファイル: app.py プロジェクト: saadalmogren/FSND
def index():
    print("hi")
    venues = Venue.query.order_by(db.desc(Venue.created)).limit(10).all()
    artists = Artist.query.order_by(db.desc(Artist.created)).limit(10).all()
    
    vdata=[]
    adata=[]

    for venue in venues:
        vdata.append({
            'id': venue.id,
            'name': venue.name,
            'image_link': venue.image_link
        })
    for artist in artists:
        adata.append({
            'id': artist.id,
            'name': artist.name,
            'image_link': artist.image_link
        })    
    
    return render_template('/pages/home.html', adata = adata, vdata = vdata)
コード例 #11
0
def read_all():
    """
    This function responds to a request for /api/resep/bahan
    with the complete list of bahan, sorted by bahan timestamp
    :return:                json list of all bahan for all people
    """
    # Query the database for all the bahan
    bahan = Bahan.query.order_by(db.desc(Bahan.timestamp)).all()

    # Serialize the list of bahan from our data
    bahan_schema = BahanSchema(many=True)
    data = bahan_schema.dump(bahan)
    return data
コード例 #12
0
ファイル: tasks.py プロジェクト: ledbagholberton/Bunny
def read_all():
    """
    This function responds to a request for /api/people/notes
    with the complete list of notes, sorted by note timestamp

    :return:                json list of all notes for all people
    """
    # Query the database for all the notes
    tasks = Task.query.order_by(db.desc(Task.timestamp)).all()

    # Serialize the list of notes from our data
    task_schema = TaskSchema(many=True, exclude=["user.notes"])
    data = task_schema.dump(tasks).data
    return data
コード例 #13
0
ファイル: addresses.py プロジェクト: kimyong/flaskdb
def read_all():
    """
    This function responds to a request for /api/people/notes
    with the complete list of notes, sorted by note timestamp

    :return:                json list of all notes for all people
    """
    # Query the database for all the notes
    addresses = Address.query.order_by(db.desc(Address.timestamp)).all()

    # Serialize the list of notes from our data
    address_schema = AddressSchema(many=True, exclude=["person.addresses"])
    data = address_schema.dump(addresses).data
    return data
コード例 #14
0
ファイル: notes.py プロジェクト: rtelles64/people_api
def read_all():
    '''
    This function responds to a request for /api/people/notes with the complete
    list of notes, sorted by note timestamp

    Returns
    -------
    list
        A JSON list of all notes for all people
    '''
    # Query the database for all the notes
    notes = Note.query.order_by(db.desc(Note.timestamp)).all()

    # Serialize the list of notes from our data
    note_schema = NoteSchema(many=True, exclude=['person.notes'])
    data = note_schema.dump(notes)

    return data
コード例 #15
0
def read_all(pool_ids=None):
    """
    This function responds to a request for /api/people/notes
    with the complete list of notes, sorted by note timestamp

    :return:                json list of all notes for all people
    """
    # Query the database for all the notes

    if not pool_ids:
        pools = Pool.query.order_by(db.desc(Pool.pool_tmodified)).all()
    else:
        pools = Pool.query \
        .filter(Pool.pool_id.in_(pool_ids)) \
        .all()

    # Serialize the list of notes from our data
    pool_schema = PoolSchema(many=True, exclude=[])
    data = pool_schema.dump(pools).data
    return data
コード例 #16
0
ファイル: transaction.py プロジェクト: paulpierre/binarygame
def read_all(transaction_ids=None):
    """
    This function responds to a request for /api/people/notes
    with the complete list of notes, sorted by note timestamp

    :return:                json list of all notes for all people
    """
    # Query the database for all the notes
    if not transaction_ids:
        transactions = Transaction.query.order_by(
            db.desc(Transaction.transaction_tmodified)).all()
    else:
        transactions = Transaction.query \
        .filter(Transaction.transaction_id.in_(transaction_ids)) \
        .all()
    # Serialize the list of notes from our data
    transaction_schema = TransactionSchema(many=True,
                                           exclude=["pool.pool_users"])
    data = transaction_schema.dump(transactions).data
    return data