• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Webapp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.webapps.models.Webapp的典型用法代码示例。如果您正苦于以下问题:Python Webapp类的具体用法?Python Webapp怎么用?Python Webapp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: _search

def _search(request, category=None):
    ctx = {'browse': True}
    region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)

    if category is not None:
        qs = Category.objects.filter(type=amo.ADDON_WEBAPP, weight__gte=0)
        ctx['category'] = get_object_or_404(qs, slug=category)
        ctx['featured'] = Webapp.featured(cat=ctx['category'], region=region,
            mobile=request.MOBILE)

        # Do a search filtered by this category and sort by Weekly Downloads.
        # TODO: Listen to andy and do not modify `request.GET` but at least
        # the traceback is fixed now.
        request.GET = request.GET.copy()
        request.GET.update({'cat': ctx['category'].id})
        if not request.GET.get('sort'):
            request.GET['sort'] = 'downloads'
    else:
        ctx['featured'] = Webapp.featured(region=region, mobile=request.MOBILE)

    # Always show three (or zero) featured apps - nothing in between.
    ctx['featured'] = ctx['featured'][:0 if len(ctx['featured']) < 3 else 3]

    ctx.update(_app_search(request, category=ctx.get('category'), browse=True))

    # If category is not listed as a facet, then remove redirect to search.
    if ctx.get('redirect'):
        return http.HttpResponseRedirect(ctx['redirect'])

    return jingo.render(request, 'search/results.html', ctx)
开发者ID:MaxDumont,项目名称:zamboni,代码行数:30,代码来源:views.py


示例2: test_get_stats_url

    def test_get_stats_url(self):
        webapp = Webapp(app_slug="woo")

        eq_(webapp.get_stats_url(), "/app/woo/statistics/")

        url = webapp.get_stats_url(action="installs_series", args=["day", "20120101", "20120201", "json"])
        eq_(url, "/app/woo/statistics/installs-day-20120101-20120201.json")
开发者ID:jvillalobos,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例3: setUp

 def setUp(self):
     self.saved_cb = models._on_change_callbacks.copy()
     models._on_change_callbacks.clear()
     self.cb = Mock()
     self.cb.__name__ = 'testing_mock_callback'
     Webapp.on_change(self.cb)
     self.testapp = app_factory(public_stats=True)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例4: featured_apps_admin

def featured_apps_admin(request):
    home_collection = Webapp.featured_collection('home')
    category_collection = Webapp.featured_collection('category')

    if request.POST:
        if 'home_submit' in request.POST:
            coll = home_collection
            rowid = 'home'
        elif 'category_submit' in request.POST:
            coll = category_collection
            rowid = 'category'
        existing = set(coll.addons.values_list('id', flat=True))
        requested = set(int(request.POST[k])
                        for k in sorted(request.POST.keys())
                        if k.endswith(rowid + '-webapp'))
        CollectionAddon.objects.filter(collection=coll,
            addon__in=(existing - requested)).delete()
        for id in requested - existing:
            CollectionAddon.objects.create(collection=coll, addon_id=id)
        messages.success(request, 'Changes successfully saved.')
        return redirect(reverse('admin.featured_apps'))

    return jingo.render(request, 'zadmin/featuredapp.html', {
        'home_featured': enumerate(home_collection.addons.all()),
        'category_featured': enumerate(category_collection.addons.all())
    })
开发者ID:gkoberger,项目名称:zamboni,代码行数:26,代码来源:views.py


示例5: test_multiple_ignored

 def test_multiple_ignored(self):
     cb = Mock()
     cb.__name__ = 'something'
     old = len(models._on_change_callbacks[Webapp])
     Webapp.on_change(cb)
     eq_(len(models._on_change_callbacks[Webapp]), old + 1)
     Webapp.on_change(cb)
     eq_(len(models._on_change_callbacks[Webapp]), old + 1)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例6: test_has_premium

    def test_has_premium(self):
        webapp = Webapp(premium_type=amo.ADDON_PREMIUM)
        webapp._premium = mock.Mock()
        webapp._premium.price = 1
        eq_(webapp.has_premium(), True)

        webapp._premium.price = 0
        eq_(webapp.has_premium(), True)
开发者ID:kmaglione,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例7: test_get_stats_url

    def test_get_stats_url(self):
        self.skip_if_disabled(settings.REGION_STORES)
        webapp = Webapp(app_slug="woo")

        eq_(webapp.get_stats_url(), "/app/woo/statistics/")

        url = webapp.get_stats_url(action="installs_series", args=["day", "20120101", "20120201", "json"])
        eq_(url, "/app/woo/statistics/installs-day-20120101-20120201.json")
开发者ID:rtnpro,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例8: test_get_price

 def test_get_price(self):
     # This test can be expensive to set up, lets just check it goes
     # down the stack.
     webapp = Webapp(premium_type=amo.ADDON_PREMIUM)
     webapp._premium = mock.Mock()
     webapp._premium.has_price.return_value = True
     webapp._premium.get_price.return_value = 1
     eq_(webapp.get_price(currency='USD'), 1)
开发者ID:mitramichaeljade,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例9: test_has_price

    def test_has_price(self):
        webapp = Webapp(premium_type=amo.ADDON_PREMIUM)
        webapp._premium = mock.Mock()
        webapp._premium.price = None
        webapp._premium.has_price.return_value = True
        eq_(webapp.has_price(), True)

        webapp._premium.has_price.return_value = False
        eq_(webapp.has_price(), False)
开发者ID:jvillalobos,项目名称:zamboni,代码行数:9,代码来源:test_models.py


示例10: test_get_stats_url

    def test_get_stats_url(self):
        webapp = Webapp(app_slug='woo')

        eq_(webapp.get_stats_url(), '/app/woo/statistics/')

        url = webapp.get_stats_url(action='installs_series',
                                   args=['day', '20120101', '20120201',
                                         'json'])
        eq_(url, '/app/woo/statistics/installs-day-20120101-20120201.json')
开发者ID:dimonov,项目名称:zamboni,代码行数:9,代码来源:test_models.py


示例11: test_assign_uuid_max_tries

 def test_assign_uuid_max_tries(self, mock_uuid4):
     guid = 'abcdef12-abcd-abcd-abcd-abcdef123456'
     mock_uuid4.return_value = uuid.UUID(guid)
     # Create another webapp with and set the guid.
     Webapp.objects.create(guid=guid)
     # Now `assign_uuid()` should fail.
     app = Webapp()
     with self.assertRaises(ValueError):
         app.save()
开发者ID:,项目名称:,代码行数:9,代码来源:


示例12: test_get_stats_url

    def test_get_stats_url(self):
        self.skip_if_disabled(settings.REGION_STORES)
        webapp = Webapp(app_slug='woo')

        eq_(webapp.get_stats_url(), '/app/woo/statistics/')

        url = webapp.get_stats_url(action='installs_series',
            args=['day', '20120101', '20120201', 'json'])
        eq_(url, '/app/woo/statistics/installs-day-20120101-20120201.json')
开发者ID:ominds,项目名称:zamboni,代码行数:9,代码来源:test_models.py


示例13: home

def home(request):
    """The home page."""
    if not getattr(request, 'can_view_consumer', True):
        return jingo.render(request, 'home/home_walled.html')
    featured = Webapp.featured('home')[:3]
    popular = Webapp.popular()[:6]
    return jingo.render(request, 'home/home.html', {
        'featured': featured,
        'popular': popular
    })
开发者ID:gkoberger,项目名称:zamboni,代码行数:10,代码来源:views.py


示例14: home

def home(request):
    """The home page."""
    if not getattr(request, 'can_view_consumer', True):
        return jingo.render(request, 'home/home_walled.html')
    region = getattr(request, 'REGION', mkt.regions.WORLDWIDE)
    featured = Webapp.featured(region=region, cat=None)[:9]
    popular = _add_mobile_filter(request, Webapp.popular(region=region))[:10]
    latest = _add_mobile_filter(request, Webapp.latest(region=region))[:10]
    return jingo.render(request, 'home/home.html', {
        'featured': featured,
    })
开发者ID:Sancus,项目名称:zamboni,代码行数:11,代码来源:views.py


示例15: tearDown

    def tearDown(self):
        # Taken from MultiSearchView test.
        for w in Webapp.objects.all():
            w.delete()
        for w in Website.objects.all():
            w.delete()
        super(TestDailyGamesView, self).tearDown()

        Webapp.get_indexer().unindexer(_all=True)
        Website.get_indexer().unindexer(_all=True)
        self.refresh(('webapp', 'website'))
开发者ID:Jobava,项目名称:zamboni,代码行数:11,代码来源:test_views.py


示例16: _landing

def _landing(request, category=None):
    if category:
        category = get_object_or_404(Category.objects.filter(type=amo.ADDON_WEBAPP, weight__gte=0), slug=category)
        featured = Webapp.featured(category)
        popular = Webapp.popular().filter(category=category.id)
    else:
        popular = Webapp.popular()
        featured = Webapp.featured(None)

    return jingo.render(
        request, "browse/landing.html", {"category": category, "featured": featured[:6], "popular": popular[:6]}
    )
开发者ID:sjhewitt,项目名称:zamboni,代码行数:12,代码来源:views.py


示例17: home

def home(request):
    """The home page."""
    if not getattr(request, 'can_view_consumer', True):
        return jingo.render(request, 'home/home_walled.html')
    featured = Webapp.featured(cat=None)
    popular = Webapp.popular()[:10]
    latest = Webapp.latest()[:10]
    return jingo.render(request, 'home/home.html', {
        'featured': featured,
        'popular': popular,
        'latest': latest
    })
开发者ID:,项目名称:,代码行数:12,代码来源:


示例18: to_native

 def to_native(self, obj):
     # fake_app is a fake instance because we need to access a couple
     # properties and methods on Webapp. It should never hit the database.
     fake_app = Webapp(id=obj['id'], icon_type='image/png',
         modified=datetime.strptime(obj['modified'], '%Y-%m-%dT%H:%M:%S'))
     ESTranslationSerializerField.attach_translations(fake_app, obj, 'name')
     return {
         'name': self.fields['name'].field_to_native(fake_app, 'name'),
         'icon' : fake_app.get_icon_url(64),
         'slug': obj['slug'],
         'manifest_url': obj['manifest_url'],
     }
开发者ID:unghost,项目名称:zamboni,代码行数:12,代码来源:serializers.py


示例19: test_xss

    def test_xss(self):
        nasty = '<script>'
        escaped = '&lt;script&gt;'
        author = self.webapp.authors.all()[0]
        author.display_name = nasty
        author.save()

        self.webapp.name = nasty
        self.webapp.save()
        Webapp.transformer([self.webapp])  # Transform `listed_authors`, etc.

        doc = pq(market_tile(self.context, self.webapp))
        data = json.loads(doc('.mkt-tile').attr('data-product'))
        eq_(data['name'], escaped)
        eq_(data['author'], escaped)
开发者ID:KryDos,项目名称:zamboni,代码行数:15,代码来源:test_helpers.py


示例20: test_initial

    def test_initial(self):
        app = Webapp(status=mkt.STATUS_PUBLIC)
        eq_(self.form(None, addon=app).fields['publish_type'].initial,
            mkt.PUBLISH_IMMEDIATE)
        eq_(self.form(None, addon=app).fields['limited'].initial, False)

        app.status = mkt.STATUS_UNLISTED
        eq_(self.form(None, addon=app).fields['publish_type'].initial,
            mkt.PUBLISH_HIDDEN)
        eq_(self.form(None, addon=app).fields['limited'].initial, False)

        app.status = mkt.STATUS_APPROVED
        eq_(self.form(None, addon=app).fields['publish_type'].initial,
            mkt.PUBLISH_HIDDEN)
        eq_(self.form(None, addon=app).fields['limited'].initial, True)
开发者ID:ujdhesa,项目名称:zamboni,代码行数:15,代码来源:test_forms.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.WebappIndexer类代码示例发布时间:2022-05-27
下一篇:
Python indexers.WebappIndexer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap