コード例 #1
0
class NewModel(Model):
    class Meta:
        collection_name = 'testcolletion'

    first_name = TextField()
    # now we added 'last_name' field
    last_name = TextField()
コード例 #2
0
class Audio(Model):
    id = IDField()
    ayah_id = TextField()
    ayah_number = NumberField()
    edition_id = TextField()
    type = TextField(format='capitalize')  # Translation or Arabic
    audio = TextField()
コード例 #3
0
class User(Model):
    """User Class Model, extending from ```fireo.models.Model``` package.

    Attributes
    ----------
    id : str
        User unique id composed by subject id given by google auth.
    name : str
        User display name.
    contacts_statistics : dict
        dictionary containg the statistics about contacts, in other words,
        contacts per domain, contacts per City Adresss, contacts per organization

    """

    id = IDField()
    query_id = TextField()
    name = TextField()
    contacts_statistics = MapField()

    @staticmethod
    def statistics_to_chart(data):
        """Return a dictionary with label and data to plot statistics.
        
        Parameters
        ----------
        data : Dict
            Dictionary with contacts statistics in the following format:
            {
                'organization': {
                    'google': 25, 'facebook': 30
                },
                ...
            }
            
        Returns
        -------
        dict
            Dictionary in the following format:
            {
                'organization': {
                    'label': ["google", "facebook", ...],
                    'data': [25, 30, ...]
                }
            }
        """
        data = data['contacts_statistics']

        chart_data = {}

        for key, item in data.items():
            print(key, item)
            chart_data[key] = {"label": [], "data": []}

            for label, value in item.items():
                chart_data[key]["label"].append(label)
                chart_data[key]["data"].append(value)

        return chart_data
コード例 #4
0
class CityOrderAndLimit(Model):
    short_name = IDField()
    name = TextField()
    state = TextField()
    country = TextField()
    capital = BooleanField()
    population = NumberField()
    regions = ListField()
コード例 #5
0
class CityQueryAndFiltering(Model):
    short_name = IDField()
    name = TextField()
    state = TextField()
    country = TextField()
    capital = BooleanField()
    population = NumberField()
    regions = ListField()
コード例 #6
0
class Translation(Model):
    id = IDField()
    ayah_id = TextField()
    edition_id = TextField()
    ayah_number = NumberField()
    text = TextField()
    
    class Meta:
        collection_name = "translations"
コード例 #7
0
class Edition(Model):
    id = IDField()
    language = TextField()
    name = TextField()
    translator = TextField()

    class Meta:
        to_lowercase = True
        collection_name = "quran_editions"
コード例 #8
0
ファイル: user.py プロジェクト: guohaolee/ghost_name_picker
class User(Model):
    id = IDField()
    name = TextField()
    email = TextField()
    profile_pic = TextField()
    last_login = DateTime()

    class Meta:
        collection_name = 'users'
コード例 #9
0
ファイル: ayah.py プロジェクト: islam-786/quran-data-importer
class Ayah(Model):
    id = IDField()
    surah_id = TextField()
    number = NumberField(int_only=True)
    number_in_surah = NumberField(int_only=True)
    arabic = TextField()

    class Meta:
        collection_name = "quran_ayahs"
コード例 #10
0
ファイル: audio.py プロジェクト: OctaByteInc/quran-data
class Audio(Model):
    id = IDField()
    ayah_id = TextField()
    ayah_number = NumberField()
    edition_id = TextField()
    type = TextField()  # Translation or Arabic
    link = TextField()

    class Meta:
        collection_name = "audios"
コード例 #11
0
class Edition(Model):
    id = IDField()
    language = TextField()
    name = TextField()
    english_name = TextField()
    type = TextField()

    class Meta:
        to_lowercase = True
        collection_name = "editions"
コード例 #12
0
class Surah(Model):
    id = IDField()
    number = NumberField(int_only=True)
    name = TextField(format='title')
    english_name = TextField(format='title')
    english_name_translation = TextField(format='title')
    number_of_ayahs = NumberField(int_only=True)
    revelation_type = TextField(format='capitalize')

    class Meta:
        to_lowercase = True
コード例 #13
0
ファイル: ayah.py プロジェクト: OctaByteInc/quran
class Ayah(Model):
    id = IDField()
    surah_id = TextField()
    number = NumberField(int_only=True)
    number_in_surah = NumberField(int_only=True)
    juz = NumberField(int_only=True)
    manzil = NumberField(int_only=True)
    ruku = NumberField(int_only=True)
    hizb_quarter = NumberField(int_only=True)
    sajda = BooleanField()
    arabic = TextField()
コード例 #14
0
ファイル: surah.py プロジェクト: islam-786/quran-backend-api
class Surah(Model):
    id = IDField()
    number = NumberField(int_only=True)
    name = TextField()
    english_name = TextField()
    english_name_translation = TextField()
    number_of_ayahs = NumberField(int_only=True)
    revelation_type = TextField()

    class Meta:
        to_lowercase = True
        collection_name = "quran_surahs"
コード例 #15
0
class Employee3(Model):
    address = TextField()
    company = ReferenceField(Company, on_load='company_load')

    def company_load(self, c):
        self.c_name = c.name
        assert c.name == 'Abc_company'
コード例 #16
0
class LowercaseUser(Model):
    txt_name = TextField()
    dict_name = MapField()
    lst_name = ListField()
    base_name = Field()

    class Meta:
        to_lowercase = True
コード例 #17
0
ファイル: ayah.py プロジェクト: octabytes/data-importer
class Ayah(Model):
    id = IDField()
    number = NumberField()
    surah_number = NumberField()
    content = MapField()
    uci = TextField(required=True)

    class Meta:
        collection_name = "quran"
コード例 #18
0
class Hero(Model):
    """Model Hero"""
    id = IDField()
    description = TextField()
    image_url = TextField()
    name = TextField()
    universe = TextField()

    class Meta:
        collection_name = "Hero"

    @classmethod
    def all(cls, cursor=None, list_type='cursor'):
        """
        Get all heroes
        :param int limit: limit of heroes
        :return: Heroes list
        """
        if list_type == 'all':
            limit = 100
        else:
            limit = 20

        if cursor:
            return cls.collection.cursor(cursor).fetch(limit)
        else:
            return cls.collection.fetch(limit)

    @classmethod
    def get_by_id(cls, hero_id):
        """
        Get by id
        :param hero_id:
        :return:
        """
        return cls.collection.get('Hero/%s' % hero_id)

    def to_dict(self):
        """"""
        hero_dict = super(Hero, self).to_dict()
        hero_dict['imageUrl'] = self.image_url
        del (hero_dict['image_url'])
        return hero_dict
コード例 #19
0
class CityEmptyField(Model):
    text = TextField()
    number = NumberField()
    date = DateTime()
    bool = BooleanField()
    geo_point = GeoPoint()
    list = ListField()
    map = MapField()
    nested = NestedModel(NModel)
    ref = ReferenceField(RModel)
コード例 #20
0
class AbuDawud(Model):
    id = IDField()
    hadith_number = NumberField()
    book_number = NumberField()
    book_name = MapField()
    chapter = MapField()
    text = MapField()
    is_sahih = BooleanField()
    uci = TextField(required=True)

    class Meta:
        collection_name = "abu_dawud"
コード例 #21
0
ファイル: ibnemaja.py プロジェクト: octabytes/data-importer
class IbneMaja(Model):
    id = IDField()
    hadith_number = NumberField()
    book_number = NumberField()
    book_name = MapField()
    chapter = MapField()
    text = MapField()
    is_sahih = BooleanField()
    uci = TextField(required=True)

    class Meta:
        collection_name = "ibne_maja"
コード例 #22
0
class Mishkat(Model):
    id = IDField()
    hadith_number = NumberField()
    book_number = NumberField()
    book_name = MapField()
    chapter = MapField()
    text = MapField()
    is_muttafaqun_alayh = BooleanField()
    is_sahih = BooleanField()
    uci = TextField(required=True)

    class Meta:
        collection_name = "mishkat"
コード例 #23
0
ファイル: muslim.py プロジェクト: octabytes/data-importer
class Muslim(Model):
    id = IDField()
    hadith_number = NumberField()
    book_number = NumberField()
    international_number = NumberField()
    book_name = MapField()
    chapter = MapField()
    text = MapField()
    is_sahih = BooleanField()
    uci = TextField(required=True)

    class Meta:
        collection_name = "muslim"
コード例 #24
0
class TestDB(Model):
    id = IDField()
    name = TextField()
    class_name = 'test_users'

    class Meta:
        collection_name = 'test_users'

    @classmethod
    def delete(cls, id):
        try:
            cls.collection.delete(f"{cls.class_name}/{id}")
            return True
        except Exception as e:
            return False
コード例 #25
0
class Task(Model):
    id = IDField()
    pkl_path = TextField()
    generation = NumberField()
    assigned_to = TextField(default="nobody")
    state = TextField(default="incomplete")
    created_at = DateTime(default=datetime.datetime.now())
    assigned_at = DateTime()
    ngrok_url = TextField()
    pkl_data = TextField()
    result_pkl_data = TextField()
    network_id = NumberField()
    extra_workers = NumberField(default=0)
    run_code = TextField(default="none")
    client_stream = TextField(default="tpu")

    def __str__(self):
        return str({k: str(v)[:15] for k, v in self.to_dict().items()})
コード例 #26
0
class Edition(Model):
    id = IDField()
    language = TextField()
    name = TextField(format='title')
    translator = TextField(format='title')
    type = TextField(format='capitalize')
    format = TextField(format='capitalize')
    direction = TextField()

    class Meta:
        to_lowercase = True
コード例 #27
0
class Edition(Model):
    id = IDField()
    language = TextField()
    name = TextField()
    translator = TextField()
    type = TextField()
    format = TextField()
    direction = TextField()

    class Meta:
        to_lowercase = True
        collection_name = "editions"
コード例 #28
0
class GhostRecord(Model):

    id = IDField()
    name = TextField()
    description = TextField()
    picked = BooleanField(default=False)
    user_first_name = TextField(default=None)
    user_last_name = TextField(default=None)
    user_email = TextField(default=None)
    user_ghost_name = TextField(default=None)
    class_name = 'ghost_name'

    class Meta:
        collection_name = 'ghost_name'

    @classmethod
    def get_unallocated_ghost(cls):
        return cls.collection.filter('picked', '==', False).fetch()

    @classmethod
    def get_allocated_ghost(cls):
        return cls.collection.filter('picked', '==', True).fetch()

    @classmethod
    def get_single_ghost(cls, ghost):
        return cls.collection.get(f"{cls.class_name}/{ghost}")

    @classmethod
    def get_email_record(cls, email):
        return cls.collection.filter('user_email', '==', email).fetch()

    @classmethod
    def reset(cls, email):
        """ reset the record """
        record = cls.collection.filter('user_email', '==', email).fetch()
        for r in record:
            r.picked = False
            r.user_first_name = None
            r.user_last_name = None
            r.user_email = None
            r.user_ghost_name = None
            r.save()

    @classmethod
    def has_record(cls, email):
        result = cls.collection.filter('user_email', '==', email).get()
        if result:
            return True
        else:
            return False
コード例 #29
0
class GetAllModel(Model):
    name = TextField()
コード例 #30
0
class DeepNestedUni3(Model):
    dept = TextField()
    student = NestedModel(DeepNestedStudent3, required=True)