Exemple #1
0
class Guild(Document):
    class Meta:
        strict = False

    id = fields.IntegerField(attribute="_id")
    channel = fields.IntegerField(default=None)
    channels = fields.ListField(fields.IntegerField, default=list)
    prefix = fields.StringField(default=None)
    silence = fields.BooleanField(default=False)
    display_images = fields.BooleanField(default=True)
    auction_channel = fields.IntegerField(default=None)

    lat = fields.FloatField(default=37.7790262)
    lng = fields.FloatField(default=-122.4199061)
    loc = fields.StringField(
        default=
        "San Francisco, San Francisco City and County, California, United States of America"
    )

    @property
    def is_day(self):
        sun = Sun(self.lat, self.lng)
        sunrise, sunset = sun.get_sunrise_time(), sun.get_sunset_time()
        if sunset < sunrise:
            sunset += timedelta(days=1)

        now = datetime.now(timezone.utc)
        return (sunrise < now < sunset
                or sunrise < now + timedelta(days=1) < sunset
                or sunrise < now + timedelta(days=-1) < sunset)
class Complex(Document):
    title = fields.StringField(required=True, allow_none=False)
    location = fields.StringField(required=True, allow_none=False)
    geographic_location = fields.EmbeddedField(GeographicLocation,
                                               required=True,
                                               allow_none=False)
    events = fields.ListField(fields.EmbeddedField(Event), default=[])
Exemple #3
0
class Item(Document):
    name = fields.StringField(required=True)
    description = fields.StringField()
    parameters = fields.DictField()

    class Meta:
        collection_name = "items"
class Predicted(Document):
    predicted = fields.StringField(required=True)  # dataset name
    department = fields.StringField(required=True)  # assign the dataset to department
    team = fields.StringField(required=True)  # assign the dateset to team
    createDate = fields.DateTimeField(validate=validate.Range(min=pd.Timestamp(1990, 1, 1)), required=True)
    updateDate = fields.DateTimeField(validate=validate.Range(min=pd.Timestamp(1990, 1, 1)), required=True)
    class Meta():
        collection = db.predicted
Exemple #5
0
class Task(Document):

    task_type = fields.ReferenceField(TaskType)
    description = fields.StringField()
    options = fields.ListField(fields.StringField)
    answers = fields.ListField(fields.StringField)
    explanation = fields.StringField()
    text = fields.ReferenceField(Text, allow_none=True)
Exemple #6
0
class Feed(Document):
    type = fields.StringField(required=True)
    uri = fields.StringField()
    name = fields.StringField(required=True)
    last_ts = fields.NumberField(required=True, default=0)

    class Meta:
        collection_name = "feed"
Exemple #7
0
class TaskType(Document):

    number = fields.StringField(required=True, unique=True)
    points = fields.IntegerField(required=True, default=1)
    cods = fields.ListField(fields.StringField)
    description = fields.StringField()
    count_of_tasks = fields.IntegerField(default=0)
    subject = fields.ReferenceField(Subject)
Exemple #8
0
class ProductDocument(Document):
    category = fields.ObjectIdField(required=True)
    name = fields.StringField(required=True)
    description = fields.StringField(required=True)
    price = fields.FloatField(required=True)
    image_url = fields.StringField()
    available_from = fields.StringField(required=True)
    available_till = fields.StringField(required=True)
Exemple #9
0
class Product(Document):
    category = fields.ReferenceField(Category)
    name = fields.StringField(required=True, unique=True)
    description = fields.StringField(required=True, unique=True)
    price = fields.NumberField(required=True)
    image_url = fields.UrlField()
    available_from = fields.DateTimeField()
    available_till = fields.DateTimeField()
Exemple #10
0
        class User(Document):
            name = fields.StringField(required=True, unique=True)
            password = fields.StringField(required=True)
            age = fields.IntegerField(required=True)
            email = fields.EmailField(required=False)

            class Meta:
                collection = db.user
Exemple #11
0
class Card(Document):

    year = fields.IntegerField(required=True)
    img = fields.UrlField()
    name = fields.StringField(required=True, unique=True)
    desc = fields.StringField(required=True)

    class Meta:
        collection = db.tawep.card
Exemple #12
0
class User(Document):

    name = fields.StringField(required=True, unique=True)
    admin = fields.BooleanField(required=True)
    password_hash = fields.StringField(required=True)
    salt = fields.StringField(required=True)

    class Meta:
        collection = db.tawep.user
Exemple #13
0
class Member(Document):
    class Meta:
        strict = False

    id = fields.IntegerField(attribute="_id")
    pokemon = fields.ListField(fields.EmbeddedField(Pokemon), required=True)

    selected = fields.IntegerField(required=True)

    order_by = fields.StringField(default="number")
    pokedex = fields.DictField(fields.StringField(),
                               fields.IntegerField(),
                               default=dict)
    shinies_caught = fields.IntegerField(default=0)
    balance = fields.IntegerField(default=0)
    redeems = fields.IntegerField(default=0)

    shiny_hunt = fields.IntegerField(default=None)
    shiny_streak = fields.IntegerField(default=0)

    boost_expires = fields.DateTimeField(default=datetime.min)

    last_voted = fields.DateTimeField(default=datetime.min)
    vote_total = fields.IntegerField(default=0)
    vote_streak = fields.IntegerField(default=0)
    gifts_normal = fields.IntegerField(default=0)
    gifts_great = fields.IntegerField(default=0)
    gifts_ultra = fields.IntegerField(default=0)
    gifts_master = fields.IntegerField(default=0)

    silence = fields.BooleanField(default=False)
    joined_at = fields.DateTimeField(default=None)
    invites = fields.IntegerField(default=0)

    suspended = fields.BooleanField(default=False)

    @property
    def selected_pokemon(self):
        try:
            return next(
                filter(lambda x: x.number == int(self.selected), self.pokemon))
        except StopIteration:
            return None

    @property
    def boost_active(self):
        return datetime.utcnow() < self.boost_expires

    @property
    def shiny_hunt_chance(self):
        return (1 + 2 * math.tanh(self.shiny_streak / 100)) / 4096

    def determine_shiny(self, species):
        if self.shiny_hunt != species.dex_number:
            return random.randint(1, 4096) == 1
        else:
            return random.random() < self.shiny_hunt_chance
Exemple #14
0
class OrderDocument(Document):
    products = fields.ListField(fields.ReferenceField(ProductDocument),
                                required=True)
    cafe = fields.ObjectIdField(required=True)
    user_id = fields.StringField(required=True, unique=True)
    order_time = fields.DateTimeField(required=True)
    status = fields.StringField(required=True)
    code = fields.IntegerField(required=True)
    price = fields.FloatField(required=True)
    deletion_time = fields.DateTimeField(allow_none=True)
Exemple #15
0
class User(Document):

    user_id = fields.IntegerField(required=True, unique=True)
    money = fields.IntegerField(default=0)
    first_name = fields.StringField(allow_none=True)
    last_name = fields.StringField(allow_none=True)
    username = fields.StringField(allow_none=True)
    referrer_id = fields.IntegerField()
    current_task_id = fields.IntegerField(default=-1)
    current_bet = fields.IntegerField(default=0)
Exemple #16
0
class Cafe(Document):
    # id_cafe = fields.IntegerField()
    name_cafe = fields.StringField(required=True, unique=True)
    address = fields.StringField(required=True, unique=True)
    info = fields.StringField()
    image_url_cafe = fields.UrlField()
    payment_type = fields.ReferenceField(PaymentTypes)

    class Meta:
        collection = db.cafe
Exemple #17
0
 class MySchema(Schema):
     dict = fields.DictField(attribute='in_mongo_dict', allow_none=True)
     kdict = fields.DictField(keys=fields.StringField(
         validate=validate.Length(0, 1)))
     vdict = fields.DictField(values=fields.IntField(
         validate=validate.Range(max=5)))
     kvdict = fields.DictField(
         keys=fields.StringField(validate=validate.Length(0, 1)),
         values=fields.IntField(validate=validate.Range(max=5)))
     dtdict = fields.DictField(values=fields.DateTimeField)
Exemple #18
0
class Account(Document):
    #
    username = fields.StringField(required=True)
    password = fields.StringField(required=True)
    createDate = fields.DateTimeField(
        validate=validate.Range(min=datetime(1990, 1, 1)), required=True)
    updateDate = fields.DateTimeField(
        validate=validate.Range(min=datetime(1990, 1, 1)), required=True)

    class Meta():
        collection = db.account
Exemple #19
0
class Car(Document):
    model = fields.StringField()
    manufacturer = fields.StringField()
    release_year = fields.IntegerField()
    colour = fields.StringField()
    vin_code = fields.StringField(unique=True)
    created_time = fields.DateTimeField(default=datetime.utcnow)
    updated_time = fields.DateTimeField()

    class Meta:
        indexes = ["-created_time"]
class Event(EmbeddedDocument):
    title = fields.StringField(required=True, allow_none=False)
    description = fields.StringField(allow_none=True, default="")
    event_type = fields.StringField(required=True, allow_none=False)
    event_start = fields.StringField(required=True, allow_none=False)
    event_end = fields.StringField(required=True, allow_none=False)
    event_length = fields.FloatField(required=True, allow_none=False)
    probability = fields.FloatField(required=True, allow_none=False)
    markers = fields.ListField(fields.EmbeddedField(Marker),
                               allow_none=True,
                               default=[])
Exemple #21
0
class User(Document):

    name = fields.StringField(required=True)
    email = fields.EmailField(required=True, unique=True)
    password = fields.StringField()
    confirm_code = fields.StringField()
    reset_code = fields.StringField(default="")
    is_admin = fields.BooleanField(default=False)
    is_math_basic = fields.BooleanField(default=True)

    class Meta:
        collection = db.user
Exemple #22
0
class Movie(Document):
    name = fields.StringField(required=True)
    director = fields.StringField(required=True)
    categories = fields.ListField(fields.StringField())
    imdb_score = fields.FloatField()
    popularity_99 = fields.FloatField()

    def __str__(self):
        return f"{self.name} : {self.director}"

    def __repr__(self):
        return f"<{self.name} : {self.director}>"
Exemple #23
0
class Product(Document):
    # id_prod = fields.IntegerField()
    id_cat = fields.ReferenceField(Category)
    name_prod = fields.StringField(required=True, unique=True)
    description = fields.StringField(required=True, unique=True)
    price = fields.NumberField(required=True)
    image_url_prod = fields.UrlField()
    avail_from = fields.DateTimeField()
    avail_till = fields.DateTimeField()

    class Meta:
        collection = db.product
Exemple #24
0
class Blog(Document, metaclass=MetaBaseTemplate):
    __collection__ = 'blog'

    title = fields.StringField(validate=validate.Length(max=128),
                               required=True)
    text = fields.StringField(validate=validate.Length(min=128), required=True)
    user = fields.UUIDField(required=True)
    created = fields.DateTimeField(missing=datetime.datetime.now)
    comments = fields.ListField(fields.EmbeddedField(Comment), missing=list)
    areal = fields.EmbeddedField(Areal, missing=dict)

    class Meta:
        pass
Exemple #25
0
class User(Document):
    #
    name = fields.StringField(required=True)
    department = fields.StringField(required=True)
    team = fields.StringField(required=True)
    createDate = fields.DateTimeField(
        validate=validate.Range(min=pd.Timestamp(1990, 1, 1)), required=True)
    updateDate = fields.DateTimeField(
        validate=validate.Range(min=pd.Timestamp(1990, 1, 1)), required=True)
    accountRef = fields.StringField(required=True)

    class Meta():
        collection = db.user
Exemple #26
0
class CafeEmployee(Document):
    username = fields.StringField(required=True,
                                  unique=True,
                                  validate=[Length(min=6, max=60)])
    password = fields.StringField(required=True)
    cafe = fields.ReferenceField(Cafe)  # fields.ObjectIdField
    # group = fields.IntegerField()
    token = fields.StringField(required=True)

    def hash_password(self):
        self.password = sha256(
            self.password.encode('UTF-8') +
            self.username.encode('UTF-8')).hexdigest()
Exemple #27
0
class Article(Document):
    ts = fields.NumberField(required=True, default=0)
    text = fields.StringField()
    tags = fields.ListField(fields.StringField(), default=[])
    source = fields.ReferenceField("Feed")
    address = fields.StringField(default="")
    # Location: {
    #       type: "Point",
    #       coordinates: [-73.856077, 40.848447]
    # }
    location = fields.DictField(default={})

    class Meta:
        collection_name = "article"
Exemple #28
0
class ImageDocument(Document, metaclass=MetaBaseTemplate):
    public_id = fields.StringField(required=True)
    filename = fields.StringField()
    tags = fields.ListField(fields.StringField, missing=list)
    url = fields.UrlField(required=True)
    signature = fields.StringField()
    etag = fields.StringField()

    user = fields.UUIDField(required=True)
    liked = fields.IntegerField(missing=0)
    created_at = fields.DateTimeField(missing=datetime.utcnow)

    class Meta:
        collection_name = "images"
Exemple #29
0
class City(Document, metaclass=MetaBaseTemplate):
    __collection__ = 'cities'

    geonameid = fields.IntegerField(required=True)
    code_name = fields.StringField(required=True)
    iso_name = fields.StringField()
    count_journeys = fields.IntegerField(required=True, missing=0)
    count_articles = fields.IntegerField(required=True, missing=0)
    points = fields.ListField(fields.EmbeddedField(Point), required=True)

    class Meta:
        indexes = [
            IndexModel([('geonameid', ASCENDING), ('code_name', ASCENDING)],
                       unique=True)
        ]
Exemple #30
0
class Item(Document):
    name = fields.StringField(required=True)
    created_time = fields.DateTimeField(default=datetime.utcnow)
    updated_time = fields.DateTimeField()

    class Meta:
        indexes = ['-created_time']