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


Python models.InappConfig类代码示例

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


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

示例1: in_app_config

def in_app_config(request, addon_id, addon, webapp=True):
    if addon.premium_type not in amo.ADDON_INAPPS:
        messages.error(request, 'Your app does not use payments.')
        return redirect(addon.get_dev_url('payments'))

    try:
        inapp_config = InappConfig.objects.get(addon=addon,
                                               status=amo.INAPP_STATUS_ACTIVE)
    except models.ObjectDoesNotExist:
        inapp_config = None

    inapp_form = InappConfigForm(request.POST or None,
                                 instance=inapp_config)

    if request.method == 'POST' and inapp_form.is_valid():
        new_inapp = inapp_form.save(commit=False)
        new_inapp.addon = addon
        new_inapp.status = amo.INAPP_STATUS_ACTIVE
        if not new_inapp.public_key:
            new_inapp.public_key = InappConfig.generate_public_key()
        new_inapp.save()
        if not new_inapp.has_private_key():
            new_inapp.set_private_key(InappConfig.generate_private_key())

        messages.success(request, _('Changes successfully saved.'))
        return redirect(addon.get_dev_url('in_app_config'))

    return jingo.render(request, 'developers/payments/in-app-config.html',
                        dict(addon=addon, inapp_form=inapp_form,
                             inapp_config=inapp_config))
开发者ID:gkoberger,项目名称:zamboni,代码行数:30,代码来源:views.py

示例2: test_any_active

 def test_any_active(self):
     assert not InappConfig.any_active(self.app)
     InappConfig.objects.create(addon=self.app,
                                status=amo.INAPP_STATUS_ACTIVE,
                                public_key='asd-1')
     assert InappConfig.any_active(self.app)
     self.assertRaises(ValueError, InappConfig.objects.create,
                       addon=self.app, status=amo.INAPP_STATUS_ACTIVE,
                       public_key='asd-2')
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:9,代码来源:test_models.py

示例3: setUp

 def setUp(self):
     self.app = self.get_app()
     cfg = self.inapp_config = InappConfig(addon=self.app,
                                           status=amo.INAPP_STATUS_ACTIVE)
     cfg.public_key = self.app_id = InappConfig.generate_public_key()
     cfg.private_key = self.app_secret = InappConfig.generate_private_key()
     cfg.save()
     self.app.paypal_id = '[email protected]'
     self.app.save()
开发者ID:beenishkhan,项目名称:zamboni,代码行数:9,代码来源:test_views.py

示例4: setUp

 def setUp(self):
     self.app = self.get_app()
     cfg = self.inapp_config = InappConfig(addon=self.app,
                                           status=amo.INAPP_STATUS_ACTIVE)
     cfg.public_key = self.app_id = InappConfig.generate_public_key()
     self.app_secret = InappConfig.generate_private_key()
     cfg.save()
     cfg.set_private_key(self.app_secret)
     self.app.paypal_id = '[email protected]'
     self.app.save()
     if hasattr(Price, '_currencies'):
         del Price._currencies  # needed to pick up fixtures.
开发者ID:bearstech,项目名称:zamboni,代码行数:12,代码来源:test_views.py

示例5: test_retry_private_keygen_until_unique

 def test_retry_private_keygen_until_unique(self, fake_conn):
     (fake_conn.expects('cursor').returns_fake()
               .expects('execute')
               .expects('fetchone').returns([1])
               .next_call().returns([1])
               .next_call().returns([0]))
     assert InappConfig.generate_private_key(max_tries=5)
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例6: setUp

    def setUp(self):
        super(TestInappIPN, self).setUp()
        self.app = self.get_app()
        cfg = self.inapp_config = InappConfig(addon=self.app,
                                              status=amo.INAPP_STATUS_ACTIVE)
        cfg.public_key = self.app_id = InappConfig.generate_public_key()
        cfg.private_key = self.app_secret = InappConfig.generate_private_key()
        cfg.save()
        self.app.paypal_id = '[email protected]'
        self.app.save()

        waffle.models.Switch.objects.create(name='in-app-payments-ui',
                                            active=True)
        self.user = UserProfile.objects.get(email='[email protected]')
        assert self.client.login(username='[email protected]',
                                 password='password')
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:16,代码来源:test_ipn.py

示例7: reset_in_app_config

def reset_in_app_config(request, addon_id, addon, config_id, webapp=True):
    if addon.premium_type not in amo.ADDON_INAPPS:
        messages.error(request, "Your app does not use payments.")
        return redirect(addon.get_dev_url("payments"))

    cfg = get_object_or_404(InappConfig, addon=addon, status=amo.INAPP_STATUS_ACTIVE)
    msg = "user reset in-app payment config %s; " "key: %r; app: %s" % (cfg.pk, cfg.public_key, addon.pk)
    log.info(msg)
    inapp_cef.log(request, addon, "inapp_reset", msg, severity=6)
    cfg.update(status=amo.INAPP_STATUS_REVOKED)
    kw = dict(
        addon=cfg.addon,
        status=amo.INAPP_STATUS_ACTIVE,
        postback_url=cfg.postback_url,
        chargeback_url=cfg.chargeback_url,
        public_key=InappConfig.generate_public_key(),
    )
    new_cfg = InappConfig.objects.create(**kw)
    new_cfg.set_private_key(InappConfig.generate_private_key())
    messages.success(request, _("Old credentials revoked; " "new credentials were generated successfully."))
    return redirect(addon.get_dev_url("in_app_config"))
开发者ID:dbialer,项目名称:zamboni,代码行数:21,代码来源:views.py

示例8: test_retry_public_keygen_until_unique

 def test_retry_public_keygen_until_unique(self, fake_filter):
     (
         fake_filter.expects_call()
         .returns_fake()
         .expects("count")
         .returns(1)
         .next_call()
         .returns(1)
         .next_call()
         .returns(0)
     )
     assert InappConfig.generate_public_key(max_tries=5)
开发者ID:pjajara,项目名称:zamboni,代码行数:12,代码来源:test_models.py

示例9: test_exhaust_public_keygen_attempts

 def test_exhaust_public_keygen_attempts(self, fake_filter):
     fake_filter.expects_call().returns_fake().expects('count').returns(1)
     InappConfig.generate_public_key(max_tries=5)
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:3,代码来源:test_models.py

示例10: test_exhaust_private_keygen_attempts

 def test_exhaust_private_keygen_attempts(self, fake_conn):
     (fake_conn.expects('cursor').returns_fake()
               .expects('execute').expects('fetchone').returns([1]))
     InappConfig.generate_private_key(max_tries=5)
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:4,代码来源:test_models.py

示例11: test_generate_private_key

 def test_generate_private_key(self):
     key = InappConfig.generate_private_key()
     assert key
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:3,代码来源:test_models.py

示例12: test_generate_public_key

 def test_generate_public_key(self):
     key = InappConfig.generate_public_key()
     assert key
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:3,代码来源:test_models.py

示例13: test_any_active_excludes_config_under_edit

 def test_any_active_excludes_config_under_edit(self):
     c = InappConfig.objects.create(addon=self.app,
                                    status=amo.INAPP_STATUS_ACTIVE,
                                    public_key='asd-1')
     assert not InappConfig.any_active(self.app, exclude_config=c.pk)
     c.save()  # no exception
开发者ID:mnoorenberghe,项目名称:zamboni,代码行数:6,代码来源:test_models.py


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