class Period(_Model): start_time = p.TimeField() end_time = p.TimeField() def __repr__(self): return 'Period(start_time={}, end_time={})'.format( self.start_time, self.end_time)
class RangoHorario(models.Model): ''' Especifica los rangos horarios en los que la politica esta activa. Atributos ---------- * dia: Dia de la semana, entre 0 y 6 siendo 0 el dia domingo y 6 sabado * hora_inicial: Hora de inicio del rango valido * hora_fin: Hora de fin del rango valido ''' id_rango_horario = models.PrimaryKeyField() politica = models.ForeignKeyField(Politica, related_name='horarios', db_column='id_politica') dia = models.SmallIntegerField() hora_inicial = models.TimeField() hora_fin = models.TimeField() def __contains__(self, item): ''' Devuelve verdadero si la fecha-hora (item) esta dentro del rango. ''' return (item.weekday() == self.dia and self.hora_inicial <= item.time() < self.hora_fin) class Meta: database = db db_table = u'rango_horario'
class Restaurant(peewee.Model): name = peewee.CharField() open_since = peewee.DateField() opening_time = peewee.TimeField() closing_time = peewee.TimeField() class Meta: database = db
class TimeTable(peewee.Model): class Meta: database = database train = peewee.ForeignKeyField(Train) station = peewee.ForeignKeyField(Station) arrive = peewee.TimeField() leave = peewee.TimeField()
class Model1(BaseModel): def __init__(self, test1=None, test2=None, test3=None, test4=None, date_field=None, timeonly_field=None, datetime_field=None): super(Model1, self).__init__() self.test1 = test1 self.test2 = test2 self.test3 = test3 self.test4 = test4 self.date_field = date_field self.timeonly_field = timeonly_field self.datetime_field = datetime_field test1 = peewee.CharField(max_length=20, null=True) test2 = peewee.CharField(max_length=20, null=True) test3 = peewee.TextField(null=True) test4 = peewee.TextField(null=True) date_field = peewee.DateField(null=True) timeonly_field = peewee.TimeField(null=True) datetime_field = peewee.DateTimeField(null=True) def __str__(self): return self.test1
class Model1(BaseModel): def __init__(self, test1=None, test2=None, test3=None, test4=None, date_field=None, timeonly_field=None, datetime_field=None, **kwargs): super(Model1, self).__init__(**kwargs) self.test1 = test1 self.test2 = test2 self.test3 = test3 self.test4 = test4 self.date_field = date_field self.timeonly_field = timeonly_field self.datetime_field = datetime_field test1 = peewee.CharField(max_length=20, null=True) test2 = peewee.CharField(max_length=20, null=True) test3 = peewee.TextField(null=True) test4 = peewee.TextField(null=True) date_field = peewee.DateField(null=True) timeonly_field = peewee.TimeField(null=True) datetime_field = peewee.DateTimeField(null=True) def __str__(self): # "or ''" fixes error when loading choices for relation field: # TypeError: coercing to Unicode: need string or buffer, NoneType found return self.test1 or ""
class Task(BaseModel): title = pw.CharField(max_length=100) description = pw.TextField() date = pw.DateField() time = pw.TimeField() status = pw.IntegerField(default=0) user = pw.ForeignKeyField(User)
class DailyReminder(BaseModel): time = peewee.TimeField(null=False) text = EmojiField(null=False) weekend = peewee.BooleanField(null=True) weekday = peewee.BooleanField(null=True) user_id = peewee.BigIntegerField(null=False) last_reminded = peewee.DateField(null=True)
class Shop(BaseModel): name = pw.CharField(null=False) email = pw.CharField(null=False, unique=True) password = pw.CharField(null=False) profile_photo = pw.CharField( default="") # to add placeholder profile photo address_line_1 = pw.CharField(null=False) address_line_2 = pw.CharField(default="") state = pw.CharField(null=False) country = pw.CharField(default="Malaysia") postcode = pw.CharField(null=False) # True for work days, false otherwise # e.g. if shop operates on Monday only, then only Monday is True mon = pw.BooleanField(default=False) tue = pw.BooleanField(default=False) wed = pw.BooleanField(default=False) thu = pw.BooleanField(default=False) fri = pw.BooleanField(default=False) sat = pw.BooleanField(default=False) sun = pw.BooleanField(default=False) # Assuming same operating hours on all chosen work days # This is either the full operating hours, or the work session before lunch break start_time_1 = pw.TimeField(null=False) end_time_1 = pw.TimeField(null=False) # work session after lunch break. optional. start_time_2 = pw.TimeField() end_time_2 = pw.TimeField() def validate(self): super().email_check(Staff) super().password_check() super().postcode_check() self.time_check() def time_check(self): if end_time_1 < start_time_1: self.errors.append("End time cannot be earlier than start time!") if end_time_2 and start_time_2: if end_time_2 < start_time_2: self.errors.append( "End time cannot be earlier than start time!")
class Reminder(peewee.Model): id = peewee.IntegerField() time = peewee.TimeField() text = peewee.CharField() date = peewee.DateTimeField() class Meta: database = database
class CacheModel(peewee.Model): path = peewee.CharField(unique=True, index=True) fileTree = peewee.TextField() page = peewee.IntegerField(default=0) expire_time = peewee.TimeField() class Meta: database = db
class america_parent(peewee.Model): LANGUAGES = ((0, 'English'), (1, 'Spanish'), (2, 'Arabic')) account_id = peewee.IntegerField() primary_language = peewee.IntegerField(choices=LANGUAGES, default=0) sms_preference_time = peewee.TimeField(default=time(12, 0, 0)) # 8am UTC sms_preference_timezone = peewee.CharField(max_length=200, default='Asia/Kuwait') class Meta: database = db
class GoldPrice(peewee.Model): ''' price, date, crawling_times, time ''' price = peewee.CharField() date = peewee.DateField() crawling_times = peewee.IntegerField() time = peewee.TimeField() class Meta: database = database
class InputLineBook(peewee.Model): """Input line for creating new booking item (event).""" start_date = peewee.DateField(null=True) start_time = peewee.TimeField(null=True) duration_seconds = peewee.IntegerField(null=True) class Meta: """Metadata.""" database = db_proxy
class GameTable(peewee.Model): id = peewee.AutoField() firstPlayer = peewee.ForeignKeyField(User, to_field="id") secondPlayer = peewee.ForeignKeyField(User, to_field="id") thirdPlayer = peewee.ForeignKeyField(User, to_field="id") fourthPlayer = peewee.ForeignKeyField(User, to_field="id") time = peewee.TimeField() date = peewee.DateTimeField() class Meta: database = DatabaseConnection.getConnection()
class Alarm(BaseModel): name = peewee.CharField() source = peewee.CharField() url = peewee.CharField() alarmTime = peewee.TimeField() created = peewee.DateTimeField(default=datetime.datetime.now) lastAlarm = peewee.DateTimeField( default=datetime.datetime.utcfromtimestamp(0)) repeatDays = peewee.CharField() active = peewee.BooleanField(default=True) playing = peewee.BooleanField(default=False)
class Weather(peewee.Model): ''' city_code, max_temp, min_temp, date, time ''' city_code = peewee.CharField() max_temp = peewee.CharField() min_temp = peewee.CharField() date = peewee.DateField() time = peewee.TimeField() class Meta: database = database
class AppPrice(peewee.Model): ''' app name, price, date, crawling_times, time ''' app_name = peewee.CharField() price = peewee.CharField() date = peewee.DateField() crawling_times = peewee.IntegerField() time = peewee.TimeField() class Meta: database = database
class Charges(peewee.Model): case_number = peewee.CharField(null=True) charge_description = peewee.CharField(null=True) charge_status = peewee.CharField(null=True) bail_amount = peewee.CharField(null=True) bond_type = peewee.CharField(null=True) court_date = peewee.DateField(null=True) court_time = peewee.TimeField(null=True) court_jurisdiction = peewee.CharField(null=True) class Meta: database = db
class charge(peewee.Model): detainee_id = peewee.CharField() case_num = peewee.CharField() description = peewee.CharField() status = peewee.CharField() bail_amount = peewee.CharField() bond_type = peewee.CharField() court_date = peewee.DateField() court_time = peewee.TimeField() jurisdiction = peewee.CharField() class Meta: database = db
class Server(BaseModel): id = pw.IntegerField(primary_key=True) channel = pw.IntegerField(null=False) movie_time = pw.TimeField(null=False, formats="%H:%M", default="12:00") admin_role = pw.TextField(null=False, default="Movie Master") tie_option = pw.TextField(null=False, default="breaker") num_movies_per_vote = pw.SmallIntegerField(null=False, default=8) num_votes_per_user = pw.SmallIntegerField(null=False, default=4) block_suggestions = pw.BooleanField(null=False, default=False) check_movie_names = pw.BooleanField(null=False, default=False) message_timeout = pw.SmallIntegerField(null=False, default=10) class Meta: table_name = "servers"
class Events(peewee.Model): id = peewee.IntegerField() date = peewee.DateField() time = peewee.TimeField() text = peewee.CharField() count = peewee.IntegerField() fun = peewee.CharField() creator = peewee.IntegerField() members = peewee.CharField() status = peewee.IntegerField() address = peewee.CharField() class Meta: database = database
class User(pw.Model): """Model a Telegram user.""" telegram_id = pw.IntegerField(unique=True) name = pw.CharField(null=True) active = pw.BooleanField(default=True) # Did the user complete the intro script intro_seen = pw.BooleanField(default=False) # Does the user want to be asked for their mood? ask_mood = pw.BooleanField(default=True) # Does the user want to be asked to record good things? ask_good_things = pw.BooleanField(default=True) # Does the user want to be asked to complete a regular diary? ask_diary = pw.BooleanField(default=True) # --- State machine data # Current chat id with which the user is participating chat_id = pw.CharField(unique=True) # Which coach is currently active in the user's chat session? active_coach = pw.CharField(default="Setup") # In which state is this module? state = pw.IntegerField(default=0) # What is the time at which the user usually wakes up? wake_time = pw.TimeField(default=lambda: datetime.time(hour=9)) class Meta: """Metadata for user model.""" database = db @staticmethod def tg_get_or_create(tguser): """Get or create based on a Telegram user object.""" return User.get_or_create(telegram_id=tguser.id, chat_id=tguser.id) def create_record(self, kind, content, reaction=None): """Return a new record in this user's diary.""" with db.transaction(): rv = Record(kind=kind, user=self, reaction=reaction, content=content) return rv
class Detainee_Charges(peewee.Model): detainee_id = peewee.IntegerField() name = peewee.CharField() case_num = peewee.CharField() charge_description = peewee.CharField() charge_status = peewee.CharField() bail_amount = peewee.CharField() bond_type = peewee.CharField() court_date = peewee.DateField() court_time = peewee.TimeField() court_of_jurisdiction = peewee.CharField() class Meta: database = db
class Customer_booking(BaseModel): shop_service = pw.ForeignKeyField(Shop_service, backref="bookings") customer = pw.ForeignKeyField(Customer, backref="bookings") staff = pw.ForeignKeyField(Staff,backref="bookings") # Assuming all services provided are completed within the same day date = pw.DateField(null=False) time_start = pw.TimeField(null=False) time_end = pw.TimeField(null=False) # acceptance status by manager/staff is_accepted = pw.BooleanField(default=False) def validate(self): pass # date check - next day onwards, during shop's operating days # time check - during shop's operating hours # --------------------------------------------------------------------- # Leaving this aside for now. May be able to implement this simply by # disabling options based on shop operating hours # --------------------------------------------------------------------- def datetimecheck(self): # This function checks the following: # 1. selected booking time is at least 2 hours from now # 2. selected booking time is within the shop's business days and hours now = datetime.datetime.now() two_hours_later = datetime.datetime.now() + timedelta(hours=2) weekday = date.weekday() if date<now: self.errors.append("Selected date must be today or later.") if time_start < two_hours_later: self.errors.append("Selected start time must be at least 2 hours from now.")
class Users(peewee.Model): id = peewee.IntegerField() telephone = peewee.CharField() hobbies = peewee.CharField() first_name = peewee.CharField() last_name = peewee.CharField() reputation = peewee.IntegerField() latitude = peewee.FloatField() longitude = peewee.FloatField() weather = peewee.IntegerField() weather_time = peewee.TimeField() fun = peewee.CharField() class Meta: database = database
class Checkin(BaseModel): """ ORM model of the Checkin table """ id = pw.CharField(unique=True, primary_key=True) shout = pw.TextField() date = pw.DateField() time = pw.TimeField() weekday = pw.IntegerField() user = pw.ForeignKeyField(User, related_name='checkins', on_delete='SET NULL', on_update='CASCADE') venue = pw.ForeignKeyField(Venue, related_name='checkins', on_delete='CASCADE', on_update='CASCADE')
class Episode(pw.Model): id = pw.AutoField(primary_key=True) title = pw.TextField() # 描述,即文件名 hash = pw.CharField(index=True) # 种子散列值 size = pw.IntegerField() # 文件大小:字节数 pub_time = pw.TimeField() # 发布时间 torrent_url = pw.CharField() # 种子下载地址,种子由mikan提供。此项也可以用磁力链 # aria2 任务号,注意:在磁力任务、种子任务中,任务号会变化 aria2_gid = pw.CharField(max_length=16, index=True, null=True) # 0:未开始,1:忽略,2:正在下载,3:下载失败,4:下载完毕 download_status = pw.IntegerField(index=True) class Meta: database = pw.SqliteDatabase( os.path.join(os.path.dirname(__file__), "mikanpro.sqlite"))
class Detainee(peewee.Model): case_numb = peewee.CharField(primary_key=True) charge_description = peewee.CharField() charge_status = peewee.CharField() bail_amount = peewee.CharField() bond_type = peewee.CharField() court_date = peewee.DateField() court_time = peewee.TimeField() juristriction_court = peewee.CharField() height = peewee.FloatField() weight = peewee.FloatField() sex = peewee.CharField() eyes = peewee.CharField() hair = peewee.CharField() race = peewee.CharField() age = city = CharField() state = CharField() class = db
class AQI(peewee.Model): ''' city_code, aqi, main, pm10, pm25, no2, so2, co, o3 ''' city_code = peewee.CharField() site_name = peewee.CharField() aqi = peewee.CharField() main = peewee.CharField() pm10 = peewee.CharField() pm25 = peewee.CharField() no2 = peewee.CharField() so2 = peewee.CharField() co = peewee.CharField() o3 = peewee.CharField() date = peewee.DateField() crawling_times = peewee.IntegerField() time = peewee.TimeField() class Meta: database = database