# -*- coding: utf-8 -*- from __future__ import annotations from django.db import models from django.utils.translation import gettext_lazy as _ from hotpocket_backend.apps.core.models import Model class ActiveAssociationsManager(models.Manager): def get_queryset(self) -> models.QuerySet[Association]: return super().get_queryset().filter( deleted_at__isnull=True, ) class Association(Model): archived_at = models.DateTimeField( auto_now=False, auto_now_add=False, blank=True, null=True, default=None, db_index=True, editable=False, ) starred_at = models.DateTimeField( auto_now=False, auto_now_add=False, blank=True, null=True, default=None, db_index=True, editable=False, ) target_meta = models.JSONField( blank=True, null=False, default=dict, ) target_title = models.CharField( blank=True, null=True, default=None, db_index=True, ) target_description = models.CharField( blank=True, null=True, default=None, db_index=True, ) target = models.ForeignKey( 'saves.Save', blank=False, null=False, default=None, db_index=True, related_name='associations', on_delete=models.CASCADE, ) objects = models.Manager() active_objects = ActiveAssociationsManager() class Meta: verbose_name = _('Association') verbose_name_plural = _('Associations') def __str__(self) -> str: return f''