feat: add project to favourites (#352)
* feat: add project to favourites * feat: add project is_favourite attribute to list endpoints * refactor: updated destroy endpoint to send project_id * chore: nomenclature update
This commit is contained in:
parent
697e7f13b5
commit
689eaad0f0
7 changed files with 141 additions and 5 deletions
|
|
@ -16,6 +16,7 @@ from .project import (
|
|||
ProjectBaseModel,
|
||||
ProjectMemberInvite,
|
||||
ProjectIdentifier,
|
||||
ProjectFavorite,
|
||||
)
|
||||
|
||||
from .issue import (
|
||||
|
|
|
|||
|
|
@ -155,3 +155,22 @@ class ProjectIdentifier(AuditModel):
|
|||
verbose_name_plural = "Project Identifiers"
|
||||
db_table = "project_identifiers"
|
||||
ordering = ("-created_at",)
|
||||
|
||||
|
||||
class ProjectFavorite(ProjectBaseModel):
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="project_favorites",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
unique_together = ["project", "user"]
|
||||
verbose_name = "Project Favorite"
|
||||
verbose_name_plural = "Project Favorites"
|
||||
db_table = "project_favorites"
|
||||
ordering = ("-created_at",)
|
||||
|
||||
def __str__(self):
|
||||
"""Return user of the project"""
|
||||
return f"{self.user.email} <{self.project.name}>"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue