mirror of https://github.com/jumpserver/jumpserver
20 lines
509 B
Python
20 lines
509 B
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
from django.db import models
|
|
|
|
from common.db.models import JMSBaseModel
|
|
|
|
__all__ = ['FavoriteAsset']
|
|
|
|
|
|
class FavoriteAsset(JMSBaseModel):
|
|
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
|
|
def get_user_favorite_asset_ids(cls, user):
|
|
return cls.objects.filter(user=user).values_list('asset', flat=True)
|