class NewModel(Model): class Meta: collection_name = 'testcolletion' first_name = TextField() # now we added 'last_name' field last_name = TextField()
class Audio(Model): id = IDField() ayah_id = TextField() ayah_number = NumberField() edition_id = TextField() type = TextField(format='capitalize') # Translation or Arabic audio = TextField()
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
class CityOrderAndLimit(Model): short_name = IDField() name = TextField() state = TextField() country = TextField() capital = BooleanField() population = NumberField() regions = ListField()
class CityQueryAndFiltering(Model): short_name = IDField() name = TextField() state = TextField() country = TextField() capital = BooleanField() population = NumberField() regions = ListField()
class Translation(Model): id = IDField() ayah_id = TextField() edition_id = TextField() ayah_number = NumberField() text = TextField() class Meta: collection_name = "translations"
class Edition(Model): id = IDField() language = TextField() name = TextField() translator = TextField() class Meta: to_lowercase = True collection_name = "quran_editions"
class User(Model): id = IDField() name = TextField() email = TextField() profile_pic = TextField() last_login = DateTime() class Meta: collection_name = 'users'
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"
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"
class Edition(Model): id = IDField() language = TextField() name = TextField() english_name = TextField() type = TextField() class Meta: to_lowercase = True collection_name = "editions"
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
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()
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"
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'
class LowercaseUser(Model): txt_name = TextField() dict_name = MapField() lst_name = ListField() base_name = Field() class Meta: to_lowercase = True
class Ayah(Model): id = IDField() number = NumberField() surah_number = NumberField() content = MapField() uci = TextField(required=True) class Meta: collection_name = "quran"
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
class CityEmptyField(Model): text = TextField() number = NumberField() date = DateTime() bool = BooleanField() geo_point = GeoPoint() list = ListField() map = MapField() nested = NestedModel(NModel) ref = ReferenceField(RModel)
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"
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"
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"
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"
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
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()})
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
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"
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
class GetAllModel(Model): name = TextField()
class DeepNestedUni3(Model): dept = TextField() student = NestedModel(DeepNestedStudent3, required=True)