当前位置: 首页>>代码示例>>Python>>正文


Python FeatureProfile.from_signature方法代码示例

本文整理汇总了Python中mkt.constants.features.FeatureProfile.from_signature方法的典型用法代码示例。如果您正苦于以下问题:Python FeatureProfile.from_signature方法的具体用法?Python FeatureProfile.from_signature怎么用?Python FeatureProfile.from_signature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.constants.features.FeatureProfile的用法示例。


在下文中一共展示了FeatureProfile.from_signature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_from_old_signature

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
 def test_from_old_signature(self):
     profile = FeatureProfile.from_signature(self.signature)
     self._test_profile_values(profile)
     new_signature = profile.to_signature()
     ok_(new_signature != self.signature)
     profile = FeatureProfile.from_signature(new_signature)
     self._test_profile_values(profile)
开发者ID:jobava-mozilla,项目名称:zamboni,代码行数:9,代码来源:test_features.py

示例2: get_feature_profile

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
 def get_feature_profile(self, request):
     profile = None
     if request.GET.get('dev') in ('firefoxos', 'android'):
         sig = request.GET.get('pro')
         if sig:
             profile = FeatureProfile.from_signature(sig)
     return profile
开发者ID:chrisdavidmills,项目名称:zamboni,代码行数:9,代码来源:api.py

示例3: get

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
 def get(self, request, *args, **kwargs):
     if 'pro' in request.GET:
         self.profile = FeatureProfile.from_signature(request.GET['pro'])
     else:
         self.profile = None
     features = OrderedDict(self._feature(i, slug) for i, slug in
                            enumerate(APP_FEATURES.keys()))
     return Response(features, status=status.HTTP_200_OK)
开发者ID:AALEKH,项目名称:zamboni,代码行数:10,代码来源:views.py

示例4: test_all_good_features_with_category

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
    def test_all_good_features_with_category(self):
        """Enable app features so they exactly match our device profile."""
        fp = FeatureProfile.from_signature(self.profile)
        self.app.current_version.features.update(**dict(("has_%s" % k, v) for k, v in fp.items()))
        self.reindex(Webapp, "webapp")

        res = self.client.get(self.list_url + (self.qs,))
        eq_(res.status_code, 200)
        eq_(len(res.json["featured"]), 1)
        eq_(int(res.json["featured"][0]["id"]), self.app.pk)
开发者ID:wraithan,项目名称:zamboni,代码行数:12,代码来源:test_api.py

示例5: test_all_good_features

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
    def test_all_good_features(self):
        # Enable app features so they exactly match our device profile.
        fp = FeatureProfile.from_signature(self.profile)
        self.webapp.current_version.features.update(**dict(("has_%s" % k, v) for k, v in fp.items()))
        self.webapp.save()
        self.refresh("webapp")

        res = self.client.get(self.url + (self.qs,))
        eq_(res.status_code, 200)
        obj = json.loads(res.content)["objects"][0]
        eq_(obj["slug"], self.webapp.app_slug)
开发者ID:wraithan,项目名称:zamboni,代码行数:13,代码来源:test_api.py

示例6: get_feature_profile

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
def get_feature_profile(request):
    profile = None
    platforms = ('firefoxos', 'android')
    if (request.GET.get('dev') in platforms or
        request.GET.get('platform') in platforms):
        sig = request.GET.get('pro')
        if sig:
            try:
                profile = FeatureProfile.from_signature(sig)
            except ValueError:
                pass
    return profile
开发者ID:unghost,项目名称:zamboni,代码行数:14,代码来源:utils.py

示例7: test_all_good_features

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
    def test_all_good_features(self):
        # Enable app features so they exactly match our device profile.
        fp = FeatureProfile.from_signature(self.features)
        self.webapp.current_version.features.update(
            **dict(('has_%s' % k, v) for k, v in fp.items()))
        self.webapp.save()
        self.refresh('webapp')

        res = self.client.get(self.url, data=self.qs)
        eq_(res.status_code, 200)
        obj = json.loads(res.content)['objects'][0]
        eq_(obj['slug'], self.webapp.app_slug)
开发者ID:j-barron,项目名称:zamboni,代码行数:14,代码来源:test_views.py

示例8: field_to_native

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
    def field_to_native(self, obj, field_name):
        value = get_component(obj, self.source)

        # Filter apps based on feature profiles.
        if hasattr(self, 'context') and 'request' in self.context:
            sig = self.context['request'].GET.get('pro')
            if sig:
                try:
                    profile = FeatureProfile.from_signature(sig)
                except ValueError:
                    pass
                else:
                    value = value.filter(**profile.to_kwargs(
                        prefix='app___current_version__features__has_'))

        return [self.to_native(item) for item in value.all()]
开发者ID:rhelmer,项目名称:zamboni,代码行数:18,代码来源:serializers.py

示例9: device_queue_search

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
def device_queue_search(request):
    """
    Returns a queryset that can be used as a base for searching the device
    specific queue.
    """
    filters = {
        'status': amo.STATUS_PENDING,
        'disabled_by_user': False,
    }
    sig = request.GET.get('pro')
    if sig:
        profile = FeatureProfile.from_signature(sig)
        filters.update(dict(
            **profile.to_kwargs(prefix='_latest_version__features__has_')
        ))
    return Webapp.version_and_file_transformer(
        Webapp.objects.filter(**filters))
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:19,代码来源:utils.py

示例10: load_feature_profile

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
def load_feature_profile(request):
    """
    Adds a `feature_profile` on the request object if one is present and the
    dev parameter is either firefoxos or android.

    Does nothing if one was already set.
    """
    if hasattr(request, 'feature_profile'):
        return
    profile = None
    if request.GET.get('dev') in ('firefoxos', 'android'):
        sig = request.GET.get('pro')
        if sig:
            try:
                profile = FeatureProfile.from_signature(sig)
            except ValueError:
                pass
    request.feature_profile = profile
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:20,代码来源:utils.py

示例11: alter_list_data_to_serialize

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
    def alter_list_data_to_serialize(self, request, data):
        form_data = self.search_form(request)
        region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
        if form_data['cat']:
            category = Category.objects.get(pk=form_data['cat'])
        else:
            category = None

        # Filter by device feature profile.
        profile = None
        if request.GET.get('dev') in ('firefoxos', 'android'):
            sig = request.GET.get('pro')
            if sig:
                profile = FeatureProfile.from_signature(sig)

        qs = Webapp.featured(cat=category, region=region, profile=profile)

        bundles = [self.build_bundle(obj=obj, request=request) for obj in qs]
        data['featured'] = [AppResource().full_dehydrate(bundle)
                            for bundle in bundles]
        return data
开发者ID:MikeLing,项目名称:zamboni,代码行数:23,代码来源:api.py

示例12: alter_list_data_to_serialize

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
    def alter_list_data_to_serialize(self, request, data):
        form_data = self.search_form(request)
        region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
        cat_slug = form_data.get('cat')
        if cat_slug:
            cat_slug = [cat_slug]

        # Filter by device feature profile.
        profile = None
        if request.GET.get('dev') in ('firefoxos', 'android'):
            sig = request.GET.get('pro')
            if sig:
                profile = FeatureProfile.from_signature(sig)

        qs = Webapp.featured(cat=cat_slug, region=region, profile=profile)

        bundles = [self.build_bundle(obj=obj, request=request) for obj in qs]
        data['featured'] = [AppResource().full_dehydrate(bundle)
                            for bundle in bundles]
        # Alter the _view_name so that statsd logs seperately from search.
        request._view_name = 'featured'
        return data
开发者ID:smillaedler,项目名称:zamboni,代码行数:24,代码来源:api.py

示例13: to_native

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
 def to_native(self, obj):
     ret = super(AppFeaturesSerializer, self).to_native(obj)
     profile = FeatureProfile.from_signature(obj.to_signature())
     ret['required'] = profile.to_list()
     return ret
开发者ID:BIGGANI,项目名称:zamboni,代码行数:7,代码来源:api.py

示例14: test_from_signature

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
 def test_from_signature(self):
     profile = FeatureProfile.from_signature(self.signature)
     self._test_profile(profile)
开发者ID:jobava-mozilla,项目名称:zamboni,代码行数:5,代码来源:test_features.py

示例15: get_list

# 需要导入模块: from mkt.constants.features import FeatureProfile [as 别名]
# 或者: from mkt.constants.features.FeatureProfile import from_signature [as 别名]
    def get_list(self, request=None, **kwargs):
        form_data = self.search_form(request)
        is_admin = acl.action_allowed(request, 'Admin', '%')
        is_reviewer = acl.action_allowed(request, 'Apps', 'Review')

        uses_es = waffle.switch_is_active('search-api-es')

        # Pluck out status and addon type first since it forms part of the base
        # query, but only for privileged users.
        status = form_data['status']
        addon_type = form_data['type']

        base_filters = {
            'type': addon_type,
        }

        # Allow reviewers and admins to search by statuses other than PUBLIC.
        if status and (status == 'any' or status != amo.STATUS_PUBLIC):
            if is_admin or is_reviewer:
                base_filters['status'] = status
            else:
                return http.HttpUnauthorized(
                    content=json.dumps(
                        {'reason': _('Unauthorized to filter by status.')}))

        # Filter by device feature profile.
        profile = None
        # TODO: Remove uses_es conditional with 'search-api-es' waffle.
        if uses_es and request.GET.get('dev') in ('firefoxos', 'android'):
            sig = request.GET.get('pro')
            if sig:
                profile = FeatureProfile.from_signature(sig)

        # Filter by region.
        region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)

        qs = _get_query(region, gaia=request.GAIA, mobile=request.MOBILE,
                        tablet=request.TABLET, filters=base_filters,
                        new_idx=True)
        qs = _filter_search(request, qs, form_data, region=region,
                            profile=profile)
        paginator = self._meta.paginator_class(request.GET, qs,
            resource_uri=self.get_resource_list_uri(),
            limit=self._meta.limit)
        page = paginator.page()

        # Rehydrate the results as per tastypie.
        objs = []
        for obj in page['objects']:
            obj.pk = obj.id
            objs.append(self.build_bundle(obj=obj, request=request))

        if uses_es:
            page['objects'] = [self.full_dehydrate(bundle)
                               for bundle in objs]
        else:
            page['objects'] = [AppResource().full_dehydrate(bundle)
                               for bundle in objs]

        # This isn't as quite a full as a full TastyPie meta object,
        # but at least it's namespaced that way and ready to expand.
        to_be_serialized = self.alter_list_data_to_serialize(request, page)
        return self.create_response(request, to_be_serialized)
开发者ID:jlongster,项目名称:zamboni,代码行数:65,代码来源:api.py


注:本文中的mkt.constants.features.FeatureProfile.from_signature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。