本文整理汇总了Python中core.models.Instance.shared_with_user方法的典型用法代码示例。如果您正苦于以下问题:Python Instance.shared_with_user方法的具体用法?Python Instance.shared_with_user怎么用?Python Instance.shared_with_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.Instance
的用法示例。
在下文中一共展示了Instance.shared_with_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_queryset
# 需要导入模块: from core.models import Instance [as 别名]
# 或者: from core.models.Instance import shared_with_user [as 别名]
def get_queryset(self):
"""
Filter projects by current user.
"""
user = self.request.user
qs = Instance.shared_with_user(user)
if 'archived' not in self.request.query_params:
qs = qs.filter(only_current_instances())
# logger.info("DEBUG- User %s querying for instances, available IDs are:%s" % (user, qs.values_list('id',flat=True)))
qs = qs.select_related("created_by")\
.select_related('created_by_identity')\
.select_related('source')\
.select_related('project')
return qs
示例2: get_queryset
# 需要导入模块: from core.models import Instance [as 别名]
# 或者: from core.models.Instance import shared_with_user [as 别名]
def get_queryset(self):
request_user = self.request.user
if request_user.is_staff or request_user.is_superuser:
instances_qs = Instance.objects.all()
elif request_user.is_authenticated():
instances_qs = Instance.shared_with_user(request_user)
else:
raise exceptions.NotAuthenticated()
query_params = self.request.query_params
query = self.get_filter_query(query_params)
queryset = instances_qs.select_related('source').prefetch_related(
'source__providermachine__application_version__application',
).filter(query)
return queryset
示例3: get_queryset
# 需要导入模块: from core.models import Instance [as 别名]
# 或者: from core.models.Instance import shared_with_user [as 别名]
def get_queryset(self):
user = self.request.user
qs = Instance.shared_with_user(user)
if 'archived' in self.request.query_params:
return qs
return qs.filter(only_current())