class Article(models.Model): """A news article.""" _id = models.CharField("MongoDB ID", max_length=40, null=False, blank=False, primary_key=True) # scrape_id = models.CharField("Scrape ID",max_length=80, null=True, blank=True) headline = models.CharField("Headline", max_length=300, null=False, blank=False) date = models.DateField("Date", auto_now_add=True) source = models.CharField("Source", max_length=200, null=False, blank=False) url = models.URLField("URL", null=True) # word_count = models.IntegerField("Word Count", null=True, blank=True) text = models.TextField("Text", blank=True) subjectivity = models.DecimalField("Subjectivity", max_digits=25, decimal_places=25) polarity = models.DecimalField("Polarity", max_digits=25, decimal_places=25) disease = models.CharField("Disease", max_length=300, null=True, blank=True) def __str__(self): """Returns string representation of the model.""" return f"{self.source} | {self.disease} | {self.headline}"
class Eligibility(models.Model): tenth_marks = models.DecimalField(max_digits=5, decimal_places=3) diploma_12 = models.DecimalField(max_digits=5, decimal_places=3) engineering = models.DecimalField(max_digits=5, decimal_places=3) class Meta: abstract = True
class RoomBilling(models.Model): reservation_id = models.AutoField(primary_key=True) customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE, related_name='billing_customer') room_charge_id = models.ForeignKey(RoomCharges, on_delete=models.CASCADE, related_name='billing_charge') invoice_no = models.CharField(max_length=120, default='') billing_address1 = models.CharField(max_length=120) billing_address2 = models.CharField(max_length=120, blank=True, null=True) county = models.CharField(max_length=120) postal_code = models.CharField(max_length=20) country = models.CharField(max_length=120) total_discounts = models.DecimalField(max_digits=5, decimal_places=2, default='') total_invoice = models.DecimalField(max_digits=5, decimal_places=2, default='') def get_absolute_url(self): return reverse('HotelsAppCRUD:rooms_billing_index') def __str__(self): return "(%s) %s" % (self.reservation_id, self.invoice_no)
class Crypto_data(models.Model): _id = models.ObjectIdField() Name = models.CharField(max_length=50) Date = models.DateTimeField() Close = models.DecimalField(decimal_places=4,max_digits=20) High = models.DecimalField(decimal_places=4,max_digits=20) Low = models.DecimalField(decimal_places=4,max_digits=20) Open = models.DecimalField(decimal_places=4,max_digits=20) Volume = models.BigIntegerField()
class Api_data(models.Model): crypto_id = models.CharField(max_length=50) rank = models.IntegerField() symbol = models.CharField(max_length=50) name = models.CharField(max_length=50) supply = models.BigIntegerField() maxSupply = models.BigIntegerField() marketCapUsd = models.BigIntegerField() volumeUsd24Hr = models.BigIntegerField() priceUsd = models.DecimalField(decimal_places=4,max_digits=20) changePercent24Hr = models.DecimalField(decimal_places=2,max_digits=20) vwap24Hr = models.DecimalField(decimal_places=2,max_digits=20)
class Product(models.Model): category = models.ForeignKey('Category', null=True, blank=True, on_delete=models.SET_NULL) sku = models.CharField(max_length=254, null=True, blank=True) name = models.CharField(max_length=254) description = models.TextField() has_sizes = models.BooleanField(default=False, null=True, blank=True) price = models.DecimalField(max_digits=6, decimal_places=2) rating = models.DecimalField(max_digits=6, decimal_places=2, null=True, blank=True) image_url = models.URLField(max_length=1024, null=True, blank=True) image = models.ImageField(null=True, blank=True) def __str__(self): return self.name
class User_profile(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) email = models.CharField(max_length=100) password = models.CharField(max_length=100) confirm_password = models.CharField(max_length=100) address = models.CharField(max_length=100) city = models.CharField(max_length=100) country = models.CharField(max_length=30) zipcode = models.CharField(max_length=10) dob = models.DateField() gender = models.CharField(max_length=10) height = models.DecimalField(max_digits=10, decimal_places=3) weight = models.DecimalField(max_digits=10, decimal_places=3)
class CloudContract(models.Model): _id = models.ObjectIdField() name = models.CharField(max_length=128, default="KwaContract") image = models.CharField(max_length=128, null=True, blank=True) duration = models.IntegerField() price = models.DecimalField(max_digits=15, decimal_places=2) hashRate = models.DecimalField(max_digits=15, decimal_places=2) description = models.CharField(max_length=5000, null=True, blank=True) company = models.ForeignKey('cryptocloud.CloudCompany', on_delete=models.CASCADE, null=True) coin = models.ForeignKey('cryptocloud.Coin', on_delete=models.CASCADE, null=True)
class Sensores_data(models.Model): date_time = models.DateTimeField(auto_now_add=False, auto_now=True) name = models.CharField(max_length=50) actions = models.CharField(max_length=20) message = models.CharField(max_length=120) numero = models.DecimalField(decimal_places=4, max_digits=5)
class Drive(models.Model): Campus_choice = (('On', 'On'), ('Off', 'Off'), ('Pool', 'Pool')) _id = models.CharField(max_length=60, null=False, blank=False, primary_key=True, unique=True) company_name = models.CharField(max_length=50, null=False, blank=False) date = models.CharField(max_length=10, null=False, blank=False) time = models.CharField(max_length=15, null=False, blank=False) venue = models.CharField(max_length=100, blank=False, null=False) campus_type = models.CharField(max_length=10, choices=Campus_choice, default='On', null=False, blank=False) Computer = models.BooleanField(default=False) Civil = models.BooleanField(default=False) Mechanical = models.BooleanField(default=False) IT = models.BooleanField(default=False) Instrumentation = models.BooleanField(default=False) Production = models.BooleanField(default=False) ENTC = models.BooleanField(default=False) base_package = models.DecimalField(max_digits=8, decimal_places=3, blank=False, null=False) login_key = models.CharField(max_length=15, null=False, blank=False) rounds = models.ArrayModelField(model_container=Drive_Rounds) eligibility = models.ArrayModelField(model_container=Eligibility) eligible_student = models.ArrayModelField(model_container=Attendance) round1_student = models.ArrayModelField(model_container=Attendance) round2_student = models.ArrayModelField(model_container=Attendance) round3_student = models.ArrayModelField(model_container=Attendance) round4_student = models.ArrayModelField(model_container=Attendance) round5_student = models.ArrayModelField(model_container=Attendance) round6_student = models.ArrayModelField(model_container=Attendance) round7_student = models.ArrayModelField(model_container=Attendance) round8_student = models.ArrayModelField(model_container=Attendance) placed_student = models.ArrayModelField(model_container=Attendance)
class Bid(models.Model): """ Bid object. The criteria a buyer specifies for a swipe such that he/she is willing to purchase the swipe. """ BID_STATES = [ ( '0', 'Pending' ), # Doesn't meet minimum, sits in the queue until an eligible listing pops up ( '1', 'Accepted' ), # Pairing between buyer and seller has been made (either at the time of bid or after a swipe was created) ( '2', 'Confirmed' ), # Transaction has occured between buyer and seller, whether successful or refund-based ] bid_id = models.AutoField(primary_key=True) status = models.CharField(max_length=1, choices=BID_STATES, default=0) swipe = models.ForeignKey(Swipe, on_delete=models.CASCADE, null=True) buyer = models.ForeignKey(User, on_delete=models.DO_NOTHING) hall_id = models.ForeignKey(DiningHall, on_delete=models.DO_NOTHING) bid_price = models.DecimalField(max_digits=5, decimal_places=2) desired_time = models.TimeField(null=True) visibility = models.ListField( blank=True, null=True, default=[] ) # An array of JSON objects that contains intervals when this buyer wants the swipe
class Expense(models.Model): category = models.CharField(max_length=50) amunt = models.DecimalField(max_digits=5, decimal_places=2,blank=True,null=True) price = models.PositiveIntegerField(blank=True , null=True) array = models.ArrayField(model_container=ArrayFieldModel) embedded = models.EmbeddedField(model_container=EmbeddedFieldModel) imgs = models.JSONField(default=[])
class MenuItem(models.Model): name = models.CharField( null=False, max_length=50, validators=[ MinLengthValidator( limit_value=3, message="Name must be at least 3 characters long.", ), MaxLengthValidator( limit_value=50, message="Name must be at most 50 characters long.", ), RegexValidator( regex="^[A-Za-z0-9 //,'-]{3,50}$", message="Please insert a valid name.", ), ProhibitNullCharactersValidator(), ], ) vegan = models.BooleanField(null=False, default=False) price = models.DecimalField( max_digits=9, decimal_places=2, null=False, default=0, validators=[ MinValueValidator(limit_value=0, message="Please insert a non-negative number."), MaxValueValidator( limit_value=1_000_000, message="Price must not exceed $1 million.", ), ], )
class GenericModel(models.Model): big_int = models.BigIntegerField() bool = models.BooleanField() char = models.CharField(max_length=20) comma_int = models.CommaSeparatedIntegerField() date = models.DateField() date_time = models.DateTimeField() decimal = models.DecimalField(max_digits=10, decimal_places=5) email = models.EmailField() float = models.FloatField() integer = models.IntegerField() null_bool = models.NullBooleanField() pos_int = models.PositiveIntegerField() pos_small_int = models.PositiveSmallIntegerField() slug = models.SlugField() small_int = models.SmallIntegerField() text = models.TextField() time = models.TimeField() url = models.URLField() ip = models.GenericIPAddressField() uuid = models.UUIDField() # TODO: add these # basic_file = models.FileField() # image = models.ImageField() objects = models.DjongoManager()
class Room(models.Model): number = models.DecimalField(unique=True, primary_key=True) places = models.DecimalField() category = models.ForeignKey(Category, on_delete=models.CASCADE) reserved = models.EmbeddedModelField(model_container=ReservedDate, model_form_class=ReservedDateForm) description = models.TextField() price = models.DecimalField() img = models.ImageField() objects = models.DjongoManager() def __str__(self): return str(self.number) class Meta: abstract = True ordering = ["number"]
class Hotel(models.Model): hotel_id = models.AutoField(primary_key=True) name = models.CharField(max_length=60) description = models.CharField(max_length=120) star_rating = models.IntegerField() address1 = models.CharField(max_length=120) address2 = models.CharField(max_length=120, blank=True, null=True) county = models.CharField(max_length=120) postal_code = models.CharField(max_length=20) country = models.CharField(max_length=120) latitude = models.DecimalField(max_digits=9, decimal_places=7) longitude = models.DecimalField(max_digits=9, decimal_places=7) def get_absolute_url(self): return reverse('HotelsAppCRUD:hotel_index') def __str__(self): return "(%s) %s" % (self.hotel_id, self.name)
class Transaction(models.Model): """ Transaction object. Represents the agreement between seller and buyer for exchanging money for a swipe. """ t_id = models.AutoField(primary_key=True) sender = models.CharField(max_length=255) recipient = models.CharField(null=True, max_length=255) paid = models.DateTimeField(null=True) total = models.DecimalField(max_digits=5, decimal_places=2) details = models.CharField(max_length=255)
class Coin(models.Model): _id = models.ObjectIdField() name = models.CharField(max_length=128, default="KwaCoin") token = models.CharField(max_length=128, default="KwaToken") image = models.CharField(max_length=128, null=True, blank=True) algorithm = models.CharField(max_length=128, null=True, blank=True) website = models.CharField(max_length=128, null=True, blank=True) description = models.CharField(max_length=5000, null=True, blank=True) maxSupply = models.DecimalField(max_digits=15, decimal_places=2, default=0.00) blockTime = models.DecimalField(max_digits=15, decimal_places=2, default=0.00) blockReward = models.DecimalField(max_digits=15, decimal_places=2, default=0.00) startDate = models.DateField() coinGecko = models.CharField(max_length=128, null=True, blank=True)
class CreditBill(models.Model): max_digit = 8 decimal_place = 2 user = models.ForeignKey(User, on_delete=models.CASCADE) credit_name = models.ForeignKey(UserCredit, on_delete=models.CASCADE) # PREVIOUS BILL prev_bill = models.DecimalField(max_digits=max_digit, decimal_places=decimal_place, default=0.0) # CURRENT BILL crnt_bill = models.DecimalField(max_digits=max_digit, decimal_places=decimal_place, default=0.0) # UN-BILLED un_bill = models.DecimalField(max_digits=max_digit, decimal_places=decimal_place, default=0.0) # CURRENT BILL PAID paid_bill = models.DecimalField(max_digits=max_digit, decimal_places=decimal_place, default=0.0) # BILL DATE bill_date = models.DateField(auto_now=False, auto_now_add=False, default=now) objects = CreditBillManager() class Meta: verbose_name = "Credit Bill" verbose_name_plural = "Credit Bills" def __str__(self): return f'Bill: {self.crnt_bill}' def get_absolute_url(self): return reverse("credit-details", kwargs={"pk": self.pk})
class Info(models.Model): Date = models.DateTimeField() High = models.DecimalField() Low = models.DecimalField() Open = models.DecimalField() Close = models.DecimalField() Volume = models.DecimalField() Adj_Close = models.DecimalField() Daily_Returns = models.DecimalField() Daily_Log_Returns = models.DecimalField() class Meta: abstract = True
class OrderDetail(models.Model): id = models.AutoField(primary_key=True) order = models.ForeignKey(Order, on_delete=models.DO_NOTHING) product = models.ForeignKey(Product, on_delete=models.DO_NOTHING, null=False, blank=False) order_number = models.CharField(max_length=100,null=True,blank=True) payment_id = models.CharField(max_length=50,null=True,blank=True) price = models.DecimalField(max_digits=19, decimal_places=2) quatity = models.IntegerField() discount = models.DecimalField(decimal_places=2, max_digits=10) total = models.IntegerField() idsku = models.CharField(max_length=100,null=True,blank=True) size = models.CharField(max_length=3,choices=Available_Size) color = models.CharField(max_length=3,choices=Available_Color) fullfield = models.BooleanField(default=False) bill_date = models.DateField(default='') created_at = models.DateTimeField(auto_now=False, auto_now_add=True) updated_at = models.DateTimeField(auto_now=True, auto_now_add=False) def __str__(self): return self.order.order_number
class Reviews(noSQLModels.Model): def __str__(self): return self.review_title review_title = noSQLModels.CharField(max_length=30) user_name = noSQLModels.CharField(max_length=50) date_written = noSQLModels.DateTimeField('date written') review_text = noSQLModels.CharField(max_length=250) star_rating = noSQLModels.DecimalField(max_digits=2, decimal_places=1) class Meta: abstract = True
class Location(models.Model): """ Location object. Various locations are stored in this table, including those for dining halls, home locations of users, and (later) current locations of sellers """ loc_id = models.AutoField(primary_key=True) lat = models.DecimalField(max_digits=9, decimal_places=6) lng = models.DecimalField(max_digits=9, decimal_places=6) @staticmethod def distance(loc1, loc2): if loc1 is None or loc2 is None: return float("inf") assert type(loc1) == api.models.Location and type( loc2) == api.models.Location # From here, perform Haversine formula to determine the distance between the two location pairs p = 0.017453292519943295 # Pi/180, a magic number a = 0.5 - cos((loc2.lat - loc1.lat) * p) / 2 + cos(loc1.lat * p) * cos( loc2.lat * p) * (1 - cos((loc2.lng - loc1.lng) * p)) / 2 return 12742 * asin( sqrt(a)) # Yields distance between the two points in km
class RoomService(models.Model): service_id = models.AutoField(primary_key=True) service_description = models.CharField(max_length=120) service_price = models.DecimalField(max_digits=5, decimal_places=2, default='') def get_absolute_url(self): return reverse('HotelsAppCRUD:rooms_service_index') def __str__(self): return "(%s) %s" % (self.service_id, self.service_description)
class UserCredit(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) credit_name = models.CharField(max_length=150) credit_limit = models.DecimalField(max_digits=8, decimal_places=2, default=0.0) credit_intrest = models.DecimalField(max_digits=4, decimal_places=2, default=0.0) objects = UserCreditManager() class Meta: verbose_name = "User Credit" verbose_name_plural = "User Credits" ordering = ['credit_name'] def __str__(self): return self.credit_name def get_absolute_url(self): return reverse("credit-details", kwargs={"pk": self.pk})
class CurrencyContainer(models.Model): currency = models.ForeignKey(Currency, related_name='container', on_delete=models.CASCADE) balance = models.DecimalField(max_digits=20, decimal_places=2, default=Decimal('0.0')) account = models.ForeignKey(Account, related_name='currencies', on_delete=models.CASCADE) def __str__(self): return "Container de %s" % (self.currency.name)
class Recipe(models.Model): """Recipe object""" user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) title = models.CharField(max_length=255) time_minutes = models.IntegerField() price = models.DecimalField(max_digits=5, decimal_places=2) link = models.CharField(max_length=255, blank=True) ingredients = models.ManyToManyField('Ingredient') tags = models.ManyToManyField('Tag') def __str__(self): return self.title
class UserBudget(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) budget = models.DecimalField(max_digits=8, decimal_places=2) class Meta: verbose_name = 'User Budget' verbose_name_plural = 'User Budgets' def __str__(self): return f"Budget: {self.budget}" def get_absolute_url(self): return reverse("UserExpense_detail", kwargs={"pk": self.pk})
class Inmueble(models.Model): direccion = models.CharField(max_length=100, null=False) IDBarrio = models.ForeignKey(Barrio, null=False, on_delete=models.PROTECT) precio = models.DecimalField(max_digits=10, decimal_places=10, null=False) IDTipo_de_inmueble = models.ForeignKey(Tipo_de_inmueble, null=False, on_delete=models.PROTECT) IDTipo_de_oferta = models.ForeignKey(Tipo_de_oferta, null=False, on_delete=models.PROTECT) alcoba = models.IntegerField(null=False) baño = models.IntegerField(null=False) parqueadero = models.BooleanField(null=False) disponible = models.BooleanField(null=False)
class DataDiabetic(models.Model): patient_info = models.OneToOneField( DataPatinet, default=0, on_delete=models.CASCADE, primary_key=True, ) result = models.IntegerField() ai_score = models.DecimalField(default=0.0, max_digits=5, decimal_places=2) tested_on = models.DateField(max_length=50, null=True, blank=True) # datefield = datetime.date def __str__(self): return f"Diabetic Result: Severity {self.result} with AI score {self.ai_score}"