from django.db import models
import uuid
def default_value():
    return {
        'ops': [
            {
                'parents': [],
                'parentsType': [],
                'linksText': [],
                'x': 0,
                'y': 0,
                'sizeX': 0,
                'sizeY': 0,
                'textContent': "",
                'id': 0,
            }
        ],
    }

class Mindmap(models.Model):

    class LevelStudied(models.TextChoices): # On définit une nouvelle classe à l'intérieur de la classe précédente
        MiddleSchool = 'MS'
        HighSchool = 'HS'
        LicenseDegree = 'LD'
        PreparatoryClass = 'PC'
        MasterDegree = 'MD'
        DoctorateDegree = 'DD'
        default = 'na'

    class SubjectStudied(models.TextChoices): # Celle-ci sert pour la liste des matières enseignées
        Mathematics = 'MA'
        Physics = 'PH'
        Biology = 'BI'
        English = 'EN'
        Spanish = 'SP'
        Frensh = 'FR'
        History = 'HI'
        Philosophy = 'PI'
        default = 'na'

    title = models.CharField(max_length=255, default='untitled')
    academicLevel = models.CharField(choices=LevelStudied.choices, max_length=3, default='na')
    subjectStudied = models.CharField(choices=SubjectStudied.choices, max_length=3, default='na')
    content = models.JSONField(default=default_value)
    creation_date = models.DateTimeField(auto_now_add=True)
    mdofication_date = models.DateTimeField(auto_now=True)
    publicIdentifier = models.UUIDField(unique=True, default=uuid.uuid4)
    user = models.ForeignKey('user.User', to_field='publicIdentifier', on_delete=models.CASCADE, related_name='mindmaps')

