class DailyFollowUp(AutoOneToOneModel(Presence, attr="presence"), TimeStampedModel): """ Model for DailyFollowUp """ important = models.BooleanField(_("Important"), default=False) comment = models.TextField(_("Comment"), blank=True, null=True) lotions = models.ManyToManyField( to="Lotion", verbose_name=_("Lotions"), through="LotionDailyFollowUp", through_fields=("daily_follow_up", "lotion") ) medications = models.ManyToManyField( to="Medication", verbose_name=_("Medications"), through="DailyFollowUpToMedication", through_fields=("daily_follow_up", "medication") ) activities = models.ManyToManyField( to="TypeActivity", verbose_name=_("Activities"), through="Activity", through_fields=("daily_follow_up", "type_activity") ) class Meta: ordering = ("presence",) verbose_name = _("Daily follow-up") verbose_name_plural = _("Daily follow-ups") def __str__(self): return _("Daily follow-up: {} - {}").format(self.presence.date, self.presence.child.full_name)
class Portfolio(AutoOneToOneModel(User)): # User_id & Portfolio auto added when user created trade_id = models.ManyToManyField(Trade, related_name='portfolio', blank=True) investment_id = models.ManyToManyField(Investment, related_name='portfolio', blank=True)
class Profile(AutoOneToOneModel(User)): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) imagefile = models.ImageField(upload_to='images/', null=True, blank=True) phonenumber = PhoneField(null=True, blank=True) major = models.CharField(max_length=50, null=True, blank=True) year = models.IntegerField(null=True, blank=True, validators=[MinValueValidator(0)]) def __str__(self): return f'{self.user.first_name} {self.user.last_name}'
class Parent(AutoOneToOneModel(User)): """Obiekt Parent jest tworzony automatycznie. Powstaje podczas rejestracji nowego użytkownika. Po zalaoganiu neleży zaktualizować dane rodzica. Modułu AutoOneToOneModel nie ma w standardzie trzeb go zainstalować pip install django-auto-one-to-one """ first_name = models.CharField(max_length=64, null=True) last_name = models.CharField(max_length=64, null=True) email = models.CharField(max_length=64, null=True) create_date = models.DateTimeField(auto_now_add=True)
class UserData(AutoOneToOneModel(User, related_name='profile')): group = models.ForeignKey( 'groups.Group', related_name='users', ) def save(self, *args, **kwargs): # Cannot use default= as the check framework evaluates them before the # database is guaranteed to be consistent. if self.group_id is None: self.group = get_default_group() super(UserData, self).save(*args, **kwargs)
class MealDailyFollowUp(AutoOneToOneModel(DailyFollowUp, attr="daily_follow_up"), TimeStampedModel): """ Model for MealDailyFollowUp """ MEAL_QUALITY_CHOICES = Choices( ("", "question.png"), ("very_good", "miao.png"), ("good", "smile.png"), ("nothing", "nothing.png"), ) snack_meals = models.ManyToManyField( to="Meal", verbose_name=_("Snack meals"), related_name="snack_meals", blank=True, ) snack_time = models.TimeField(_("Snack time"), blank=True, null=True) snack_quality = models.CharField(_("Snack quality"), choices=MEAL_QUALITY_CHOICES, max_length=10, blank=True, null=True) lunch_meals = models.ManyToManyField( to="Meal", verbose_name=_("Lunch meals"), related_name="lunch_meals", blank=True, ) lunch_time = models.TimeField(_("Lunch time"), blank=True, null=True) lunch_quality = models.CharField(_("Lunch quality"), choices=MEAL_QUALITY_CHOICES, max_length=10, blank=True, null=True) afternoon_snack_meals = models.ManyToManyField( to="Meal", verbose_name=_("Afternoon snack meals"), related_name="afternoon_snack_meals", blank=True, ) afternoon_snack_time = models.TimeField(_("Afternoon snack time"), blank=True, null=True) afternoon_snack_quality = models.CharField(_("Afternoon snack quality"), choices=MEAL_QUALITY_CHOICES, max_length=10, blank=True, null=True) comment = models.TextField(_("Comment"), blank=True, null=True) class Meta: ordering = ("daily_follow_up",) verbose_name = _("Meal daily follow-up") verbose_name_plural = _("Meal daily follow-ups") def __str__(self): return _("Meal: {}").format(self.daily_follow_up)
class Billing(AutoOneToOneModel(Group)): stripe_customer_ident = models.CharField(unique=True, max_length=255) plan = models.CharField( choices=sorted((x.value, x.display) for x in PLANS.values()), max_length=40, ) def get_plan_object(self): return PLANS[self.plan] def get_stripe_customer(self): return stripe.Customer.retrieve(self.stripe_customer_ident) def sync(self): customer = self.get_stripe_customer() for x in customer.subscriptions.all(count=1).data: self.plan = x.plan.id self.save(update_fields=('plan', ))
class StoreInfo(AutoOneToOneModel(Business)): phoneNumber = PhoneField(null=True, E164_only=True, help_text='Store phone number.', verbose_name='Contact Number') # phone number of the business website = models.URLField(null=True, blank=True, verbose_name="Website", help_text="Store website.") # if the business has a website add the home screen here timeOpen = models.TimeField( null=True, help_text="What times does the store open?", verbose_name="Opening Time. In 24 hour time. Ex: 6:30 am is 06:30:00") # time the store opens timeClose = models.TimeField( null=True, help_text="What times does the store close?", verbose_name="Closing Time. In 24 hour time. Ex: 7:45 pm is 19:45:00") # time the store closes ordering = models.TextField( null=True, max_length=250, help_text= "How can customers order products -i.e. online, phone, etc. 250 characters max", verbose_name="How Can Customers Order") # types or ordering allowed inStorePickUp = models.BooleanField( null=True, help_text= "Can customer pick up in store? (check for yes, leave blank for no).", verbose_name="In store pickup") # is in store pick up allowed deliveryOption = models.BooleanField( null=True, help_text= "Can customers have items delivered via mail, driver, etc - i.e. someway the ordered item will arrive at their home (check for yes, leave blank for no).", verbose_name="Delivery Available") # is a delivery option available specialNotes = models.TextField( blank=True, null=True, max_length=250, verbose_name="Special Notes", help_text="Additional details people should know? 250 characters max.", default=None) # extra details people should know about ownerMessage = models.TextField( blank=True, null=True, max_length=250, help_text= "If the owner wants to say something quote then here. 250 characters max.", verbose_name="Owner Message") # any extra that the owner would like to add about their business createdBy = models.ForeignKey(User, null=True, on_delete=models.SET_NULL, default=None, blank=True, verbose_name="Entry created by", help_text="User that created this entry", related_name="Creating_User") # person who created this entry approvedBy = models.ForeignKey( User, null=True, on_delete=models.SET_NULL, default=None, blank=True, verbose_name="Entry approved by", help_text="Admin that approved for publishing", related_name="Approving_User") # admin who approved this info before going out lastUpdatedDate = models.DateTimeField(default=timezone.now, verbose_name="Last updated") # time of last update creationDate = models.DateTimeField(auto_now_add=True, verbose_name="Date Created") # when this entry was first created def get_absolute_url(self): return reverse('teamMembers_viewBusinesses')
class Reception(AutoOneToOneModel(DailyFollowUp, attr="daily_follow_up"), TimeStampedModel): """ Model for Reception """ SLEEP_CHOICES = Choices( ('very_good', 'miao.png'), ("good", "smile.png"), ("bad", "spook.png"), ) BREAKFAST_CHOICES = Choices( ('very_good', 'miao.png'), ('good', 'smile.png'), ('nothing', 'nothing.png') ) CONDITION_CHOICES = Choices( ("very_good", "miao.png"), ("good", "smile.png"), ("sick", "spook.png") ) FEVER_CHOICES = Choices( ("no", _("No")), ("37", "37"), ("37.5", "37.5"), ("38", "38"), ("38.5", "38.5"), ("39", "39"), ("39.5", "39.5"), ("40", "40") ) SICK_CHOICES = Choices( ("no", _("No")), ("gastroenteritis", _("Gastroenteritis")), ("conjunctivitis", _("Conjunctivitis")), ("cough", _("Cough")), ("cold", _("Cold")) ) wake_up_time = models.TimeField(verbose_name=_("Wake up time"), choices=range_time(3, 15, 5, 00), null=True, blank=True) sleep = models.CharField(choices=SLEEP_CHOICES, verbose_name=_("Sleep"), max_length=10, null=True, blank=False, default=SLEEP_CHOICES.very_good) breakfast = models.CharField(choices=BREAKFAST_CHOICES, verbose_name=_("Breakfast"), max_length=20, null=True, blank=False, default=BREAKFAST_CHOICES.very_good) breakfast_time = models.TimeField(verbose_name=_("Breakfast time"), null=True, blank=True, ) condition = models.CharField(verbose_name=_("Condition"), choices=CONDITION_CHOICES, max_length=10, null=True, blank=False, default=CONDITION_CHOICES.very_good) fever = models.CharField(verbose_name=_("Fever"), choices=FEVER_CHOICES, max_length=10, null=True, blank=False, default=FEVER_CHOICES.no) sick = models.CharField(verbose_name=_("Sick"), choices=SICK_CHOICES, max_length=25, null=True, blank=False, default=SICK_CHOICES.no) comment = models.TextField(verbose_name=_("Comment"), null=True, blank=True) class Meta: ordering = ('daily_follow_up',) verbose_name = _('Reception') verbose_name_plural = _('Receptions') def __str__(self): return _("Reception: {}").format(self.daily_follow_up)
class PlayerList(AutoOneToOneModel(LongGame)): long_game = models.OneToOneField(LongGame, primary_key=True, max_length=7, on_delete=models.CASCADE, editable=False) def __str__(self): return "PlayerList for " + str(self.long_game)
class UserScores(AutoOneToOneModel(User, related_name='user_id')): score = models.PositiveIntegerField(default=0) def __str__(self): return str(self.score)
class Brim(AutoOneToOneModel(Hat)): pass
class MatchStat(AutoOneToOneModel(Match)): match = models.ForeignKey(Match, on_delete=models.PROTECT) host_score = models.IntegerField(blank=True, default=0) away_score = models.IntegerField(blank=True, default=0)