2023-09-10 15:32:07 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2023-09-12 15:07:47 +00:00
|
|
|
|
|
|
|
class Level(models.Model):
|
|
|
|
level_number = models.IntegerField()
|
|
|
|
level_string = models.CharField(max_length=50)
|
|
|
|
|
|
|
|
|
|
|
|
class Word(models.Model):
|
|
|
|
word = models.CharField(max_length=50)
|
|
|
|
definition = models.CharField(max_length=255)
|
|
|
|
level = models.ForeignKey(Level, on_delete=models.CASCADE, related_name="words")
|
|
|
|
|
|
|
|
|
|
|
|
class Grid(models.Model):
|
|
|
|
level = models.ForeignKey(Level, on_delete=models.CASCADE, related_name="grids")
|
|
|
|
words = models.ManyToManyField(Word, through="Placement")
|
|
|
|
|
|
|
|
|
|
|
|
class Direction:
|
|
|
|
RIGHT = 1
|
|
|
|
BOTTOM = 2
|
|
|
|
|
|
|
|
|
|
|
|
class Placement(models.Model):
|
|
|
|
word = models.ForeignKey(Word, on_delete=models.CASCADE)
|
|
|
|
grid = models.ForeignKey(Grid, on_delete=models.CASCADE)
|
|
|
|
coordinates_first_letter = models.CharField(max_length=10)
|
|
|
|
direction = models.SmallIntegerField(
|
|
|
|
default=Direction.RIGHT,
|
|
|
|
choices=[(Direction.RIGHT, "Right"), (Direction.BOTTOM, "Bottom")],
|
|
|
|
)
|