33 lines
954 B
Python
33 lines
954 B
Python
from django.db import models
|
|
|
|
|
|
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")],
|
|
)
|