workouttest_backoffice/aitrainer_backoffice/aitrainer_backoffice/models.py
2020-11-06 07:42:30 +01:00

189 lines
6.9 KiB
Python

from django.db import models
from django.utils.translation import ugettext_lazy as _
class ExerciseTree(models.Model):
tree_id = models.AutoField(primary_key=True)
parent_id = models.IntegerField(help_text='This is the parent menu ID. 0 if it is on the top of the tree')
name = models.CharField(max_length=100, help_text='The name should be in English here')
image_url = models.ImageField(upload_to='images/', help_text='The menu image size is 1366x768')
active = models.BooleanField(default=0, blank=True, null=True)
class Meta:
db_table = 'exercise_tree'
verbose_name = _("Exercise Tree")
verbose_name_plural = _("Exercise Tree Items")
def __str__(self):
return self.name
class ExerciseType(models.Model):
class UnitTypes(models.TextChoices):
REPEAT = 'repeat'
SECOND = 'second'
MINUTE = 'minute'
METER = 'meter'
CM = 'centimeter'
PERCENT = 'percent'
CALORIES = 'calories'
KG = 'kilogram'
exercise_type_id = models.AutoField(primary_key=True)
tree = models.ForeignKey(ExerciseTree, on_delete=models.CASCADE)
name = models.CharField(max_length=100, help_text='The name should be in English here')
description = models.TextField(max_length=1000, blank=True, null=True, help_text='The description should be in '
'English here')
unit = models.CharField(choices=UnitTypes.choices, default=UnitTypes.REPEAT, max_length=50, blank=True, null=True)
unit_quantity = models.BooleanField(default=0, blank=True, null=True)
unit_quantity_unit = models.CharField(choices=UnitTypes.choices, default=UnitTypes.KG, max_length=50, blank=True,
null=True)
active = models.BooleanField(default=0, blank=True, null=True)
base = models.BooleanField(default=0, blank=True, null=True)
class Meta:
db_table = 'exercise_type'
verbose_name = _("Exercise")
verbose_name_plural = _("Exercises")
def __str__(self):
return self.name
class ExerciseTypeImage(models.Model):
class ImageTypes(models.TextChoices):
IMAGE = 'image'
VIDEO = 'video'
MENU = 'menu'
image_id = models.AutoField(primary_key=True)
exercise_type = models.ForeignKey(ExerciseType, on_delete=models.CASCADE)
name = models.CharField(max_length=50, blank=True, null=True)
type = models.CharField(choices=ImageTypes.choices, default=ImageTypes.IMAGE, max_length=50, blank=True, null=True)
url = models.ImageField(upload_to='images/', help_text='The menu image size is 1366x768')
class Meta:
db_table = 'exercise_type_image'
verbose_name = _("Image")
verbose_name_plural = _("Images")
def __str__(self):
return self.name
class LanguageTypes(models.TextChoices):
EN = "en"
HU = "hu"
class ExerciseTypeTranslation(models.Model):
translation_id = models.AutoField(primary_key=True)
exercise_type = models.ForeignKey(ExerciseType, on_delete=models.CASCADE)
language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU)
name = models.CharField(max_length=100)
description = models.TextField(max_length=1000, blank=True, null=True)
class Meta:
db_table = 'exercise_type_translation'
verbose_name = _("Translation")
verbose_name_plural = _("Translations")
def __str__(self):
return self.name
class ExerciseTreeTranslation(models.Model):
translation_id = models.AutoField(primary_key=True)
tree = models.ForeignKey(ExerciseTree, on_delete=models.CASCADE)
language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU)
name = models.CharField(max_length=100)
class Meta:
db_table = 'exercise_tree_translation'
verbose_name = _("Translation")
verbose_name_plural = _("Translations")
def __str__(self):
return self.name
class ExercisePlan(models.Model):
exercise_plan_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, help_text='The name should be in English here')
description = models.TextField(max_length=1000, blank=True, null=True, help_text='The description should be in '
'English here')
class Meta:
db_table = 'exercise_plan'
verbose_name = _("Exercise Plan")
verbose_name_plural = _("Exercise Plans")
def __str__(self):
return self.name
class ExercisePlanTranslation(models.Model):
translation_id = models.AutoField(primary_key=True)
exercise_plan = models.ForeignKey(ExercisePlan, on_delete=models.CASCADE)
language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU)
name = models.CharField(max_length=100)
description = models.TextField(max_length=1000, blank=True, null=True)
class Meta:
db_table = 'exercise_plan_translation'
verbose_name = _("Translation")
verbose_name_plural = _("Translations")
def __str__(self):
return self.name
class ExercisePlanDetail(models.Model):
exercise_plan_detail_id = models.AutoField(primary_key=True)
exercise_plan = models.ForeignKey(ExercisePlan, on_delete=models.CASCADE)
exercise_type = models.ForeignKey(ExerciseType, on_delete=models.CASCADE)
serie = models.IntegerField()
repeat = models.IntegerField()
weight_equation = models.CharField(max_length=100)
class Meta:
db_table = 'exercise_plan_detail'
verbose_name = _("Exercise Plan Detail")
verbose_name_plural = _("Exercise Plan Details")
class ProductTypes(models.TextChoices):
SUBS = "subscription"
IN_APP_CURR = "in-app-currency"
class Product(models.Model):
product_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=50)
description = models.TextField(max_length=1000, blank=True, null=True)
type = models.CharField(max_length=15, choices=ProductTypes.choices, default=ProductTypes.SUBS)
valid_from = models.DateField(blank=True, null=True)
valid_to = models.DateField(blank=True, null=True)
class Meta:
db_table = 'product'
verbose_name = _("Product")
verbose_name_plural = _("Products")
def __str__(self):
return self.name
class Purchase(models.Model):
purchase_id = models.AutoField(primary_key=True)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
customer_id = models.IntegerField()
date_add = models.DateField(blank=True, null=True)
purchase_sum = models.DecimalField(decimal_places=2, max_digits=7)
currency = models.CharField(max_length=3)
class Meta:
db_table = 'purchase'
verbose_name = _("Purchase")
verbose_name_plural = _("Purchases")