mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-06 01:49:56 +02:00
Activity stream representations for user and favorites
This commit is contained in:
parent
93e4a4f123
commit
691665e3cf
12 changed files with 159 additions and 0 deletions
|
@ -1,8 +1,10 @@
|
|||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
from funkwhale_api.music.models import Track
|
||||
|
||||
|
||||
class TrackFavorite(models.Model):
|
||||
creation_date = models.DateTimeField(default=timezone.now)
|
||||
user = models.ForeignKey(
|
||||
|
@ -18,3 +20,7 @@ class TrackFavorite(models.Model):
|
|||
def add(cls, track, user):
|
||||
favorite, created = cls.objects.get_or_create(user=user, track=track)
|
||||
return favorite
|
||||
|
||||
def get_activity_url(self):
|
||||
return '{}/favorites/tracks/{}'.format(
|
||||
self.user.get_activity_url(), self.pk)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue