コード例 #1
0
class reports(mongoengine.Document):
    _id = mongoengine.StringField(primary_key=True)
    time = mongoengine.StringField()
    status = mongoengine.StringField()
    source_pat_sents = mongoengine.StringField()
    compare_pats = mongoengine.ListField()
    report_html = mongoengine.FileField()
    report_pdf = mongoengine.FileField()
コード例 #2
0
ファイル: carrotmongo.py プロジェクト: andreiliphd/carrot
class Carrot(mo.Document):
    date_time = mo.DateTimeField(required=True)
    epoch = mo.IntField()
    train_loss = mo.FloatField()
    test_loss = mo.FloatField()
    train_accuracy = mo.FloatField()
    test_accuracy = mo.FloatField()
    parameters = mo.FileField()
    gradients = mo.FileField()
コード例 #3
0
class Product(me.Document):
    title = me.StringField(min_length=2, max_length=128, required=True)
    description = me.StringField(max_length=1024)
    price = me.DecimalField(force_string=True, required=True, min_value=0)
    discount = me.IntField(min_value=0, max_value=100, default=0)
    in_stock = me.BooleanField(default=True)
    category = me.ReferenceField(Category)
    supplier = me.ReferenceField('Supplier')
    image = me.FileField()
    parameters = me.EmbeddedDocumentField(Parameters)

    @classmethod
    def get_discount_products(cls):
        return cls.objects(discount__gt=0)

    def get_products_parameters(self):
        if self.parameters:
            return f'Характеристики :\n' \
                   f'ширина - {self.parameters.width} см.\n' \
                   f'высота - {self.parameters.height} см.\n' \
                   f'вес - {self.parameters.weight} кг.\n' \
                   f'мощность - {self.parameters.power} Вт'
        return f'Характеристики : нет данных'

    def get_product_info(self):
        product_info = f'{self.title}\n' \
                       f'Описание :\n' \
                       f'{self.description}\n' \
                       f' {self.get_products_parameters()}'
        if self.discount > 0:
            discount_price = (self.price - (self.price / 100) * self.discount)
            return product_info + f'\nСтарая цена : {self.price}\nЦена со скидкой : {discount_price}'
        return product_info + f'\nЦена : {self.price}'
コード例 #4
0
ファイル: challenges.py プロジェクト: r202-coe-psu/sadhu
class Solution(me.Document):
    code = me.FileField(required=True)
    output = me.StringField()
    messages = me.StringField()
    score = me.FloatField(required=True, default=0)
    passed = me.BooleanField(required=True, default=False)

    type = me.StringField(required=True, default="user", choices=SOLUTION_TYPE)
    status = me.StringField(required=True, default="waiting")
    enrolled_class = me.ReferenceField("Class", dbref=True)
    assignment = me.ReferenceField("Assignment", dbref=True)
    challenge = me.ReferenceField("Challenge", required=True, dbref=True)
    owner = me.ReferenceField("User", required=True, dbref=True)

    submitted_date = me.DateTimeField(required=True,
                                      default=datetime.datetime.now)

    executed_date = me.DateTimeField()
    executed_ended_date = me.DateTimeField()
    language = me.StringField(required=True)
    test_results = me.ListField(me.EmbeddedDocumentField("TestResult"))

    metadata = me.DictField()

    meta = {"collection": "solutions"}

    def count_pass_testcases(self):
        count = 0
        for t in self.test_results:
            if t.validated:
                count += 1

        return count
コード例 #5
0
ファイル: airplane.py プロジェクト: tspycher/pyaeromanager
class PerformanceChart(mongoengine.EmbeddedDocument):
    name = mongoengine.StringField(required=True)
    description = mongoengine.StringField(required=False)
    file = mongoengine.FileField(required=True)

    def __str__(self):
        return "%s" % self.name
コード例 #6
0
ファイル: music.py プロジェクト: tiger8888/wang_fm
class MusicStorage(BaseMongoStorage, mongoengine.Document):
    """store music info
    key             str
    title           str
    artist          str
    album           str
    company         str
    public_time     str
    kbps            str
    cover           file
    audio           file
    upload_date     datetime
    uuid            str
    """
    title = mongoengine.StringField(max_length=256, default='')
    artist = mongoengine.StringField(max_length=256, default='')
    album = mongoengine.StringField(max_length=256, default='')
    company = mongoengine.StringField(max_length=256, default='')
    public_time = mongoengine.StringField(max_length=10, default='')
    kbps = mongoengine.StringField(max_length=5, default='')
    cover = mongoengine.FileField()
    audio = mongoengine.FileField()
    upload_date = mongoengine.DateTimeField()

    uuid = mongoengine.StringField(unique=True)

    meta = {
        'ordering': ['-upload_date']
    }

    def __str__(self):
        return 'title=%s, artist=%s, album=%s' % (self.title, self.artist, self.album)

    def delete(self):
        self.cover.delete()
        self.audio.delete()
        super(MusicStorage, self).delete()

    def update(self, **kwargs):
        cover = kwargs.pop('cover', None)
        audio = kwargs.pop('audio', None)
        if cover:
            self.cover.replace(cover)
        if audio:
            self.audio.replace(audio)
        self.save()
        super(MusicStorage, self).update(**kwargs)
コード例 #7
0
class UserImage(db.Document):
    user_img_id = db.ObjectIdField(default=ObjectId,
                                   required=True,
                                   unique=True,
                                   primary_key=True)
    # user_ref = db.ReferenceField('User', required=True, dbref=False)
    facebook_id = db.StringField(max_length=255, required=True)
    data_file = db.FileField(required=True)
コード例 #8
0
ファイル: tag.py プロジェクト: SlimShadyIAm/gir
class Tag(mongoengine.EmbeddedDocument):
    name = mongoengine.StringField(required=True)
    content = mongoengine.StringField(required=True)
    added_by_tag = mongoengine.StringField()
    added_by_id = mongoengine.IntField()
    added_date = mongoengine.DateTimeField(default=datetime.now)
    use_count = mongoengine.IntField(default=0)
    image = mongoengine.FileField(default=None)
コード例 #9
0
class Version(db.Document):
    meta = {'strict': False}
    archivo = db.FileField()  # id de GridFS
    redactor = db.ReferenceField(Usuario)
    fecha = db.DateTimeField(default=datetime.datetime.now)
    comentarios = db.ListField(db.ReferenceField(Comentario))
    nombre = db.StringField(max_length=50)  # Ej. R_2
    nombre_creacion = db.StringField(max_length=10)  # Ej. XX_99_99
コード例 #10
0
class Features(mongoengine.Document):
    document = mongoengine.ReferenceField(Cache, reverse_delete_rule=mongoengine.CASCADE, required=True)
    feature = mongoengine.BinaryField(required=True)
    file = mongoengine.FileField(required=True)
    meta = {
        'db_alias': 'core',
        'collection': 'features'
    }
コード例 #11
0
ファイル: fcs.py プロジェクト: fabbondanza/CytoPy
class Cluster(mongoengine.EmbeddedDocument):
    """
    Represents a single cluster generated by a clustering experiment on a single file

    Parameters
    ----------
    cluster_id: str, required
        name associated to cluster
    index: FileField
        index of cell events associated to cluster (very large array)
    n_events: int, required
        number of events in cluster
    prop_of_root: float, required
        proportion of events in cluster relative to root population
    cluster_experiment: RefField
        reference to ClusteringDefinition
    meta_cluster_id: str, optional
        associated meta-cluster
    """
    cluster_id = mongoengine.StringField(required=True)
    index = mongoengine.FileField(db_alias='core',
                                  collection_name='cluster_indexes')
    n_events = mongoengine.IntField(required=True)
    prop_of_root = mongoengine.FloatField(required=True)
    cluster_experiment = mongoengine.ReferenceField(ClusteringDefinition)
    meta_cluster_id = mongoengine.StringField(required=False)

    def save_index(self, data: np.array) -> None:
        """
        Save the index of data that corresponds to cells belonging to this cluster

        Parameters
        ----------
        data: np.array, required
            Numpy array of single cell events data

        Returns
        -------
        None
        """
        if self.index:
            self.index.replace(Binary(pickle.dumps(data, protocol=2)))
        else:
            self.index.new_file()
            self.index.write(Binary(pickle.dumps(data, protocol=2)))
            self.index.close()

    def load_index(self) -> np.array:
        """
        Load the index of data that corresponds to cells belonging to this cluster

        Returns
        -------
        np.array
            Array of single cell events data
        """
        return pickle.loads(bytes(self.index.read()))
コード例 #12
0
ファイル: Users.py プロジェクト: adnanahmadkhan/Orion
class PersonalDetails(me.Document):
    date_of_birth = me.DateField()
    nationality = me.StringField()
    gender = me.StringField()
    home_number = me.IntField()
    current_address = me.StringField()
    postcode = me.IntField()
    duration_of_stay_at_address = me.StringField()
    profile_picture = me.FileField()
コード例 #13
0
class Products(me.Document):
    title = me.StringField(min_length=1, max_length=512)
    description = me.StringField(min_length=2, max_length=4096)
    created = me.DateField(default=datetime.datetime.now())
    price = me.DecimalField(required=True)
    in_stock = me.BooleanField(default=True)
    discount = me.IntField(min_value=0, max_value=100)
    image = me.FileField(required=True)
    category = me.ReferenceField(Category)
コード例 #14
0
ファイル: models.py プロジェクト: d3vzer0/streamio-faust
class Snapshots(db.Document):
    url = db.StringField(max_length=1000, required=True)
    timestamp = db.DateTimeField(required=False, default=datetime.datetime.now)
    response = db.EmbeddedDocumentField(Responses)
    sha256 = db.StringField(max_length=256, required=True)
    screenshot = db.FileField()

    meta = {
        'ordering': ['-timestamp'],
    }
コード例 #15
0
ファイル: models.py プロジェクト: YiranShu/scene-editor
class Scene(mongoengine.Document):
    # created_on = models.DateTimeField(auto_now_add=True)
    file = mongoengine.FileField()
    file_name = mongoengine.StringField()
    # user = mongoengine.StringField()
    date_created = mongoengine.DateTimeField(default=datetime.datetime.utcnow)
    scene_name = mongoengine.StringField()
    description = mongoengine.StringField()
    category = mongoengine.StringField()
    tag = mongoengine.StringField()
コード例 #16
0
class Product(me.Document):
    title = me.StringField(min_length=2, max_length=128, required=True)
    description = me.StringField(max_length=2048)
    price = me.DecimalField(force_string=True, required=True, min_value=0)
    discount = me.IntField(min_value=0, max_value=100, default=0)
    in_stock = me.BooleanField(default=True)
    category = me.ReferenceField(Category)
    supplier = me.ReferenceField(Supplier)
    image = me.FileField()
    parameters = me.EmbeddedDocumentField(Parameters)
コード例 #17
0
ファイル: user.py プロジェクト: jainal09/Mask_net
class UserModel(mongoengine.Document):
    @classmethod
    def post_save(cls, sender, document, **kwargs):
        globals.add_to_embeddings(username=document.user_name,
                                  encoding=pickle.loads(document.encoding))

    user_name = mongoengine.StringField(required=True)
    image = mongoengine.FileField(required=True)
    encoding = mongoengine.BinaryField(required=True)
    meta = {'db_alias': 'core', 'collection': 'users'}
コード例 #18
0
ファイル: challenges.py プロジェクト: r202-coe-psu/sadhu
class TestCase(me.Document):
    input_file = me.FileField()
    is_inputfile = me.BooleanField(required=True, default=False)
    input_string = me.StringField()

    output_file = me.FileField()
    is_outputfile = me.BooleanField(required=True, default=False)
    output_string = me.StringField()

    public = me.BooleanField(required=True, default=False)

    challenge = me.ReferenceField("Challenge", dbref=True, required=True)
    owner = me.ReferenceField("User", dbref=True, required=True)
    created_date = me.DateTimeField(required=True,
                                    default=datetime.datetime.now)
    updated_date = me.DateTimeField(required=True,
                                    default=datetime.datetime.now,
                                    auto_now=True)

    meta = {"collection": "test_cases"}
コード例 #19
0
class TrainedClassifiers(mongoengine.Document):
    name = mongoengine.StringField(required=True, max_length=256, unique=True)
    classifier = mongoengine.FileField()
    stats = mongoengine.DictField()

    def set_classifier(self, classifier):
        s = StringIO.StringIO(pickle.dumps(classifier))
        self.classifier.put(s)

    def get_classifier(self):
        return pickle.loads(self.classifier.read())
コード例 #20
0
class Card(me.EmbeddedDocument):
    title = me.StringField(default='Card Title')
    content = me.StringField(default='Card Content')
    image = me.FileField()
    width = me.IntField(default=50)
    height = me.IntField(default=50)
    x = me.IntField(required=True, validation=_not_empty)
    y = me.IntField(required=True, validation=_not_empty)
    linked_board = me.ReferenceField('Board', default=None)

    meta = {'auto_create_index': True}
コード例 #21
0
ファイル: models.py プロジェクト: vivid-ZLL/wx_diancan
class Menu(mongoengine.Document):
    title = mongoengine.StringField(max_length=16)
    menuId = mongoengine.StringField(max_length=16)
    hot = mongoengine.StringField(max_length=16, default=None)
    bargin = mongoengine.StringField(max_length=16, default=None)
    active = mongoengine.BooleanField(max_length=16, default=False)
    all = mongoengine.StringField(max_length=16, default="所有菜品")
    price = mongoengine.IntField()
    id_ = mongoengine.IntField()
    num = mongoengine.IntField(default=1)
    img = mongoengine.FileField()
コード例 #22
0
ファイル: models.py プロジェクト: zhaolixiang/graphene-mongo
class Editor(mongoengine.Document):
    """
    An Editor of a publication.
    """

    meta = {'collection': 'test_editor'}
    id = mongoengine.StringField(primary_key=True)
    first_name = mongoengine.StringField(required=True, help_text="Editor's first name.", db_field='fname')
    last_name = mongoengine.StringField(required=True, help_text="Editor's last name.")
    metadata = mongoengine.MapField(field=mongoengine.StringField(), help_text="Arbitrary metadata.")
    company = mongoengine.LazyReferenceField(Publisher)
    avatar = mongoengine.FileField()
    seq = mongoengine.SequenceField()
コード例 #23
0
class Test(gj.Document):
    test = mongoengine.FileField()
    creation_date = mongoengine.DateTimeField()
    modified_date = mongoengine.DateTimeField(default=datetime.datetime.now)

    def default(self, user):
        self.test["id"] = user.id

    def save(self, *args, **kwargs):
        if not self.creation_date:
            self.creation_date = datetime.datetime.now()
        self.modified_date = datetime.datetime.now()
        return super(Test, self).save(*args, **kwargs)
コード例 #24
0
class XmlData(mongoengine.Document):
    anareport = mongoengine.IntField()
    xml = mongoengine.DictField()
    file = mongoengine.FileField()
    wave = mongoengine.DictField()
    file_name = mongoengine.StringField()

    #
    # class Meta:
    #     collection = "xmldata"

    def __str__(self):
        return self.anareport
コード例 #25
0
ファイル: models.py プロジェクト: C0nstanta/one
class Products(me.Document):
    attributes = me.EmbeddedDocumentField(ProductAttributes)
    title = me.StringField(min_length=1, max_length=512)
    description = me.StringField(min_length=2, max_length=4096)
    created = me.DateTimeField(default=datetime.datetime.now())
    price = me.DecimalField(required=True)
    in_stock = me.BooleanField(default=True)
    discount = me.IntField(min_value=0, max_value=100)
    image = me.FileField(required=True)
    category = me.ReferenceField('Category')

    def get_discount_price(self):
        return self.price - (self.price / 100 * self.discount)
コード例 #26
0
class Checkpoint(me.Document):
	"""
	Checkpoint document containing .vtk file for an associated .yaml setup
	"""

	name = me.StringField()  # Name
	setup = me.ReferenceField(Setup)  # associated yaml setup
	vtk = me.FileField()  # .vtk file
	vtk_hash = me.StringField(unique=True)  # vtk hash
	active = me.BooleanField()  # active toggle
	uploadDate = me.DateTimeField()  # Upload Date

	def __str__(self):
		return self.name
コード例 #27
0
class UserModel(mongoengine.Document):
    @classmethod
    def pre_save(cls, sender, document, **kwargs):
        globals.add_to_embeddings(username=document.user_name,
                                  encoding=pickle.loads(document.encoding))

    user_name = mongoengine.StringField(required=True)
    full_name = mongoengine.StringField(required=True)
    points = mongoengine.IntField(default=0, required=True)
    img = mongoengine.FileField(required=True)
    encoding = mongoengine.BinaryField(required=True)
    email = mongoengine.StringField(required=True)
    description = mongoengine.StringField(required=True)
    meta = {'db_alias': 'core', 'collection': 'users'}
コード例 #28
0
class Product(me.Document):
    title = me.StringField(required=True, max_length=256)
    description = me.StringField(max_length=512)
    in_stock = me.BooleanField(default=True)
    discount = me.IntField(min_value=0, max_value=100, default=0)
    price = me.FloatField(required=True)
    image = me.FileField()
    category = me.ReferenceField(Category,
                                 required=True,
                                 reverse_delete_rule=CASCADE)
    parameters = me.EmbeddedDocumentField(Parameters)

    @property
    def product_price(self):
        return (100 - self.discount) / 100 * self.price
コード例 #29
0
class Product(me.Document):
    title = me.StringField(required=True, max_length=256)
    description = me.StringField(max_length=512)
    in_stock = me.BooleanField(default=True)
    discount = me.IntField(min_value=0, max_value=100, default=0)
    price = me.FloatField(required=True)
    image = me.FileField()
    category = me.ReferenceField(Category, required=True)
    parameters = me.EmbeddedDocumentField(Parameters)

    def real_discount(self):
        if self.discount != 0:
            return self.price * (100 - self.discount) / 100
        else:
            return self.price
コード例 #30
0
ファイル: models.py プロジェクト: viktortsvil/ITEA_Project
class Product(me.Document):
    title = me.StringField(required=True, min_length=2, max_length=512)
    slug = me.StringField(required=True, min_length=2, max_length=512, unique=True)
    description = me.StringField(min_length=2, max_length=2048)
    characteristics = me.EmbeddedDocumentField(Characteristics)
    price = me.DecimalField(required=True, min_value=0, force_string=True)
    discount_percentage = me.IntField(min_value=0, max_value=100, default=0)
    category = me.ReferenceField(Category)
    image = me.FileField()

    @classmethod
    def get_discount_products(cls):
        return cls.objects.filter(discount_percentage__gt=0)  # discount_percentage > 0

    def get_price(self):
        return self.price * (100 - self.discount_percentage) / 100