class User(db.Document): email = db.StringField() password = db.StringField() name = db.StringField() last_logged_in = db.DateTimeField() created_at = db.DateTimeField() user_type = db.IntField()
class Email(db.EmbeddedDocument): email_id = db.StringField(primary_key=True) email = db.StringField() is_primary = db.BooleanField(db_field="is_primary", default=False) created_at = db.DateTimeField(default=datetime.now()) updated_at = db.DateTimeField() deleted_at = db.DateTimeField()
class Maintenance(db.Document): cost = db.DecimalField() title = db.StringField() created_by = db.ReferenceField(User) created_at = db.DateTimeField() modified_at = db.DateTimeField() room_name = db.StringField() img_url = db.StringField()
class DetailTemps(db.Document): date = db.DateTimeField() description = db.StringField() heure = db.DateTimeField() jour = db.IntField() conversion = db.FloatField() temps_id = db.ReferenceField(Temps) ordre = db.IntField() parent = db.IntField()
class Customer(db.Document): name = db.StringField() email = db.StringField() facebook = db.StringField() phone = db.StringField() current = db.BooleanField() created_by = db.ReferenceField(User) created_at = db.DateTimeField() modified_at = db.DateTimeField()
class staffDetails(db.Document): staffId = db.StringField(unique=True) staffSSN = db.IntField(unique=True) staffName = db.StringField(max_length=50) staffPhone = db.IntField(max_length=10) staffDept = db.StringField() staffDob = db.DateTimeField() staffDoj = db.DateTimeField() staffAddress = db.StringField()
class Activity(db.Document): activity_id = db.IntField( unique=True ) activity_name = db.StringField( unique=True, max_length = 50 ) leader_id = db.IntField( required=True ) leader_name = db.StringField( max_length = 20) open_date = db.DateTimeField( default=datetime.utcnow ) start_date = db.DateTimeField( ) genre = db.StringField( max_length = 20 ) skills = db.StringField( max_length = 50 ) description = db.StringField( max_length = 200 )
class Event(db.Document): name = db.StringField(required=True) place = db.StringField(required=True) location = db.PointField(required=True) start_datetime = db.DateTimeField(required=True) end_datetime = db.DateTimeField(required=True) event_photo = db.StringField() description = db.StringField(min_length=50, required=True) host = db.ObjectIdField(required=True) cancel = db.BooleanField(default=False) attendees = db.ListField(db.ReferenceField(User))
class BaseDocument(db.Document): created_at = db.DateTimeField(verbose_name=u'Criado em', required=True) updated_at = db.DateTimeField(verbose_name=u'Atualizado em', required=True) meta = {'abstract': True} def save(self, *args, **kwargs): if not self.created_at: self.created_at = datetime.utcnow() self.updated_at = datetime.utcnow() return super(BaseDocument, self).save(*args, **kwargs)
class BaseDocument(db.Document): created_at = db.DateTimeField(required=True) updated_at = db.DateTimeField(required=True) meta = {'abstract': True} def save(self, *args, **kwargs): if not self.created_at: self.created_at = datetime.now() self.updated_at = datetime.now() return super(BaseDocument, self).save(*args, **kwargs)
class Account(db.Document): TYPE = (('S', 'Savings'), ('C', 'Current')) STATUS = (('UPDATED', 'UPDATED'), ('CREATED', 'CREATED'), ('DELETED', 'DELETED')) ws_cust_id = db.StringField() ws_acct_id = db.StringField(unique=True) ws_acct_type = db.StringField(max_length=3, choices=TYPE) ws_status = db.StringField(max_length=10, choices=STATUS) ws_message = db.StringField() ws_acct_balance = db.IntField(min_value=0) ws_acct_crdate = db.DateTimeField() ws_acct_lasttrdate = db.DateTimeField() ws_acct_duration = db.IntField(min_value=0)
class Room(db.Document): name = db.StringField() created_at = db.DateTimeField() modified_at = db.DateTimeField() building = db.StringField() is_available = db.BooleanField() room_number = db.StringField() current_booking = db.ReferenceField( Booking, reverse_delete_rule=mongoengine.NULLIFY) last_active = db.DateTimeField() maintenance_history = db.ListField( db.ReferenceField(Maintenance, reverse_delete_rule=mongoengine.PULL)) booking_history = db.ListField( db.ReferenceField(Booking, reverse_delete_rule=db.PULL))
class Booking(db.Document): customers = db.ListField( db.ReferenceField(Customer, reverse_delete_rule=mongoengine.PULL)) room_name = db.StringField() check_in = db.DateTimeField() check_out = db.DateTimeField() deposit = db.DecimalField() modified_at = db.DateTimeField() ppm = db.DecimalField() created_at = db.DateTimeField() created_by = db.ReferenceField(User) note = db.StringField() room_type = db.IntField() confirmed = db.BooleanField()
class Product(db.Document): code = db.StringField(max_length=60) name = db.StringField(max_length=60) price = db.FloatField() packing = db.StringField(max_length=60) description = db.StringField() created_at = db.DateTimeField(verbose_name=u'Created At', required=True) updated_at = db.DateTimeField(verbose_name=u'Updated At', required=True) def save(self, *args, **kwargs): if not self.created_at: self.created_at = datetime.datetime.now() self.updated_at = datetime.datetime.now() return super(Product, self).save(*args, **kwargs)
class GiftCard(db.Document): gift_card_id = db.StringField(db_field="gift_card_id", primary_key=True) gifter_customer = db.ReferenceField(Customer, db_field="gifter_customer_id") recipient_customer = db.ReferenceField(Customer, db_field="recipient_customer_id") original_balance_in_cents = db.IntField() current_balance_in_cents = db.IntField() created_at = db.DateTimeField(default=datetime.now()) updated_at = db.DateTimeField() voided_at = db.DateTimeField() def redeem(self, invoice): amount_to_apply = min( [invoice.get_subtotal_amount(), self.current_balance_in_cents]) invoice.gift_card_used_amount_in_cents += amount_to_apply invoice.save() GiftCardSpend(gift_card_spend_id=str(uuid.uuid4().int), gift_card=self, invoice=invoice, amount=amount_to_apply, remaining_balance=self.current_balance_in_cents - amount_to_apply).save() self.current_balance_in_cents -= amount_to_apply self.updated_at = datetime.now() self.save() @classmethod def get_active_giftcards(cls, customer): gift_cards = GiftCard.objects.filter( recipient_customer=customer, current_balance_in_cents__gt=0).all() for gift_card in gift_cards: yield gift_card def void(self): self.voided_at = datetime.now() self.updated_at = datetime.now() self.current_balance_in_cents = 0 self.save() meta = { 'indexes': [('gifter_customer', ), ('recipient_customer', ), ('gift_card_id', )] }
class CreditRedemption(db.Document): credit_redemption_id = db.StringField(db_field="credit_redemption_id", primary_key=True) credit = db.ReferenceField(Credit, db_field="credit_id") invoice = db.ReferenceField(Invoice, db_field="invoice_id") amount = db.IntField() remaining_balance = db.IntField() created_at = db.DateTimeField(default=datetime.now())
class BesoinFinancier(db.Document): commande = db.StringField() fournisseur = db.StringField() montant = db.FloatField() avance = db.FloatField() paye = db.FloatField() date_echeance = db.DateTimeField() projet_id = db.ReferenceField(Projet) attente = db.BooleanField(default=True) rejet = db.BooleanField(default=False) parent = db.ReferenceField('self') last_child = db.BooleanField(default=False) updated = db.ListField(db.EmbeddedDocumentField(Update_Besoin)) def child(self): childs = BesoinFinancier.objects(parent=self.id) return childs def lasted_child(self): last = BesoinFinancier.objects(Q(parent=self.id) & Q(last_child=True)).first() return last def notified(self): data = [] for notifie in self.updated: if notifie.notified: data.append(notifie) return data
class Articles(db.Document): url = db.StringField(max_length=100, unique=True, required=True) title = db.StringField(max_length=200) newspaper_title = db.StringField(max_length=200) topic_id = db.IntField() channel_id = db.IntField() published_date = db.DateTimeField(default=datetime.now) newspaper_published_date = db.DateTimeField(default=datetime.now) description = db.StringField() newspaper_topic = db.StringField(max_length=50) newspaper_summary = db.StringField() newspaper_text = db.StringField() newspaper_authors = db.ListField(db.StringField(max_length=20)) last_crawled = db.DateTimeField(default=datetime.now) newspaper_tags = db.ListField(db.StringField(max_length=20)) newspaper_keywords = db.ListField(db.StringField(max_length=20))
class CartItem(db.Document): cart_item_id = db.StringField(db_field="cart_item_id", primary_key=True) product_id = db.ReferenceField(Product, db_field="product_id") cart_id = db.ReferenceField(Cart, db_field="cart_id") quantity = db.IntField() added_at = db.DateTimeField(default=datetime.now()) removed_at = db.DateTimeField() invoice_created_at = db.DateTimeField() meta = {'indexes': [("cart_id", "removed_at")]} def remove_from_cart(self): self.removed_at = datetime.now() self.product_id.inventory += self.quantity self.product_id.save() self.save()
class User(db.Document): name = db.StringField(required=True) email = db.StringField(required=True, unique=True) password = db.StringField(required=True) created = db.DateTimeField(default=datetime.datetime.now) bio = db.StringField(max_length=200) profile_image = db.StringField()
class Pet(db.Document): external_id = db.StringField(db_field="ei") name = db.StringField(db_field="n") species = db.StringField(db_field="s") breed = db.StringField(db_field="b") age = db.IntField(db_field="a") store = db.ReferenceField(Store, db_field="st") price = db.DecimalField(db_field="p", precision=2, rounding='ROUND_HALF_UP') sold = db.BooleanField(db_field="sl", default=False) received_date = db.DateTimeField(db_field="rd") sold_date = db.DateTimeField(db_field="sd") live = db.BooleanField(db_field="l", default=True) meta = { 'indexes': [('external_id', 'live'), ('species', 'live'), ('store', 'live')] }
class BehaviorDiffDB(db.Document): elements_added = db.ListField(db.ReferenceField(ElementDB), db_field="elements_added", default=[]) # pylint: disable=no-member elements_removed = db.ListField(db.ReferenceField(ElementDB), db_field="elements_removed", default=[]) # pylint: disable=no-member created = db.DateTimeField(db_field="created", required=True, default=datetime.utcnow) # pylint: disable=no-member """ Returns the diff object for this data. Since the diff is only manipulated in the Application Level, all the data returned are AO """ def to_obj(self): return { "created": self.created, "diff": { "added": set(elt.to_obj() for elt in self.elements_added), "removed": set(elt.to_obj() for elt in self.elements_removed) } } def to_json(self): return { "created": self.created, "diff": { "added": set(elt.to_json() for elt in self.elements_added), "removed": set(elt.to_json() for elt in self.elements_removed) } } def __repr__(self): return f"Added: {self.elements_added} ||| Removed: {self.elements_removed}"
class DetailFrais(db.Document): date = db.DateTimeField() description = db.StringField() montant = db.FloatField() detail_fdt = db.ReferenceField(DetailTemps) temps_id = db.ReferenceField(Temps) frais_projet_id = db.ReferenceField(FraisProjet)
class Target(db.EmbeddedDocument): """ Target Stats """ target_account_id = db.StringField() target_account_name = db.StringField() last_update = db.DateTimeField()
class GiftCardSpend(db.Document): gift_card_spend_id = db.StringField(db_field="gift_card_spend_id", primary_key=True) gift_card = db.ReferenceField(GiftCard, db_field="gift_card_id") invoice = db.ReferenceField(Invoice, db_field="invoice_id") amount = db.DecimalField() remaining_balance = db.DecimalField() created_at = db.DateTimeField(default=datetime.now())
class Transaction(db.Document): transaction_id = db.IntField(unique=True) user_id = db.IntField(unique=False) transaction_type = db.StringField(max_length=10) currency_symbol = db.StringField(max_length=30) amount = db.FloatField() value = db.FloatField() date = db.DateTimeField()
class User(db.Document): email = db.EmailField(required=True, unique=True) alias = db.StringField(required=True, unique=True) password = db.StringField(min_length=8, required=True) emailVerified = db.BooleanField(default=False) lastLogin = db.DateTimeField() allowTracking = db.BooleanField(default=False) isMod = db.BooleanField(default=False)
class dbtrip(db.Document): homeLocation = db.StringField() earliestStart = db.DateTimeField() latestStart = db.DateTimeField() latestReturn = db.DateTimeField() des1 = db.StringField() min_stay1 = db.IntField() max_stay1 = db.IntField() des2 = db.StringField() min_stay2 = db.IntField() max_stay2 = db.IntField() des3 = db.StringField() min_stay3 = db.IntField() max_stay3 = db.IntField() des4 = db.StringField() min_stay4 = db.IntField() max_stay4 = db.IntField()
class Post(db.Document): post_id = db.IntField(unique=True) title = db.StringField(max_length=50) teaser = db.StringField(max_length=500) body = db.ListField() date = db.DateTimeField() heading = db.ListField() image_description = db.StringField(max_length=50)
class Address(db.Document): address_id = db.StringField(db_field="address_id", primary_key=True, default=str(uuid.uuid4().int)) customer_id = db.ReferenceField(Customer, db_field="customer_id") street = db.StringField(db_field="street") city = db.StringField(db_field="city") zip = db.StringField(db_field="zip") state = db.StringField(db_field="state") country = db.StringField(db_field="country") is_primary = db.BooleanField(db_field="is_primary", default=False) created_at = db.DateTimeField(default=datetime.now()) updated_at = db.DateTimeField() deleted_at = db.DateTimeField() def make_primary(self): """ marks the address as primary. unmarks the old primary address :return: address obj """ old_primary_address = Address.objects.filter( customer_id=self.customer_id, is_primary=True).first() if old_primary_address: old_primary_address.is_primary = False old_primary_address.updated_at = datetime.now() old_primary_address.save() self.is_primary = True self.updated_at = datetime.now() self.save() def delete(self): """ marks an address as deleted :return: null """ self.deleted_at = datetime.now() self.updated_at = datetime.now() self.is_primary = False self.save() meta = {'indexes': [('customer_id', ), ('address_id', )]}