class Product(types.Type): name = validators.String(max_length=10) rating = validators.Integer(allow_null=True, default=None, minimum=0, maximum=100) created = validators.DateTime()
class PuppyOutputType(types.Type): id = validators.Number(title="id", description="ID") name = validators.String(title="name", description="Name") number = validators.Integer(title="number", description="Number") time = validators.DateTime(title="time", description="Time") float = validators.Number(title="float", description="Float", allow_null=True) bool = validators.Boolean(title="bool", description="Boolean")
class CallBack(types.Type): """ 回调表 """ name = validators.String(max_length=255, title=u'接口名称', description=u'接口名称') url = validators.String(title=u'回调url', description=u'回调url') create_time = validators.DateTime(default=cur_date_time(), title=u'创建时间', description=u'创建时间') def __str__(self): return self.name
class Block(PickleType): height = validators.Integer() timestamp = validators.DateTime() txns = validators.Array(items=Transaction, allow_null=True, default=[]) mined_hash = validators.String(max_length=100) previous_hash = validators.String(max_length=100, allow_null=True) nonce = validators.Integer() @property def previous_block(self): return get_block(self.previous_hash)
class PuppyInputType(types.Type): name = validators.String(title="name", description="Name") number = validators.Integer(title="number", description="Number", default=0) time = validators.DateTime(title="time", description="Time") float = validators.Number(title="float", description="Float", allow_null=True) bool = validators.Boolean(title="bool", description="Boolean", default=False)
class OpeningDayEvent(BaseBlock): BLOCK_TYPE = "event_opening_dates" date_start = validators.DateTime() date_end = validators.DateTime() space_time_info = validators.String(allow_null=True) timetable = validators.Array(items=TimeTableItem) @classmethod def from_es(cls, es_poi, lang): if es_poi.PLACE_TYPE != 'event': return None date_start = es_poi.get('date_start') date_end = es_poi.get('date_end') space_time_info= es_poi.get('space_time_info') timetable = es_poi.get('timetable') or '' if not date_start or not date_end: return None timetable = timetable.split(';') new_format_timetable = [] for tt in filter(None, timetable): date_start_end = tt.split(' ') new_format_timetable.append( TimeTableItem(beginning=date_start_end[0], end=date_start_end[1]) ) timetable = new_format_timetable return cls( date_start=date_start, date_end=date_end, space_time_info=space_time_info, timetable=timetable )
class AirQuality(BaseBlock): BLOCK_TYPE = 'air_quality' CO = ParticleType PM10 = ParticleType O3 = ParticleType NO2 = ParticleType SO2 = ParticleType PM2_5 = ParticleType quality_index = validators.Integer(minimum=1, maximum=5) date = validators.DateTime() source = validators.String() source_url = validators.String() measurements_unit = validators.String(allow_null=True) @classmethod def from_es(cls, place, lang): if not settings['BLOCK_AIR_QUALITY_ENABLED']: return None if place.PLACE_TYPE != 'admin': return None if place.get('zone_type') not in ('city', 'city_district', 'suburb'): return None bbox = place.get_bbox() if not bbox: return None try: air_quality = get_air_quality(bbox) except Exception: logger.warning('Failed to fetch air quality for %s', place.get_id(), exc_info=True) return None if not air_quality: return None return cls(**air_quality)
class TimeTableItem(types.Type): beginning = validators.DateTime() end = validators.DateTime()
class TokenType(types.Type): id = UUID() user_id = validators.Integer() created = validators.DateTime() updated = validators.DateTime()
class UserType(UserBaseType): created = validators.DateTime() updated = validators.DateTime()
class Example(types.Type): when = validators.DateTime()
class Example(types.Type): when = validators.DateTime(allow_null=True)
class Transaction(PickleType): timestamp = validators.DateTime() sender = validators.String(max_length=100, allow_null=True) receiver = validators.String(max_length=100) amount = validators.Integer()
class Question(types.Type): id = validators.Integer(allow_null=False) created = validators.DateTime() topic = validators.Integer(allow_null=False) question = validators.String() answer = validators.String()
class BlockType(types.Type): index = validators.Integer() timestamp = validators.DateTime() data = validators.Any() previous_hash = validators.String() hash = validators.String()