# backend/formulas/models/favorite_formula.py
from django.db import models
from django.conf import settings
from formulas.models.formula import Formula

class FavoriteFormula(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    formula = models.ForeignKey(Formula, on_delete=models.CASCADE)
    added_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        unique_together = ('user', 'formula')
        verbose_name = "Ulubiony wzór"
        verbose_name_plural = "Ulubione wzory"

    def __str__(self):
        return f"{self.user.username} ❤️ {self.formula.code}"