Example #1
0
class Registro01(peewee.Model):
    data_pregao = peewee.DateField()
    codigo_bdi = peewee.CharField(max_length=2)
    codigo_negociacao = peewee.CharField(max_length=12)
    tipo_mercado = peewee.IntegerField()
    nome_resumido = peewee.CharField(max_length=12)
    especificaco = peewee.CharField(max_length=10)
    prazo_termo = peewee.CharField(max_length=3)
    moeda = peewee.CharField(max_length=4)
    preco_abertura = peewee.DecimalField(max_digits=11, decimal_places=2)
    preco_maximo = peewee.DecimalField(max_digits=11, decimal_places=2)
    preco_minimo = peewee.DecimalField(max_digits=11, decimal_places=2)
    preco_medio = peewee.DecimalField(max_digits=11, decimal_places=2)
    preco_ultimo = peewee.DecimalField(max_digits=11, decimal_places=2)
    preco_ofc = peewee.DecimalField(max_digits=11, decimal_places=2)
    preco_ofv = peewee.DecimalField(max_digits=11, decimal_places=2)
    total_negocios = peewee.IntegerField()
    quantidade_titulos = peewee.IntegerField()
    volume_titulos = peewee.DecimalField(max_digits=16, decimal_places=2)
    preexe = peewee.DecimalField(max_digits=11, decimal_places=2)
    indicador_cp = peewee.IntegerField()
    data_vencimento = peewee.DateField()
    fator_cotacao = peewee.IntegerField()
    ptoexe = peewee.DecimalField(max_digits=11, decimal_places=2)
    codigo_isin = peewee.CharField(max_length=12)
    dismes = peewee.IntegerField()

    class Meta:
        database = data_base
Example #2
0
class Record(BaseModel):
    appointment = pw.ForeignKeyField(Appointment,
                                     unique=True,
                                     backref="appointment")
    report = pw.TextField(null=True)
    prescription = pw.TextField(null=True)
    payment_amount = pw.DecimalField(default=0, decimal_places=2)
    paid = pw.BooleanField(default=False)
    cholestrol_level = pw.DecimalField(null=True)
    sugar_level = pw.DecimalField(null=True)
    systolic_blood_pressure = pw.IntegerField(null=True)
    diastolic_blood_pressure = pw.IntegerField(null=True)

    def validate(self):
        #validate payment amount
        if (self.payment_amount) or (
                self.payment_amount == 0
        ):  #check if amount is inputted, and also allow 0 to be saved (0 is falsy)
            if self.payment_amount == 0:  #if there is no payment_amount, change paid state to True
                self.paid = True
            self.payment_amount = round(
                self.payment_amount,
                2)  #round to 2 decimal places before saving
        else:
            self.errors.append('No payment is inputted.')

    @hybrid_property
    def photo(self):
        from models.patient_photo import Patient_Photo
        photo_list = []
        photo = Patient_Photo.select().where(Patient_Photo.record == self)
        for p in photo:
            photo_list.append(p.full_image_url)
        return photo_list
Example #3
0
    class RevisionAnswer(pw.Model):
        id = pw.AutoField()
        datetime = pw.DateTimeField()
        expected_ease = pw.IntegerField()
        chosen_ease = pw.IntegerField()
        card_due = pw.DateField()
        card_new_ivl = pw.DecimalField(auto_round=False,
                                       decimal_places=5,
                                       max_digits=10,
                                       rounding=ROUND_HALF_EVEN)
        card_old_ivl = pw.DecimalField(auto_round=False,
                                       decimal_places=5,
                                       max_digits=10,
                                       rounding=ROUND_HALF_EVEN)
        card_new_factor = pw.DecimalField(auto_round=False,
                                          decimal_places=5,
                                          max_digits=10,
                                          rounding=ROUND_HALF_EVEN)
        card_old_factor = pw.DecimalField(auto_round=False,
                                          decimal_places=5,
                                          max_digits=10,
                                          rounding=ROUND_HALF_EVEN)
        time_taken = pw.IntegerField()
        early = pw.BooleanField()
        rollover_hour = pw.IntegerField()

        class Meta:
            table_name = "revisionanswer"
Example #4
0
class Anime(baseModel):
    nome = peewee.CharField()
    genero = peewee.CharField()
    numeroEpisodio = peewee.DecimalField(max_digits=5, decimal_places=0)
    imagem = peewee.CharField()
    link = peewee.CharField()
    status = peewee.DecimalField(max_digits=1, decimal_places=0)
Example #5
0
def migrate(migrator, database, fake=False, **kwargs):
    """Write your migrations here."""

    migrator.add_fields(
        'booking',
        catereringTotal=pw.DecimalField(auto_round=False,
                                        decimal_places=5,
                                        max_digits=10,
                                        null=True,
                                        rounding='ROUND_HALF_EVEN'),
        discountTotal=pw.DecimalField(auto_round=False,
                                      decimal_places=5,
                                      max_digits=10,
                                      null=True,
                                      rounding='ROUND_HALF_EVEN'),
        roomTotal=pw.DecimalField(auto_round=False,
                                  decimal_places=5,
                                  max_digits=10,
                                  null=True,
                                  rounding='ROUND_HALF_EVEN'),
        subtotal=pw.DecimalField(auto_round=False,
                                 decimal_places=5,
                                 max_digits=10,
                                 null=True,
                                 rounding='ROUND_HALF_EVEN'),
        canceledRooms=pw.CharField(max_length=255, null=True))
Example #6
0
 class Booking(pw.Model):
     canceler = pw.IntegerField(index=True, null=True)
     contact = pw.ForeignKeyField(db_column='contact_id',
                                  rel_model=Contact,
                                  to_field='id')
     creator = pw.ForeignKeyField(db_column='creator_id',
                                  rel_model=User,
                                  to_field='id')
     discountAmount = pw.DecimalField(auto_round=False,
                                      decimal_places=5,
                                      max_digits=10,
                                      rounding='ROUND_HALF_EVEN')
     discountPercent = pw.DecimalField(auto_round=False,
                                       decimal_places=5,
                                       max_digits=10,
                                       rounding='ROUND_HALF_EVEN')
     endTime = pw.DateTimeField()
     eventName = pw.CharField(max_length=255)
     finalPrice = pw.DecimalField(auto_round=False,
                                  decimal_places=5,
                                  max_digits=10,
                                  null=True,
                                  rounding='ROUND_HALF_EVEN')
     isCanceled = pw.BooleanField()
     startTime = pw.DateTimeField()
Example #7
0
class Ticker(BaseModel):
    coin = peewee.ForeignKeyField(Coin, backref='tickers')
    price = peewee.DecimalField(max_digits=20, decimal_places=8)
    captured_at = peewee.DateTimeField(default=datetime.datetime.utcnow)
    # don't want to take up precious db space?, just making a float
    price_change_day_pct = peewee.DecimalField(max_digits=20,
                                               decimal_places=8,
                                               null=True)
Example #8
0
class MoneySendLimit(BaseModel):
    user_id = peewee.BigIntegerField(default=0)
    pay_amount = peewee.IntegerField(default=0)
    gived_money = peewee.DecimalField(max_digits=65,
                                      decimal_places=2,
                                      default=Decimal("0"))
    pay = peewee.DecimalField(max_digits=65,
                              decimal_places=2,
                              default=Decimal("0"))
Example #9
0
class ItineraryPin(BaseModel):
    user = pw.ForeignKeyField(User, backref="itinerary")
    longitude = pw.DecimalField(max_digits=9, decimal_places=6)
    latitude = pw.DecimalField(max_digits=9, decimal_places=6)
    name = pw.CharField(max_length=255)
    description = pw.CharField(max_length=1000, null=True)
    address = pw.CharField(null=True)
    start_time = pw.DateTimeField()
    resolved = pw.BooleanField(
        default=False)  # False if user has not confirmed safety status
Example #10
0
class Location(BaseModel):
    latitude = peewee.DecimalField(null=False)
    longitude = peewee.DecimalField(null=False)
    created_on = peewee.DateTimeField(
        null=True, default=lambda: datetime.datetime.utcnow())
    name = peewee.TextField(null=False)

    @property
    def google_maps_url(self):
        return f"https://www.google.com/maps/place/{self.latitude}+{self.longitude}/@{self.latitude},{self.longitude},20z"
Example #11
0
class Resources(BaseModel):
    """
    ORM model for Resources table
    """
    name = peewee.CharField(primary_key=True)
    type = peewee.CharField(null=False)
    availability_start = peewee.DateTimeField()
    availability_end = peewee.DateTimeField()
    amount = peewee.DecimalField()
    rate = peewee.DecimalField()
Example #12
0
class SafeLocation(BaseModel):
    category = pw.CharField()
    name = pw.CharField()
    description = pw.CharField(max_length=3000)
    longitude = pw.DecimalField(max_digits=9, decimal_places=6)
    latitude = pw.DecimalField(max_digits=9, decimal_places=6)
    address = pw.CharField(null=True)
    phone_num = pw.CharField(null=True)
    opening_time = pw.DateTimeField(null=True)
    closing_time = pw.DateTimeField(null=True)
class Issue(DictionaryIndexMixin, BaseModel):
    name = peewee.CharField()
    key = peewee.CharField()

    lower = peewee.DecimalField()
    upper = peewee.DecimalField()

    data_set = peewee.ForeignKeyField(DataSet, on_delete="CASCADE")

    hash_field = "key"
Example #14
0
class RateHistory(BaseModel):
    bitmex = peewee.DecimalField(default=0)
    coinbase = peewee.DecimalField(default=0)
    kraken = peewee.DecimalField(default=0)

    class Meta:
        db_table = 'bot_rate_history'

    def __str__(self):
        return "%s | %s | %s" % (self.bitmex, self.coinbase, self.kraken)
Example #15
0
class Transaction(BaseModel):
    uuid = peewee.UUIDField(primary_key=True, unique=True)
    equity = peewee.ForeignKeyField(Equities,
                                    backref='transaction',
                                    index=True)
    time = peewee.DateTimeField(index=True)
    price = peewee.DecimalField(max_digits=14, decimal_places=3)  # 成交价
    price_change = peewee.DecimalField(max_digits=14, decimal_places=3)  # 价格变动
    volume = peewee.IntegerField()  # 成交量(手)
    turnover = peewee.DecimalField(max_digits=14, decimal_places=3)  # 成交额(元)
    kind = peewee.CharField(max_length=16)  # 性质(买盘、买盘、中性盘)
Example #16
0
class MarketOrder(BaseModel):
    order_id = peewee.CharField(max_length=64)
    market = peewee.CharField(max_length=32)
    time_placed = peewee.DateTimeField()
    order_type = peewee.CharField(max_length=4)
    price = peewee.DecimalField(max_digits=12, decimal_places=8)
    amount = peewee.DecimalField(max_digits=18, decimal_places=8)
    has_executed = peewee.BooleanField(default=False)

    class Meta:
        order_by = ('-time_placed',)
Example #17
0
class Candle(MySQLModel):
    firstTrade = None
    lastTrade = None
    close = pw.DecimalField(null=True)
    high = pw.DecimalField(null=True)
    low = pw.DecimalField(null=True)
    open = pw.DecimalField(null=True)
    trades = pw.IntegerField(null=True)
    volume = pw.DecimalField(null=True, max_digits=20, decimal_places=8)
    idfrom = pw.IntegerField(null=True)
    idto = pw.IntegerField(null=True)
    candle_date_time = pw.CharField(null=True)
Example #18
0
class MapPin(BaseModel):
    user = pw.ForeignKeyField(User, backref="pins")
    name = pw.CharField(max_length=255)
    description = pw.CharField(max_length=1000, null=True)
    longitude = pw.DecimalField(max_digits=9, decimal_places=6)
    latitude = pw.DecimalField(max_digits=9, decimal_places=6)
    is_safe = pw.BooleanField()
    category = pw.CharField()
    source = pw.CharField(default="User")
    radius = pw.IntegerField()
    address = pw.CharField(null=True)
    is_public = pw.BooleanField(default=True)
Example #19
0
class SentinelScene(BaseModel):
    """
    Model for parsed scenes
    """
    farm_id = peewee.IntegerField()
    scene = peewee.TextField()
    date = peewee.DateField()
    ndvi = peewee.DecimalField(max_digits=4, decimal_places=3)
    nmdi = peewee.DecimalField(max_digits=4, decimal_places=3)

    class Meta:
        db_table = 'sentinel_scenes'
Example #20
0
class Sale(BaseModel):
    user = pw.ForeignKeyField(User, backref="sales")
    client = pw.ForeignKeyField(Client, backref="sales")
    quantity = pw.IntegerField(default=1)
    value = pw.DecimalField(max_digits=10, decimal_places=2)
    discounts = pw.DecimalField(max_digits=10, decimal_places=2, default=0)
    submit_date = TimezoneField(default=datetime.now)
    obs = pw.TextField(null=True)

    @property
    def total(self):
        return (float(self.quantity) * float(self.value)) - float(
            self.discounts)
Example #21
0
class clans(BaseModel):
    header_id = peewee.BigIntegerField(default=0)
    register_date = peewee.TextField(default=datetime.date.today())
    name = peewee.TextField(default="")
    shortname = peewee.TextField(default="")
    treasury = peewee.DecimalField(max_digits=65,
                                   decimal_places=2,
                                   default=Decimal("0"))
    clan_type = peewee.IntegerField(default=0)
    raiting = peewee.DecimalField(max_digits=65,
                                  decimal_places=2,
                                  default=Decimal("0"))
    tag = peewee.TextField(default="")
Example #22
0
class Position(MySQLModelTrader):
    orderType = pw.CharField(null=True)
    cty = pw.DecimalField(null=True)
    price = pw.DecimalField(null=True)
    timestamp = pw.DateTimeField(null=True)

    def __str__(self):
        return (str(self.timestamp) + ',' +
                str(self.getType()) + ',' +
                str(self.getCty()) + ',' +
                str(self.getPrice()))

    def create(self, orderType, cty, price, timestamp = str(datetime.now()).split('.')[0]):
        self.orderType = orderType
        self.cty = cty
        self.price = price
        self.timestamp = timestamp
        return self

    def getType(self):
        return self.orderType

    def getTypeOpposite(self):
        if self.getType() == OrderType.BUY:
            return OrderType.SELL
        elif self.getType() == OrderType.SELL:
            return OrderType.BUY

    def getCty(self):
        return self.cty

    def getPrice(self):
        return self.price

    def getTimeStamp(self):
        return self.timestamp

    def setType(self, orderType):
        self.orderType = orderType

    def setCty(self, cty):
        self.cty = cty

    def setPrice(self, price):
        self.price = price

    def setTimeStamp(self, timestamp):
        self.timestamp = timestamp
Example #23
0
class Media(BaseModel):
    # base table containing all media entries
    title = peewee.CharField(unique=True)
    alt_title = peewee.CharField(null=True)
    series = peewee.ForeignKeyField(Series, backref='sequels', null=True)
    order = peewee.DecimalField(
        max_digits=2, null=True
    )  # the story's chronological order ex: Star Wars Ep. 1, 2, 3, 4, 5, 6 | NOT 4, 5, 6, 1, 2, 3
    media_type = peewee.ForeignKeyField(
        MediaTypes, backref='media')  # movie | tv show | etc
    animated = peewee.BooleanField()
    country = peewee.ForeignKeyField(Countries,
                                     backref='media')  # USA | UK | Japan | etc
    language = peewee.ManyToManyField(Languages, backref='media')
    subtitles = peewee.BooleanField(null=True)
    year = peewee.IntegerField(constraints=[peewee.Check('year > 1900')],
                               null=True)  # release year
    genres = peewee.ManyToManyField(Genres, backref='media')
    director = peewee.ForeignKeyField(Directors, backref='media', null=True)
    studio = peewee.ForeignKeyField(Studios, backref='media', null=True)
    actors = peewee.ManyToManyField(
        Actors, backref='media')  # ManyToManyField does not support null=True
    plot = peewee.CharField(null=True)
    rating = peewee.IntegerField(constraints=[
        peewee.Check('rating >= 1 AND rating <=10')
    ],
                                 null=True)  # 1 to 10
    tags = peewee.ManyToManyField(
        Tags, backref='media')  # ManyToManyField does not support null=True
    notes = peewee.CharField(null=True)
Example #24
0
class Project(BaseModel):
    name = pw.CharField()
    project_type = pw.CharField()
    client_id = pw.ForeignKeyField(Client, backref='projects')
    date = pw.DateField()
    currency = pw.CharField()
    total = pw.DecimalField(decimal_places=2)
class Donate(BaseModel):
    # what is backref, and on_delete?
    # d in image.donations - backref
    # d.user.id = d.amount
    image = pw.ForeignKeyField(Image, backref="donations", on_delete="CASCADE")
    user = pw.ForeignKeyField(User, backref="donations", on_delete="CASCADE")
    amount = pw.DecimalField(null=False)
Example #26
0
class Donations(BaseModel):
    amount = pw.DecimalField()
    image = pw.ForeignKeyField(Image, backref='donations')
    user = pw.ForeignKeyField(User, backref='donations')

    def validate(self):
        return
Example #27
0
class Job(BaseModel):
    """
    This class defines Job, which maintains details of past Jobs
    held by a Person.
    """
    logger.info("Defining table: Job.")
    logger.info("Adding job_name field to Job table.")
    job_name = pw.ForeignKeyField(DeptJobs)
    logger.info("Adding dept_name field to Job table.")
    dept_name = pw.ForeignKeyField(Department)
    logger.info("Adding start_date field to Job table.")
    start_date = pw.DateField(formats='YYYY-MM-DD', null=False)
    logger.info("Adding end_date field to Job table; default is current date.")
    end_date = pw.DateField(formats='YYYY-MM-DD', default=dt.date.today())
    logger.info("Add salary field to Job table.")
    salary = pw.DecimalField(max_digits=7, decimal_places=2)
    logger.info("Add person_employed field to Job table; the field is "
                "a foreign key from the Person table.")
    person_employed = pw.ForeignKeyField(Person,
                                         related_name='was_filled_by',
                                         null=False)

    class Meta:
        """This class defines a composite key as the primary key."""
        logger.info(
            "Set primary key to combo of person_employed & start_date fields.\n"
        )
        primary_key = pw.CompositeKey('person_employed', 'start_date')
Example #28
0
class Ingredient(BaseModel):
    name = pw.CharField(unique=True, null=False)
    description = pw.CharField(null=True)
    ingredient_type = pw.CharField(null=False)
    image = pw.TextField(null=False)
    price = pw.DecimalField(null=False, decimal_places=2)
    stock = pw.IntegerField(null=False)

    def validate(self):
        duplicate_name = Ingredient.get_or_none(name=self.name)

        if duplicate_name:
            self.errors.append("Ingredient name exist!")
        
        if len(self.name.strip())==0:
            self.erros.append("Ingredient name cannot be blank!")

        if len(self.description.strip())==0:
            self.errors.append("Description cannot be blank!")
        
        if len(self.price.strip())==0:
            self.erros.append("Price cannot be blank!")
        
        if len(self.ingredient_type.strip())==0:
            self.errors.append("Ingredient type canot be blank!")

        if len(self.stock.strip())==0:
            self.errors.append("Stock cannot be blank!")
Example #29
0
class Client(BaseModel):
    user_id = peewee.IntegerField(unique=True)
    first_name = peewee.CharField(null=True)
    username = peewee.CharField(null=True)
    balance = peewee.DecimalField(12, 2, default=0.00)
    language_code = peewee.CharField(null=True)
    photo = peewee.CharField(null=True)
Example #30
0
class Transactions(BaseModel):
    client = peewee.ForeignKeyField(Client, null=False, backref='transactions')
    amount = peewee.DecimalField(12, 2, null=False)
    currency = peewee.CharField(null=False)
    opened = peewee.DateTimeField()
    closed = peewee.DateTimeField()
    result = BinaryJSONField()