feat: cycle favourites for user (#369)

* feat: cycle favourites for user

* chore: update nomenclature

* chore: update on nomenclature

* feat: add favorites for completed and current cycle endpoints
This commit is contained in:
pablohashescobar 2023-03-06 18:59:47 +05:30 committed by GitHub
parent 79d7b6fec3
commit cb8b6b43dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 166 additions and 13 deletions

View file

@ -39,7 +39,7 @@ from .social_connection import SocialLoginConnection
from .state import State
from .cycle import Cycle, CycleIssue
from .cycle import Cycle, CycleIssue, CycleFavorite
from .shortcut import Shortcut

View file

@ -7,7 +7,6 @@ from . import ProjectBaseModel
class Cycle(ProjectBaseModel):
name = models.CharField(max_length=255, verbose_name="Cycle Name")
description = models.TextField(verbose_name="Cycle Description", blank=True)
start_date = models.DateField(verbose_name="Start Date", blank=True, null=True)
@ -18,7 +17,6 @@ class Cycle(ProjectBaseModel):
related_name="owned_by_cycle",
)
class Meta:
verbose_name = "Cycle"
verbose_name_plural = "Cycles"
@ -50,3 +48,29 @@ class CycleIssue(ProjectBaseModel):
def __str__(self):
return f"{self.cycle}"
class CycleFavorite(ProjectBaseModel):
"""_summary_
CycleFavorite (model): To store all the cycle favorite of the user
"""
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="cycle_favorites",
)
cycle = models.ForeignKey(
"db.Cycle", on_delete=models.CASCADE, related_name="cycle_favorites"
)
class Meta:
unique_together = ["cycle", "user"]
verbose_name = "Cycle Favorite"
verbose_name_plural = "Cycle Favorites"
db_table = "cycle_favorites"
ordering = ("-created_at",)
def __str__(self):
"""Return user and the cycle"""
return f"{self.user.email} <{self.cycle.name}>"