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


Python UserInappKey.create方法代码示例

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


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

示例1: test_keys_page_renders_when_solitude_raises_404

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
    def test_keys_page_renders_when_solitude_raises_404(self, solitude):
        UserInappKey.create(self.user)
        solitude.api.generic.product.side_effect = HttpClientError()

        res = self.client.get(self.url)
        eq_(res.status_code, 200)

        # Test that a message is sent to the user
        eq_(len(res.context['messages']), 1)
开发者ID:prodigeni,项目名称:zamboni,代码行数:11,代码来源:test_views_payments.py

示例2: in_app_keys

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
def in_app_keys(request):
    keys = UserInappKey.uncached.filter(solitude_seller__user=request.amo_user)
    # TODO(Kumar) support multiple test keys. For now there's only one.
    if keys.count():
        key = keys.get()
    else:
        key = None
    if request.method == "POST":
        if key:
            key.reset()
            messages.success(request, _("Secret was reset successfully."))
        else:
            UserInappKey.create(request.amo_user)
            messages.success(request, _("Key and secret were created successfully."))
        return redirect(reverse("mkt.developers.apps.in_app_keys"))

    return jingo.render(request, "developers/payments/in-app-keys.html", {"key": key})
开发者ID:wraithan,项目名称:zamboni,代码行数:19,代码来源:views_payments.py

示例3: test_reset

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
    def test_reset(self, solitude):
        self.setup_solitude(solitude)
        key = UserInappKey.create(self.user)
        product = mock.Mock()
        solitude.api.generic.product.return_value = product

        self.client.post(self.url)
        product.patch.assert_called_with(data={'secret': ANY})
        solitude.api.generic.product.assert_called_with(key.seller_product_pk)
开发者ID:wraithan,项目名称:zamboni,代码行数:11,代码来源:test_views_payments.py

示例4: in_app_keys

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
def in_app_keys(request):
    keys = (UserInappKey.objects.no_cache()
            .filter(solitude_seller__user=request.amo_user))
    # TODO(Kumar) support multiple test keys. For now there's only one.
    if keys.count():
        key = keys.get()
    else:
        key = None
    if request.method == 'POST':
        if key:
            key.reset()
            messages.success(request, _('Secret was reset successfully.'))
        else:
            UserInappKey.create(request.amo_user)
            messages.success(request,
                             _('Key and secret were created successfully.'))
        return redirect(reverse('mkt.developers.apps.in_app_keys'))

    return jingo.render(request, 'developers/payments/in-app-keys.html',
                        {'key': key})
开发者ID:rajuch,项目名称:zamboni,代码行数:22,代码来源:views_payments.py

示例5: _

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
        # Attempt to retrieve the public id from solitude
        try:
            key_public_id = key.public_id()
        except HttpClientError, e:
            messages.error(request,
                           _('A server error occurred '
                             'when retrieving the application key.'))
            log.exception('Solitude connection error: {0}'.format(e.message))

    if request.method == 'POST':
        if key:
            key.reset()
            messages.success(request, _('Secret was reset successfully.'))
        else:
            UserInappKey.create(request.amo_user)
            messages.success(request,
                             _('Key and secret were created successfully.'))
        return redirect(reverse('mkt.developers.apps.in_app_keys'))

    return render(request, 'developers/payments/in-app-keys.html',
                  {'key': key, 'key_public_id': key_public_id})


@login_required
def in_app_key_secret(request, pk):
    key = (UserInappKey.objects.no_cache()
           .filter(solitude_seller__user=request.amo_user, pk=pk))
    if not key.count():
        # Either the record does not exist or it's not owned by the
        # logged in user.
开发者ID:AALEKH,项目名称:zamboni,代码行数:32,代码来源:views_payments.py

示例6: setup_objects

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
 def setup_objects(self, solitude):
     self.setup_solitude(solitude)
     key = UserInappKey.create(self.user)
     self.url = reverse('mkt.developers.apps.in_app_key_secret',
                        args=[key.pk])
开发者ID:wraithan,项目名称:zamboni,代码行数:7,代码来源:test_views_payments.py

示例7: _

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
        # Attempt to retrieve the public id from solitude
        try:
            key_public_id = key.public_id()
        except HttpClientError, e:
            messages.error(request,
                           _('A server error occurred '
                             'when retrieving the application key.'))
            log.exception('Solitude connection error: {0}'.format(e.message))

    if request.method == 'POST':
        if key:
            key.reset()
            messages.success(request, _('Secret was reset successfully.'))
        else:
            UserInappKey.create(request.user)
            messages.success(request,
                             _('Key and secret were created successfully.'))
        return redirect(reverse('mkt.developers.apps.in_app_keys'))

    return render(request, 'developers/payments/in-app-keys.html',
                  {'key': key, 'key_public_id': key_public_id})


@login_required
def in_app_key_secret(request, pk):
    key = (UserInappKey.objects.no_cache()
           .filter(solitude_seller__user=request.user, pk=pk))
    if not key.count():
        # Either the record does not exist or it's not owned by the
        # logged in user.
开发者ID:andymckay,项目名称:zamboni,代码行数:32,代码来源:views_payments.py

示例8: generate_app_from_spec

# 需要导入模块: from mkt.developers.models import UserInappKey [as 别名]
# 或者: from mkt.developers.models.UserInappKey import create [as 别名]
def generate_app_from_spec(name, categories, type, status, num_previews=1,
                           num_ratings=1, locale_names=('en-US', 'es-ES'),
                           preview_files=(),
                           video_files=(),
                           developer_name='Fake App Developer',
                           developer_email='[email protected]',
                           privacy_policy='Fake privacy policy',
                           premium_type='free', description=None,
                           default_locale='en-US', rereview=False,
                           special_regions={}, inapp_id=None,
                           inapp_secret=None, popularity=0, **spec):
    status = STATUS_CHOICES_API_LOOKUP[status]
    names = generate_localized_names(name, locale_names)
    if type == 'hosted':
        app = generate_hosted_app(
            names[default_locale], categories, developer_name, status=status,
            default_locale=default_locale, **spec)
    else:
        app = generate_packaged_app(
            names, type, categories, developer_name,
            default_locale=default_locale, status=status, **spec)
    generate_icon(app)
    if not preview_files:
        generate_previews(app, num_previews)
    if video_files:
        for i, f in enumerate(video_files):
            t = tempfile.mktemp()
            copy_stored_file(f, t, src_storage=local_storage,
                             dst_storage=private_storage)
            p = Preview.objects.create(addon=app, filetype="video/webm",
                                       caption="video " + str(i),
                                       position=i)
            resize_video(t, p.pk)
    if preview_files:
        for i, f in enumerate(preview_files):
            p = Preview.objects.create(addon=app, filetype="image/png",
                                       caption="screenshot " + str(i),
                                       position=i + len(video_files))
            t = tempfile.mktemp()
            copy_stored_file(f, t, src_storage=local_storage,
                             dst_storage=private_storage)
            resize_preview(t, p.pk)
    generate_ratings(app, num_ratings)
    app.name = names
    if not description:
        description = GENERIC_DESCRIPTION
    app.description = description
    app.privacy_policy = privacy_policy
    app.support_email = developer_email
    premium_type = mkt.ADDON_PREMIUM_API_LOOKUP[premium_type]
    app.premium_type = premium_type
    app.default_locale = default_locale
    if popularity:
        app.popularity.create(value=popularity)
    if premium_type != mkt.ADDON_FREE and status != mkt.STATUS_NULL:
        acct = get_or_create_payment_account(developer_email, developer_name)
        product_uri = Reference().product_create(acct, app)
        AddonPaymentAccount.objects.create(addon=app, payment_account=acct,
                                           account_uri=acct.uri,
                                           product_uri=product_uri)
        if premium_type in (mkt.ADDON_PREMIUM, mkt.ADDON_PREMIUM_INAPP):
            price = get_or_create_price(spec.get('price', '0.99'))
            AddonPremium.objects.create(addon=app, price=price)
        if premium_type in (mkt.ADDON_FREE_INAPP, mkt.ADDON_PREMIUM_INAPP):
            UserInappKey.create(acct.user, secret=inapp_secret,
                                public_id=inapp_id,
                                access_type=ACCESS_PURCHASE)

    for optField in ('support_url', 'homepage', 'is_offline'):
        if optField in spec:
            setattr(app, optField, spec[optField])
    # Status has to be updated at the end because STATUS_DELETED apps can't
    # be saved.
    app.status = status
    app.save()
    for (region, region_status) in special_regions.iteritems():
        app.geodata.update(**{'region_%s_nominated' % (region,):
                              datetime.datetime.now(),
                              'region_%s_status' % (region,):
                              STATUS_CHOICES_API_LOOKUP[region_status]})
    addon_review_aggregates(app.pk)
    if rereview:
        RereviewQueue.objects.get_or_create(addon=app)
    try:
        u = UserProfile.objects.get(email=developer_email)
    except UserProfile.DoesNotExist:
        u = create_user(developer_email)
        u.display_name = developer_name
        u.save()
    AddonUser.objects.create(user=u, addon=app)
    return app
开发者ID:carriercomm,项目名称:zamboni,代码行数:93,代码来源:fakedata.py


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