1
0

models.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. from django.db import models
  2. from django.core.validators import validate_unicode_slug, MaxLengthValidator#, MaxValueValidator, URLValidator
  3. # Create your models here.
  4. class Event(models.Model):
  5. slug = models.SlugField(
  6. db_index=True,
  7. unique=True,
  8. validators=[validate_unicode_slug],
  9. )
  10. name = models.CharField(
  11. max_length=50,
  12. validators=[MaxLengthValidator(50)],
  13. )
  14. description = models.CharField(
  15. null=True,
  16. blank=True,
  17. max_length=200,
  18. validators=[MaxLengthValidator(200)],
  19. )
  20. location = models.ForeignKey(
  21. 'Location',
  22. on_delete=models.PROTECT,
  23. )
  24. doors_open = models.DateTimeField(
  25. null=True,
  26. blank=True,
  27. )
  28. doors_close = models.DateTimeField(
  29. null=True,
  30. blank=True,
  31. )
  32. price = models.DecimalField(
  33. decimal_places=2,
  34. max_digits=5,
  35. )
  36. wardrobe = models.DecimalField(
  37. null=True,
  38. default=None,
  39. decimal_places=2,
  40. max_digits=4,
  41. )
  42. wardrobe_guarded = models.BooleanField(
  43. default=False
  44. )
  45. dresscode = models.CharField(
  46. max_length=50,
  47. validators=[MaxLengthValidator(50)],
  48. )
  49. #class Meta:
  50. # ordering = ['doors_open']
  51. def __str__(self):
  52. return self.name
  53. class Location(models.Model):
  54. name = models.CharField(
  55. max_length=50,
  56. validators=[MaxLengthValidator(50)],
  57. )
  58. venue_type = models.CharField(
  59. max_length=30,
  60. validators=[MaxLengthValidator(30)],
  61. )
  62. street = models.CharField(
  63. max_length=50,
  64. validators=[MaxLengthValidator(50)],
  65. )
  66. housenumber = models.CharField(
  67. max_length=10,
  68. validators=[MaxLengthValidator(10)],
  69. )
  70. city = models.CharField(
  71. max_length=30,
  72. validators=[MaxLengthValidator(30)],
  73. )
  74. areacode = models.CharField(
  75. null=True,
  76. blank=True,
  77. max_length=10,
  78. validators=[MaxLengthValidator(10)],
  79. )
  80. free_parking = models.PositiveSmallIntegerField(
  81. default=False,
  82. )
  83. class Meta:
  84. #db_table = 'app_version'
  85. constraints = [
  86. models.UniqueConstraint(fields=['street', 'housenumber'], name='unique location')
  87. ]
  88. ordering = ['name']
  89. def __str__(self):
  90. return self.name
  91. class Activity(models.Model):
  92. event = models.ForeignKey(
  93. 'Event',
  94. on_delete=models.CASCADE,
  95. )
  96. area = models.ForeignKey(
  97. 'Area',
  98. on_delete=models.CASCADE,
  99. )
  100. name = models.CharField(
  101. null=True,
  102. blank=True,
  103. max_length=50,
  104. default='Social',
  105. validators=[MaxLengthValidator(50)],
  106. )
  107. description = models.CharField(
  108. null=True,
  109. blank=True,
  110. max_length=200,
  111. validators=[MaxLengthValidator(200)],
  112. )
  113. TYPE_CHOICES = [
  114. ('Dance party',
  115. (
  116. ('sc', 'Social'),
  117. ('gl', 'Gala'),
  118. )
  119. ),
  120. ('ws', 'Workshop'),
  121. ('sh', 'Show'),
  122. ('cl', 'Class'),
  123. ('br', 'Break'),
  124. ('ot', 'Other'),
  125. ]
  126. type = models.CharField(
  127. max_length=2,
  128. choices=TYPE_CHOICES,
  129. default='sc',
  130. validators=[MaxLengthValidator(2)],
  131. )
  132. start = models.DateTimeField()
  133. end = models.DateTimeField()
  134. artist = models.CharField(
  135. null=True,
  136. blank=True,
  137. max_length=50,
  138. validators=[MaxLengthValidator(50)],
  139. )
  140. #class Meta:
  141. # ordering = ['name']
  142. def __str__(self):
  143. return self.name
  144. class Area(models.Model):
  145. name = models.CharField(
  146. max_length=50,
  147. default='Main',
  148. validators=[MaxLengthValidator(50)],
  149. )
  150. def __str__(self):
  151. return self.name