2019-10-18 07:05:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from common.mixins.models import CommonModelMixin
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ['FavoriteAsset']
|
|
|
|
|
|
|
|
|
|
|
|
class FavoriteAsset(CommonModelMixin):
|
|
|
|
user = models.ForeignKey('users.User', on_delete=models.CASCADE)
|
|
|
|
asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = ('user', 'asset')
|
|
|
|
|
|
|
|
@classmethod
|
2021-03-08 02:08:51 +00:00
|
|
|
def get_user_favorite_asset_ids(cls, user):
|
2019-10-18 07:05:45 +00:00
|
|
|
return cls.objects.filter(user=user).values_list('asset', flat=True)
|