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


Python waffle.flag_is_active函数代码示例

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


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


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