本文整理汇总了Python中mkt.webapps.models.Webapp.get_excluded_in方法的典型用法代码示例。如果您正苦于以下问题:Python Webapp.get_excluded_in方法的具体用法?Python Webapp.get_excluded_in怎么用?Python Webapp.get_excluded_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.webapps.models.Webapp
的用法示例。
在下文中一共展示了Webapp.get_excluded_in方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queryset
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import get_excluded_in [as 别名]
def queryset(self):
res = SearchSuggestionsAjax.queryset(self)
if self.category:
res = res.filter(category__in=[self.category])
if (self.mobile or self.tablet) and not self.gaia:
if isinstance(res, S):
res = res.filter(~F(premium_type__in=amo.ADDON_PREMIUMS,
price__gt=0))
else:
res.exclude(premium_type__in=amo.ADDON_PREMIUMS, price__gt=0)
region = getattr(self.request, 'REGION', mkt.regions.WORLDWIDE)
if region:
excluded = Webapp.get_excluded_in(region)
if excluded:
if isinstance(res, S):
# ES? Do fanciness.
res = res.filter(~F(id__in=excluded))
else:
# Django ORM? Do an `exclude`.
res = res.exclude(id__in=excluded)
if self.gaia:
res = res.filter(device=amo.DEVICE_GAIA.id, uses_flash=False)
elif self.mobile:
res = res.filter(device=amo.DEVICE_MOBILE.id, uses_flash=False)
return res
示例2: test_excluded_in
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import get_excluded_in [as 别名]
def test_excluded_in(self):
app1 = app_factory()
app2 = app_factory()
region = list(mkt.regions.ADULT_EXCLUDED)[0]
AddonExcludedRegion.objects.create(addon=app1, region=region.id)
Flag.objects.create(addon=app1, adult_content=True)
Flag.objects.create(addon=app2, adult_content=True)
eq_(Webapp.get_excluded_in(region), [app1.id, app2.id])
示例3: queryset
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import get_excluded_in [as 别名]
def queryset(self):
"""Get items based on ID or search by name."""
res = Addon.objects.none()
q = self.request.GET.get(self.key)
if q:
pk = None
try:
pk = int(q)
except ValueError:
pass
qs = None
if pk:
qs = Addon.objects.filter(id=int(q), disabled_by_user=False)
elif len(q) > 2:
qs = (S(Webapp).query(or_=name_only_query(q.lower()))
.filter(is_disabled=False))
if qs:
res = qs.filter(type__in=self.types,
status__in=amo.REVIEWED_STATUSES)
if self.category:
res = res.filter(category__in=[self.category])
if (self.mobile or self.tablet) and not self.gaia:
if isinstance(res, S):
res = res.filter(~F(premium_type__in=amo.ADDON_PREMIUMS,
price__gt=0))
else:
res.exclude(premium_type__in=amo.ADDON_PREMIUMS, price__gt=0)
region = getattr(self.request, 'REGION', mkt.regions.WORLDWIDE)
if region:
excluded = Webapp.get_excluded_in(region)
if excluded:
if isinstance(res, S):
# ES? Do fanciness.
res = res.filter(~F(id__in=excluded))
else:
# Django ORM? Do an `exclude`.
res = res.exclude(id__in=excluded)
if self.gaia:
res = res.filter(device=amo.DEVICE_GAIA.id, uses_flash=False)
elif self.mobile:
res = res.filter(device=amo.DEVICE_MOBILE.id, uses_flash=False)
return res
示例4: queryset
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import get_excluded_in [as 别名]
def queryset(self):
res = SearchSuggestionsAjax.queryset(self)
if self.category:
res = res.filter(category__in=[self.category])
region = getattr(self.request, 'REGION', mkt.regions.WORLDWIDE)
if region:
excluded = Webapp.get_excluded_in(region)
if excluded:
if isinstance(res, S):
# ES? Do fanciness.
return res.filter(~F(id__in=excluded))
else:
# Django ORM? Do an `exclude`.
return res.exclude(id__in=excluded)
if getattr(self.request, 'MOBILE', False):
res = res.filter(device=amo.DEVICE_MOBILE.id)
return res
示例5: queryset
# 需要导入模块: from mkt.webapps.models import Webapp [as 别名]
# 或者: from mkt.webapps.models.Webapp import get_excluded_in [as 别名]
def queryset(self):
res = SearchSuggestionsAjax.queryset(self)
if self.category:
res = res.filter(category__in=[self.category])
if waffle.switch_is_active("disabled-payments"):
res = res.filter(premium_type__in=amo.ADDON_FREES, price=0)
region = getattr(self.request, "REGION", mkt.regions.WORLDWIDE)
if region:
excluded = Webapp.get_excluded_in(region)
if excluded:
if isinstance(res, S):
# ES? Do fanciness.
res = res.filter(~F(id__in=excluded))
else:
# Django ORM? Do an `exclude`.
res = res.exclude(id__in=excluded)
if getattr(self.request, "MOBILE", False):
res = res.filter(device=amo.DEVICE_MOBILE.id)
return res