def fetch_schedules(self, item_id): query = db.session.query(self.datamodel.obj) query = query.join(self.schedule_type_model).filter( self.schedule_type_model.id == item_id) schedules = [] for schedule in query.all(): info = {"schedule": schedule.id} for col in self.list_columns + self.add_exclude_columns: info[col] = getattr(schedule, col) if isinstance(info[col], enum.Enum): info[col] = info[col].name elif isinstance(info[col], security_manager.user_model): info[col] = info[col].username info["user"] = schedule.user.username info[self.schedule_type] = getattr(schedule, self.schedule_type).id schedules.append(info) return json_success(json.dumps(schedules, default=json_iso_dttm_ser))
def fetch_schedules(self, item_id): query = db.session.query(self.datamodel.obj) query = query.join(self.schedule_type_model).filter( self.schedule_type_model.id == item_id) schedules = [] for schedule in query.all(): info = {'schedule': schedule.id} for col in self.list_columns + self.add_exclude_columns: info[col] = getattr(schedule, col) if isinstance(info[col], enum.Enum): info[col] = info[col].name elif isinstance(info[col], security_manager.user_model): info[col] = info[col].username info['user'] = schedule.user.username info[self.schedule_type] = getattr(schedule, self.schedule_type).id schedules.append(info) return json_success(json.dumps(schedules, default=json_iso_dttm_ser))