def delete_prefixes(self): prefixes = LocationPrefix.select().where( LocationPrefix.location_id == self.location_id ) for prefix in prefixes: prefix.delete_instance()
def get(self): location_id = self.get_location_id() # make sure location exists try: location = Location.get(Location.location_id == location_id) except peewee.DoesNotExist: abort(404, message="location_id does not exist") query = LocationPrefix.select().where( LocationPrefix.location_id == location_id) prefixes = [] for prefix in query: prefixes.append(prefix.to_dict()) return { 'status': 'ok', 'location_prefixes': prefixes, 'location': location.to_dict() }
def get(self): location_id = self.get_location_id() # make sure location exists try: location = Location.get(Location.location_id == location_id) except peewee.DoesNotExist: abort(404, message="location_id does not exist") query = LocationPrefix.select().where( LocationPrefix.location_id == location_id ) prefixes = [] for prefix in query: prefixes.append(prefix.to_dict()) return { 'status': 'ok', 'location_prefixes': prefixes, 'location': location.to_dict() }
def delete_prefixes(self): prefixes = LocationPrefix.select().where( LocationPrefix.location_id == self.location_id) for prefix in prefixes: prefix.delete_instance()