30 lines
995 B
Python
30 lines
995 B
Python
# apps/settingsapp/models.py
|
|
from django.db import models
|
|
from django.core.exceptions import ValidationError
|
|
|
|
class GradingSettings(models.Model):
|
|
# NOTAS
|
|
report_weight = models.FloatField(default=2) # Entregable
|
|
presentation_weight = models.FloatField(default=1) # Presentación
|
|
objective_weight = models.FloatField(default=3) # Objetivo max
|
|
|
|
# SIMILITUD
|
|
R_weight = models.FloatField(default=1)
|
|
L_weight = models.FloatField(default=1)
|
|
Ph_weight = models.FloatField(default=1)
|
|
Pcu_weight= models.FloatField(default=1)
|
|
|
|
def clean(self):
|
|
if GradingSettings.objects.exclude(pk=self.pk).exists():
|
|
raise ValidationError("Solo puede existir un GradingSettings")
|
|
|
|
def save(self, *args, **kwargs):
|
|
self.full_clean()
|
|
super().save(*args, **kwargs)
|
|
|
|
@classmethod
|
|
def get(cls):
|
|
# devuelve la única instancia (la crea si no existe)
|
|
obj, _ = cls.objects.get_or_create(pk=1)
|
|
return obj
|