hotpocket/services/backend/hotpocket_backend/apps/saves/models/association.py
Tomek Wójcik b4338e2769
Some checks failed
CI / Checks (push) Failing after 13m2s
Release v1.0.0
2025-08-20 21:00:50 +02:00

73 lines
1.6 KiB
Python

# -*- 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'<Association pk={self.pk}>'