Exemplo n.º 1
0
def signed_out():
    """Find instruments that haven't been signed back in yet"""
    found = InstrumentModel.scan((InstrumentModel.assignedTo.exists())
                                 & (InstrumentModel.gifted == False))
    instruments_out = api_models.process_instrument_db_list(found)

    return data_or_404(instruments_out)
Exemplo n.º 2
0
def history_and_assigned(search: api_models.Search):
    """Find a student's assigned instrument and history"""
    found_items = InstrumentModel.scan(
        InstrumentModel.history.contains(search.term)
        | InstrumentModel.assignedTo.contains(search.term))
    instruments_out = api_models.process_instrument_db_list(found_items)
    return data_or_404(instruments_out)
Exemplo n.º 3
0
def main(instrument_filter: api_models.InstrumentFilter):
    """Filter instruments by certain values"""
    filter_string = instrument_filter.generate_filter_string()

    found = InstrumentModel.scan(eval(filter_string))
    instruments_out = api_models.process_instrument_db_list(found)

    return success(instruments_out)
Exemplo n.º 4
0
def all_():
    """Get all the instruments"""
    instruments = api_models.process_instrument_db_list(InstrumentModel.scan())
    return success(instruments)
Exemplo n.º 5
0
def gifted():
    """Find instruments that have been given away to students"""
    found = InstrumentModel.scan(InstrumentModel.gifted == True)
    instruments_out = api_models.process_instrument_db_list(found)
    return data_or_404(instruments_out)
Exemplo n.º 6
0
def number(search: api_models.Search):
    """Find an instrument by number"""
    # noinspection PyTypeChecker
    found_items = InstrumentModel.scan(InstrumentModel.number == search.term)
    instruments_out = api_models.process_instrument_db_list(found_items)
    return data_or_404(instruments_out)
Exemplo n.º 7
0
def history(search: api_models.Search):
    """Find an instrument by its history"""
    found_items = InstrumentModel.scan(
        InstrumentModel.history.contains(search.term))
    instruments_out = api_models.process_instrument_db_list(found_items)
    return data_or_404(instruments_out)
Exemplo n.º 8
0
def assigned(search: api_models.Search):
    """Find an instrument by who it's assigned to"""
    found_items = InstrumentModel.scan(
        InstrumentModel.assignedTo.contains(search.term))
    instruments_out = api_models.process_instrument_db_list(found_items)
    return data_or_404(instruments_out)