class TVShow(Model): class Meta: database = dbTVShows name = CharField() year_start = DateField() year_end = DateField()
class TexteVersion(BaseModel): class Meta: table_name = "textes_versions" id = CharField(primary_key=True) nature = TextField() titre = TextField() titrefull = TextField() titrefull_s = TextField() etat = TextField() date_debut = DateField() date_fin = DateField() autorite = TextField() ministere = TextField() num = TextField() num_sequence = IntegerField() nor = CharField() date_publi = DateField() date_texte = DateField() derniere_modification = DateField() origine_publi = TextField() page_fin_publi = IntegerField() page_deb_publi = IntegerField() visas = TextField() signataires = TextField() tp = TextField() nota = TextField() abro = TextField() rect = TextField() dossier = TextField() cid = CharField() mtime = IntegerField() texte_id = CharField()
class User(db.Model): name = CharField(column_name="naam") email = CharField() usergroup_id = CharField(column_name="cms_usergroups_id") valid_firstday = DateField() valid_lastday = DateField() lastlogin = DateTimeField() lastaction = DateTimeField() class Meta: table_name = "cms_users" def __str__(self): return self.name, self.organisation_id @staticmethod def get_all_users(): return User.select().order_by(User.name) @staticmethod def get_user(email): user = User.select().where(User.email == email).get() base_ids = UsergroupBaseAccess.get_all_base_id_for(user.usergroup_id) # base_ids is a peewee ModelSelect (so, many objects). # convert to dict 1 at a time, # and pull the base_id from that dict, and put in a list user.base_id = [model_to_dict(item)["base_id"] for item in base_ids] return user
class Texte(Model): class Meta: database = bd enum_natures = [ 'constitution', 'code', 'loi', 'loi constitutionnelle', 'ordonnance', 'décret', 'arrêté', 'décret-loi' ] enum_natures = [ ('constitution', 'Constitution'), ('code', 'Code'), ('loi', 'Loi'), ('loi constitutionnelle', 'Loi constitutionnelle'), ('ordonnance', 'Ordonnance'), ('décret', 'Décrêt'), ('arrêté', 'Arrêté'), ('décret-loi', 'Décret-loi') ] cid = CharField(max_length=20, primary_key=True) nor = CharField(max_length=20) nature = CharField(max_length=20, choices=enum_natures) date_texte = DateField(null=True) date_publi = DateField(null=True)
class Version_texte(Model): class Meta: database = bd enum_etats_juridiques = [ ('VIGUEUR', 'vigueur'), ('VIGUEUR_DIFF', 'vigueur différée'), ('ABROGE', 'abrogé'), ('ABROGE_DIFF', 'abrogé différé'), ('ANNULE', 'annulé'), ('PERIME', 'périmé'), ('TRANSFERE', 'transféré'), ('', 'disjoint'), ('', 'substitué'), ('MODIFIE', ''), ('MODIFIE_MORT_NE', '') ] texte = ForeignKeyField(Texte, related_name='versions_texte') titre = CharField(max_length=200) titre_long = CharField(max_length=200) etat_juridique = CharField(max_length=25) debut = DateField(null=True) fin = DateField(null=True) base = ForeignKeyField('self', null=True)
class BaseModel(Model): """Base model for tables""" created = DateField(default=datetime.datetime.now) modified = DateField(default=datetime.datetime.now) class Meta: database = db @classmethod def get_all(cls, limit: int = 20, offset: int = 1): """Querys for all records of a model Keyword Arguments: limit {int} -- Number of records to select (default: {20}) offset {int} -- Start of records (default: {1}) Returns: [type] -- [description] """ return cls.select().limit(limit).offset(offset) @classmethod def get_by_id(cls, id): """Gets a record by id Arguments: id {[type]} -- ID of record on table Returns: [type] -- [description] """ return cls.get(id=id)
class Bill(BaseModel): name = CharField(max_length=255, unique=True) amount = IntegerField() first_day = DateField() last_day = DateField() paid_on = DateTimeField(null=True) paid_by = ForeignKeyField(User, backref='all', null=True)
class Order(BaseModel): address = TextField() full_address = TextField(default="") latitude = FloatField(default=0.0) longitude = FloatField(default=0.0) assigned_date = DateField(default=date.today) due_date = DateField(default=date.today) research_completed = BooleanField(default=False) data_completed = BooleanField(default=False) supervisor_picture = BooleanField(default=False) data_picture = BooleanField(default=False) manager_submit = BooleanField(default=False) company = ForeignKeyField(Company) research_user = ForeignKeyField(User, null=True) data_user = ForeignKeyField(User, null=True) client_code = ForeignKeyField(ClientCode) kind = ForeignKeyField(OrderType, null=True) research_type = ForeignKeyField(ResearchType, null=True) state = ForeignKeyField(OrderState, null=True)
class ReportingUnit(BaseModel): id = CharField(null=True) reportingunitid = CharField(null=True) reportingunitname = CharField(null=True) description = CharField(null=True) electiondate = DateField() fipscode = CharField(null=True, max_length=5) initialization_data = BooleanField(null=True) lastupdated = DateField(null=True) level = CharField(null=True) national = CharField(null=True) officeid = CharField(null=True) officename = CharField(null=True) precinctsreporting = IntegerField(null=True) precinctsreportingpct = DecimalField(null=True) precinctstotal = IntegerField(null=True) raceid = CharField(null=True) racetype = CharField(null=True) racetypeid = CharField(null=True) seatname = CharField(null=True) seatnum = CharField(null=True) statename = CharField(null=True) statepostal = CharField(null=True, max_length=2) test = BooleanField(null=True) uncontested = BooleanField(null=True) votecount = IntegerField(null=True)
class ClientConfig(BaseModel): id = IntegerField(primary_key=True, db_column="client_config_id", sequence="client_config_id_seq") client_id = ForeignKeyField(Client, related_name="configurations", to_field="client_id", index=True) event_type_id = ForeignKeyField(EventType, related_name="event_types", to_field="event_type_id", index=True) effective_date = DateField(null=False) expiration_date = DateField(null=True) status = StatusField(null=False, default="PENDING") account_type = AccountTypeField(null=False) product_code = CharField(null=True) # balance_range = DecimalField(max_digits=15, decimal_places=4, auto_round=True, null=True) balance_floor = DecimalField(max_digits=15, decimal_places=4, auto_round=True, null=True) inserted = DateTimeField(default=DT.now(), null=False) updated = DateTimeField(default=DT.now(), null=False) class Meta: db_table = "client_configs"
class Article(Model): class Meta: database = bd enum_etat_juridique = [ 'vigueur', 'vigueur différée', 'abrogé', 'vigueur avec terme', 'annulé', 'disjoint', 'modifié', 'périmé', 'substitué', 'transféré' ] id = CharField(max_length=20, primary_key=True) nom = CharField(max_length=200) etat_juridique = CharField(max_length=25) num = CharField(max_length=200) debut = DateField() fin = DateField(null=True) texte = ForeignKeyField(Texte) version_section = ForeignKeyField(Version_section, null=True) version_texte = ForeignKeyField(Version_texte)
class TVShow(Model): class Meta: database = dbTVShows name = CharField() year_start = DateField(default=datetime.date.today(), null=True) year_end = DateField(default=datetime.date.today(), null=True)
class MeetingRequest(Base): ticketID = ForeignKeyField(JiraTicket, backref="allocations") afterDate = DateField() beforeDate = DateField() highPriority = BooleanField() requestFilled = BooleanField(default=False) dateAllocated = DateField(null=True) @classmethod def makeRequest(cls, ticketID, afterDate, dueDate, priority): try: newAllocation = cls.create( ticketID=ticketID, afterDate=afterDate, beforeDate=dueDate, highPriority=priority, ) return newAllocation except IntegrityError: raise ValueError(f"Ticket Assign Already Exists") @property def afterDate_date(self): return dt.datetime.strptime(str(self.afterDate), "%Y-%m-%d").date() @property def beforeDate_date(self): return dt.datetime.strptime(str(self.beforeDate), "%Y-%m-%d").date() @property def priority(self): return self.highPriority @property def allocatedDate(self): if self.requestFilled: return self.dateAllocated else: return False def allocateDate(self, setDate): self.requestFilled = True self.dateAllocated = setDate self.save() def elevatePriority(self): self.highPriority = True self.save() @property def isActive(self): if ( self.beforeDate_date - dt.date.today() ).days <= 0 and not self.requestFilled: return True else: return False
class Location(BaseModel): id = PrimaryKeyField() uuid = UUIDField(constraints=[SQL('DEFAULT uuid_generate_v4()')], unique=True) city = CharField() address = CharField() type = ForeignKeyField(Location_Type, related_name='related_locations') available_from = DateField(default=datetime.now().strftime('%Y-%m-%d')) unavailable_from = DateField(null=True)
class Manager(db.Model): password_hash = CharField(255, null=False) building = ForeignKeyField(Building, null=True) leaved = BooleanField(null=False) real_name = CharField(255, null=False) enter_date = DateField(null=False) leave_date = DateField(null=True)
class Contract(BaseModel): uuid = UUIDField(default=uuid.uuid4(), constraints=[SQL('DEFAULT uuid_generate_v4()')], unique=True) user = ForeignKeyField(User, related_name='contracts') module = ForeignKeyField(Module, related_name='contracts') type = ForeignKeyField(Contract_Type, related_name='contracts') signed_on = DateField(default=datetime.now().date()) valid_till = DateField() class Meta: primary_key = CompositeKey('user', 'module', 'signed_on')
class Reminder(BaseModel): user_name = CharField() tweet_id = BigIntegerField() created_on = DateField() remind_on = DateField() stock_symbol = CharField() stock_price = FloatField() class Meta: table_name = "reminders"
class Airline(Model): asn_id = CharField(20) name = CharField(100) country = CharField(30) ICAO = CharField(6) IATA = CharField(6) founded = DateField() ended = DateField() class Meta: database = db
class Pricing(ModelBase): id = IntegerField(primary_key=True) account_id = IntegerField() active_time = DateField() deactive_time = DateField() currency = CharField() pricing_config = TextField() class Meta: database = db table_name = 'pricing'
class Pitchfork(BaseModel): url = TextField() pubdate = DateField() score = DoubleField() year = DateField() label = TextField() genre = TextField() artwork = TextField() title = TextField() artist = TextField() album = TextField()
class Reservation(ModelBase): """ Classe de Reservation para mapeamento """ reservation_code = CharField(null=True, unique=True) number_of_guests = IntegerField() reservation_date = DateField() checkin_date = DateField() checkout_date = DateField() ativo = CharField(null=False, default = 'ativo') customer = ForeignKeyField(Customer)
class QuotationDetails(Model): customerName = TextField() customerAddress = TextField() quotationNo = IntegerField() quotationValidity = DateField() quotationDate = DateField() estAmount = FloatField() estTotal = FloatField() remarks = TextField() cancelReason = TextField() class Meta: database = db
class Book(Model): owner = CharField() rank = IntegerField() title = CharField() author = CharField() genre = CharField() read = BooleanField(default=False) date_added = DateField(default=datetime.datetime.now) date_read = DateField(null=True, default=None) class Meta: database = db
class Job(BaseModel): contest_num = IntegerField() date_closed = DateField(null=True) date_opened = DateField() dept = TextField() site_id = IntegerField() site_url = TextField() title = TextField() class Meta: table_name = 'job' schema = 'jobs'
class Module_Location(BaseModel): uuid = UUIDField(constraints=[SQL('DEFAULT uuid_generate_v4()')], unique=True) module = ForeignKeyField(Module, related_name='locations') location = ForeignKeyField(Location, related_name='modules') corridor = ForeignKeyField(Corridor, related_name='modules') price_per_month = FloatField() start_date = DateField() end_date = DateField() class Meta: primary_key = CompositeKey('module', 'start_date')
class Transaction(Model): type = CharField() wallet_txid = DateField() amount = FloatField() to_user = ForeignKeyField(User, related_name='incoming_transactions', null=True) from_user = ForeignKeyField(User, related_name='outgoing_transactions', null=True) transaction_time = DateField(null=True) raw_tx_rpc = CharField(null=True) status = CharField() created = DateField() class Meta: database = db
class Patient(Model): code = IntegerField(unique=True) name = CharField(50) lastName = CharField(50) telNumber = CharField(50) birthDate = DateField() vaccine = ForeignKeyField(Vaccine, backref='vaccine') province = ForeignKeyField(Province, backref='province') firstDoseDate = DateField() secondDoseDate = DateField(null=True) class Meta: database = db
class BookShelf(BaseModel): user = ForeignKeyField(User, backref='book_shelves') book = ForeignKeyField(Book, backref='book_shelves') shelf = ForeignKeyField(Shelf, backref='book_shelves') start_date = DateField(null=True) end_date = DateField(null=True) rate = SmallIntegerField() comment = TextField() created_time = DateTimeField(default=datetime.now()) def change_to_read(self): read_shelf = self.user.shelves.where(Shelf.name == Shelf.READ).first() self.shelf = read_shelf self.save()
class PersonToJob(BaseModel): """ Maps a person to a job. """ LOGGER.info('Define PersonToJob table...') person_name = ForeignKeyField(Person, to_field="person_name") job_id = ForeignKeyField(Job, to_field="job_id") start_date = DateField(formats='YYYY-MM-DD') end_date = DateField(formats='YYYY-MM-DD') salary = DecimalField(max_digits=7, decimal_places=2) duration_days = DecimalField(max_digits=7, decimal_places=0, null=True) LOGGER.info("Table defined successfully.")
class ChequeAccount(BaseModel): """ 支票账户类 """ id = CharField(primary_key=True) branchName = ForeignKeyField(Branch) accountBalance = FloatField() openTime = DateField() visitTime = DateField() creditLimit = FloatField() class Meta: tablename = 'chequeaccount'