mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
665 B
25 lines
665 B
# -*- coding: utf-8 -*-
|
|
#
|
|
from django.db import models
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
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')
|
|
verbose_name = _("Favorite asset")
|
|
|
|
@classmethod
|
|
def get_user_favorite_asset_ids(cls, user):
|
|
return cls.objects.filter(user=user).values_list('asset', flat=True)
|
|
|
|
def __str__(self):
|
|
return '%s' % self.asset
|