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

Python waffle.flag_is_active函数代码示例

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

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



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

示例1: payments_confirm

def payments_confirm(request, addon_id, addon):
    data = {}
    # TODO(solitude): remove all references to AddonPaymentData.
    if waffle.flag_is_active(request, 'solitude-payments'):
        data = client.get_seller_paypal_if_exists(addon) or {}

    adp, created = AddonPaymentData.objects.safer_get_or_create(addon=addon)
    if not data:
        data = model_to_dict(adp)

    form = PaypalPaymentData(request.POST or data)
    if request.method == 'POST' and form.is_valid():
        if waffle.flag_is_active(request, 'solitude-payments'):
            # TODO(solitude): when the migration of data is completed, we
            # will be able to remove this.
            pk = client.create_seller_for_pay(addon)
            client.patch_seller_paypal(pk=pk, data=form.cleaned_data)

        # TODO(solitude): remove this.
        adp.update(**form.cleaned_data)
        AppSubmissionChecklist.objects.get(addon=addon).update(payments=True)
        addon.mark_done()
        return redirect('submit.app.done', addon.app_slug)

    return jingo.render(request, 'submit/payments-confirm.html', {
                        'step': 'payments',
                        'addon': addon,
                        'form': form
                        })
开发者ID:dbialer,项目名称:zamboni,代码行数:29,代码来源:views.py


示例2: render_to_response

    def render_to_response(self, context):

        # Allow superusers to set ?dwft_bypass_teamwork=1
        # while viewing a transcript.
        flag_is_active(self.request, 'bypass_teamwork')

        return super(TranscriptDetailView, self).render_to_response(context)
开发者ID:aruneral01,项目名称:fanscribed,代码行数:7,代码来源:views.py


示例3: _check_readonly

    def _check_readonly(request, *args, **kwargs):
        if not flag_is_active(request, 'kumaediting'):
            raise ReadOnlyException("kumaediting")
        elif flag_is_active(request, 'kumabanned'):
            raise ReadOnlyException("kumabanned")

        return view(request, *args, **kwargs)
开发者ID:FrankBian,项目名称:kuma,代码行数:7,代码来源:decorators.py


示例4: test

def test(request):
    c = {}

    if waffle.flag_is_active(request, 'feature1'):
        c["feature11"] = "View Feature 1 is live!"
    else:
        c["feature11"] = "View Feature 1 is not available right now"

    # question feature
    users = User.objects.all()

    c['question_array'] = []
    if waffle.flag_is_active(request, 'question'):
        for user in users:
            questions = Question.objects.filter(user=user.id)
            c['question_array'].append("")
            c['question_array'].append(user.username + ":")
            if questions:
                for question in questions:
                    c['question_array'].append(question.text)
            else:
                c['question_array'].append("Hasn't asked any questions... sad.")

    if waffle.flag_is_active(request, 'answer'):
        c["answer_array"] = Answer.objects.all()

    c['cookie_answer'] = request.COOKIES.get('dwf_answer')
    c['cookie_question'] = request.COOKIES.get('dwf_question')
    c['cookie_feature1'] = request.COOKIES.get('dwf_feature1')

    return render_to_response('test.html',c, context_instance = RequestContext(request))
开发者ID:davinwong,项目名称:feature_flipper_demo_server,代码行数:31,代码来源:views.py


示例5: payment

def payment(request, status=None):
    # Note this is not post required, because PayPal does not reply with a
    # POST but a GET, that's a sad face.
    pre, created = PreApprovalUser.objects.safer_get_or_create(user=request.amo_user)

    context = {"preapproval": pre, "currency": CurrencyForm(initial={"currency": pre.currency or "USD"})}

    if status:
        data = request.session.get("setup-preapproval", {})

        context["status"] = status

        if status == "complete":
            # The user has completed the setup at PayPal and bounced back.
            if "setup-preapproval" in request.session:
                if waffle.flag_is_active(request, "solitude-payments"):
                    client.put_preapproval(data={"uuid": request.amo_user}, pk=data["solitude-key"])

                paypal_log.info(u"Preapproval key created: %s" % request.amo_user.pk)
                amo.log(amo.LOG.PREAPPROVAL_ADDED)
                # TODO(solitude): once this is turned off, we will want to
                # keep preapproval table populated with something, perhaps
                # a boolean inplace of pre-approval key.
                pre.update(paypal_key=data.get("key"), paypal_expiry=data.get("expiry"))

                # If there is a target, bounce to it and don't show a message
                # we'll let whatever set this up worry about that.
                if data.get("complete"):
                    return http.HttpResponseRedirect(data["complete"])

                messages.success(request, _("You're all set for instant app purchases with PayPal."))
                del request.session["setup-preapproval"]

        elif status == "cancel":
            # The user has chosen to cancel out of PayPal. Nothing really
            # to do here, PayPal just bounce to the cancel page if defined.
            if data.get("cancel"):
                return http.HttpResponseRedirect(data["cancel"])

            messages.success(request, _("Your payment pre-approval has been cancelled."))

        elif status == "remove":
            # The user has an pre approval key set and chooses to remove it
            if waffle.flag_is_active(request, "solitude-payments"):
                other = client.lookup_buyer_paypal(request.amo_user)
                if other:
                    client.patch_buyer_paypal(pk=other["resource_pk"], data={"key": ""})

            if pre.paypal_key:
                # TODO(solitude): again, we'll want to maintain some local
                # state in zamboni, so this will probably change to a
                # boolean in the future.
                pre.update(paypal_key="")

                amo.log(amo.LOG.PREAPPROVAL_REMOVED)
                messages.success(request, _("Your payment pre-approval has been disabled."))
                paypal_log.info(u"Preapproval key removed for user: %s" % request.amo_user)

    return jingo.render(request, "account/payment.html", context)
开发者ID:jvillalobos,项目名称:zamboni,代码行数:59,代码来源:views.py


示例6: test_flag_all_sites_override

    def test_flag_all_sites_override(self):
        name = 'sample'
        Flag.objects.create(name=name, everyone=True, site=self.site1)

        self.assertTrue(waffle.flag_is_active(get(), name))

        with self.settings(SITE_ID=2):
            self.assertTrue(waffle.flag_is_active(get(), name))
开发者ID:evilkost,项目名称:django-waffle,代码行数:8,代码来源:test_sites.py


示例7: test_testing_disabled_flag

    def test_testing_disabled_flag(self):
        Flag.objects.create(name='foo')
        request = get(dwft_foo='1')
        assert not waffle.flag_is_active(request, 'foo')
        assert not hasattr(request, 'waffle_tests')

        request = get(dwft_foo='0')
        assert not waffle.flag_is_active(request, 'foo')
        assert not hasattr(request, 'waffle_tests')
开发者ID:ntoll,项目名称:django-waffle,代码行数:9,代码来源:test_waffle.py


示例8: _wrapped_view

        def _wrapped_view(request, *args, **kwargs):
            if flag_name.startswith('!'):
                active = not flag_is_active(request, flag_name[1:])
            else:
                active = flag_is_active(request, flag_name)

            if not active:
                raise Http404
            return view(request, *args, **kwargs)
开发者ID:evilkost,项目名称:django-waffle,代码行数:9,代码来源:decorators.py


示例9: dispatch

    def dispatch(self, request, *args, **kwargs):
        if self.waffle_flag.startswith('!'):
            active = not flag_is_active(request, self.waffle_flag[1:])
        else:
            active = flag_is_active(request, self.waffle_flag)

        if not active:
            raise Http404
        return super(WaffleFlagMixin, self).dispatch(request, *args, **kwargs)
开发者ID:nikdoof,项目名称:vapemap,代码行数:9,代码来源:mixins.py


示例10: test_flag_existed_and_was_null

    def test_flag_existed_and_was_null(self):
        Flag.objects.create(name="foo", everyone=None)

        with override_flag("foo", active=True):
            assert waffle.flag_is_active(req(), "foo")

        with override_flag("foo", active=False):
            assert not waffle.flag_is_active(req(), "foo")

        assert Flag.objects.get(name="foo").everyone is None
开发者ID:webus,项目名称:django-waffle,代码行数:10,代码来源:test_testutils.py


示例11: test_flag_did_not_exist

    def test_flag_did_not_exist(self):
        assert not Flag.objects.filter(name='foo').exists()

        with override_flag('foo', active=True):
            assert waffle.flag_is_active(req(), 'foo')

        with override_flag('foo', active=False):
            assert not waffle.flag_is_active(req(), 'foo')

        assert not Flag.objects.filter(name='foo').exists()
开发者ID:DjangoBD,项目名称:django-waffle,代码行数:10,代码来源:test_testutils.py


示例12: test_flag_existed_and_was_null

    def test_flag_existed_and_was_null(self):
        waffle.get_waffle_flag_model().objects.create(name='foo', everyone=None)

        with override_flag('foo', active=True):
            assert waffle.flag_is_active(req(), 'foo')

        with override_flag('foo', active=False):
            assert not waffle.flag_is_active(req(), 'foo')

        assert waffle.get_waffle_flag_model().objects.get(name='foo').everyone is None
开发者ID:jsocol,项目名称:django-waffle,代码行数:10,代码来源:test_testutils.py


示例13: test_flag_existed_and_was_active

    def test_flag_existed_and_was_active(self):
        Flag.objects.create(name='foo', everyone=True)

        with override_flag('foo', active=True):
            assert waffle.flag_is_active(req(), 'foo')

        with override_flag('foo', active=False):
            assert not waffle.flag_is_active(req(), 'foo')

        assert Flag.objects.get(name='foo').everyone
开发者ID:DjangoBD,项目名称:django-waffle,代码行数:10,代码来源:test_testutils.py


示例14: test_custom_segment

    def test_custom_segment(self):
        Flag.objects.create(name='flag-1', custom_segment=(
            '{"even_numbers": 1}'
        ))
        Flag.objects.create(name='flag-2', custom_segment=(
            '{"even_numbers": 2}'
        ))

        request = get()
        self.assertFalse(waffle.flag_is_active(request, 'flag-1'))
        self.assertTrue(waffle.flag_is_active(request, 'flag-2'))
开发者ID:sirex,项目名称:django-waffle,代码行数:11,代码来源:test_waffle.py


示例15: test_cache_is_flushed_by_testutils_even_in_transaction

    def test_cache_is_flushed_by_testutils_even_in_transaction(self):
        waffle.get_waffle_flag_model().objects.create(name='foo', everyone=True)

        with transaction.atomic():
            with override_flag('foo', active=True):
                assert waffle.flag_is_active(req(), 'foo')

            with override_flag('foo', active=False):
                assert not waffle.flag_is_active(req(), 'foo')

        assert waffle.flag_is_active(req(), 'foo')
开发者ID:jsocol,项目名称:django-waffle,代码行数:11,代码来源:test_testutils.py


示例16: test_testing_flag

    def test_testing_flag(self):
        Flag.objects.create(name="foo", testing=True)
        request = get(dwft_foo="1")
        assert waffle.flag_is_active(request, "foo")
        assert "foo" in request.waffle_tests
        assert request.waffle_tests["foo"]

        request = get(dwft_foo="0")
        assert not waffle.flag_is_active(request, "foo")
        assert "foo" in request.waffle_tests
        assert not request.waffle_tests["foo"]
开发者ID:jlongster,项目名称:django-waffle,代码行数:11,代码来源:test_waffle.py


示例17: akismet_parameter_overrides

 def akismet_parameter_overrides(self):
     """
     Get parameter overrides based on user's waffle flags.
     """
     parameters = {}
     if flag_is_active(self.request, constants.SPAM_ADMIN_FLAG):
         parameters['user_role'] = 'administrator'
     if flag_is_active(self.request, constants.SPAM_SPAMMER_FLAG):
         parameters['comment_author'] = 'viagra-test-123'
     if flag_is_active(self.request, constants.SPAM_TESTING_FLAG):
         parameters['is_test'] = True
     return parameters
开发者ID:MekliCZ,项目名称:kuma,代码行数:12,代码来源:forms.py


示例18: test_testing_flag

    def test_testing_flag(self):
        Flag.objects.create(name="foo", testing=True)
        request = get(dwft_foo="1")
        assert waffle.flag_is_active(request, "foo")
        assert "foo" in request.waffle_tests
        assert request.waffle_tests["foo"]

        # GET param should override cookie
        request = get(dwft_foo="0")
        request.COOKIES["dwft_foo"] = "True"
        assert not waffle.flag_is_active(request, "foo")
        assert "foo" in request.waffle_tests
        assert not request.waffle_tests["foo"]
开发者ID:agriffis,项目名称:django-waffle,代码行数:13,代码来源:test_waffle.py


示例19: _set_packaged_errors

 def _set_packaged_errors(self):
     """Add packaged-app submission errors for incompatible platforms."""
     devices = self._get_combined()
     bad_android = (
         not waffle.flag_is_active(self.request, 'android-packaged') and
         ('android-mobile' in devices or 'android-tablet' in devices)
     )
     bad_desktop = (
         not waffle.flag_is_active(self.request, 'desktop-packaged') and
         'desktop' in devices
     )
     if bad_android or bad_desktop:
         self._errors['free_platforms'] = self._errors['paid_platforms'] = (
             self.ERRORS['packaged'])
开发者ID:andymckay,项目名称:zamboni,代码行数:14,代码来源:forms.py


示例20: _wrapped_view

        def _wrapped_view(request, *args, **kwargs):
            if flag_name.startswith('!'):
                active = not flag_is_active(request, flag_name[1:])
            else:
                active = flag_is_active(request, flag_name)

            if not active:
                response_to_redirect_to = get_response_to_redirect(redirect_to)
                if response_to_redirect_to:
                    return response_to_redirect_to
                else:
                    raise Http404

            return view(request, *args, **kwargs)
开发者ID:ColorGenomics,项目名称:django-waffle,代码行数:14,代码来源:decorators.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python waffle.sample_is_active函数代码示例发布时间:2022-05-26
下一篇:
Python waffle.cache_switch函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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