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)
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)
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)
def all_(): """Get all the instruments""" instruments = api_models.process_instrument_db_list(InstrumentModel.scan()) return success(instruments)
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)
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)
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)
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)