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


Python messages.error函数代码示例

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


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

示例1: refund_reason

def refund_reason(request, contribution, wizard):
    addon = contribution.addon
    if not 'request' in wizard.get_progress():
        return redirect('support', contribution.pk, 'request')

    if contribution.transaction_id is None:
        messages.error(request,
            _('A refund cannot be applied for yet. Please try again later. '
              'If this error persists contact [email protected]'))
        paypal_log.info('Refund requested for contribution with no '
                        'transaction_id: %r' % contribution.pk)
        return redirect('account.purchases')

    if contribution.is_instant_refund():
        try:
            paypal.refund(contribution.paykey)
        except PaypalError, e:
            paypal_log.error('Paypal error with refund', exc_info=True)
            messages.error(request, _('There was an error with your instant '
                                      'refund.'))
            contribution.record_failed_refund(e)
            return redirect('account.purchases')

        refund = contribution.enqueue_refund(amo.REFUND_APPROVED_INSTANT)
        paypal_log.info('Refund %r issued for contribution %r' %
                        (refund.pk, contribution.pk))
        # Note: we have to wait for PayPal to issue an IPN before it's
        # completely refunded.
        messages.success(request, _('Refund is being processed.'))
        return redirect('account.purchases')
开发者ID:gkoberger,项目名称:zamboni,代码行数:30,代码来源:views.py

示例2: refund_reason

def refund_reason(request, contribution, wizard):
    if not contribution.can_we_refund():
        return http.HttpResponseForbidden()

    addon = contribution.addon
    if not 'request' in wizard.get_progress():
        return redirect('support', contribution.pk, 'request')

    if contribution.transaction_id is None:
        messages.error(request,
            _('A refund cannot be applied for yet. Please try again later. '
              'If this error persists contact [email protected]'))
        paypal_log.info('Refund requested for contribution with no '
                        'transaction_id: %r' % contribution.pk)
        return redirect('account.purchases')

    if contribution.is_instant_refund():
        try:
            paypal.refund(contribution.paykey)
        except PaypalError:
            paypal_log.error('Paypal error with refund', exc_info=True)
            messages.error(request, _('There was an error with your instant '
                                      'refund.'))
            return redirect('account.purchases')

        refund = contribution.enqueue_refund(amo.REFUND_APPROVED_INSTANT)
        paypal_log.info('Refund %r issued for contribution %r' %
                        (refund.pk, contribution.pk))
        # Note: we have to wait for PayPal to issue an IPN before it's
        # completely refunded.
        messages.success(request, _('Refund is being processed.'))
        return redirect('account.purchases')

    form = forms.ContactForm(request.POST or None)
    if request.method == 'POST' and form.is_valid():
        reason = form.cleaned_data['text']
        template = jingo.render_to_string(request,
            wizard.tpl('emails/refund-request.txt'),
            context={'product': addon,
                     'form': form,
                     'user': request.amo_user,
                     'contribution': contribution,
                     'refund_url': contribution.get_absolute_refund_url(),
                     'refund_reason': reason})
        log.info('Refund request sent by user: %s for addon: %s' %
                 (request.amo_user.pk, addon.pk))

        # L10n: %s is the app name.
        support_mail(_(u'New Refund Request for %s' % addon.name),
                     template, sender=settings.NOBODY_EMAIL,
                     recipients=[smart_str(addon.support_email)])

        # Add this refund request to the queue.
        contribution.enqueue_refund(amo.REFUND_PENDING, reason)
        return redirect(reverse('support',
                                args=[contribution.pk, 'refund-sent']))

    return wizard.render(request, wizard.tpl('refund.html'),
                         {'product': addon, 'contribution': contribution,
                          'form': form, 'title': _('Request Refund')})
开发者ID:beenishkhan,项目名称:zamboni,代码行数:60,代码来源:views.py

示例3: bango_portal_from_package

def bango_portal_from_package(request, package_id):
    response = _redirect_to_bango_portal(package_id, "package_id: %s" % package_id)
    if "Location" in response:
        return HttpResponseRedirect(response["Location"])
    else:
        message = json.loads(response.content).get("__all__", response.content)[0]
        messages.error(request, message)
        return HttpResponseRedirect(reverse("lookup.home"))
开发者ID:vinu76jsr,项目名称:zamboni,代码行数:8,代码来源:views.py

示例4: app_review

def app_review(request, addon):
    version = addon.latest_version
    resp = None
    try:
        resp = _review(request, addon, version)
    except SigningError, exc:
        transaction.rollback()
        messages.error(request, "Signing Error: %s" % exc)
        transaction.commit()
        return redirect(reverse("reviewers.apps.review", args=[addon.app_slug]))
开发者ID:steekid,项目名称:zamboni,代码行数:10,代码来源:views.py

示例5: bango_portal_from_package

def bango_portal_from_package(request, package_id):
    response = _redirect_to_bango_portal(int(package_id),
                                         'package_id: %s' % package_id)
    if 'Location' in response:
        return HttpResponseRedirect(response['Location'])
    else:
        message = (json.loads(response.content)
                       .get('__all__', response.content)[0])
        messages.error(request, message)
        return HttpResponseRedirect(reverse('lookup.home'))
开发者ID:chusiang,项目名称:zamboni,代码行数:10,代码来源:views.py

示例6: user_delete

def user_delete(request, user_id):
    delete_form = DeleteUserForm(request.POST)
    if not delete_form.is_valid():
        messages.error(request, delete_form.errors)
        return HttpResponseRedirect(reverse('lookup.user_summary',
                                    args=[user_id]))

    user = get_object_or_404(UserProfile, pk=user_id)
    user.deleted = True
    user.save()  # Must call the save function to delete user.
    amo.log(amo.LOG.DELETE_USER_LOOKUP, user,
            details={'reason': delete_form.cleaned_data['delete_reason']},
            user=request.amo_user)

    return HttpResponseRedirect(reverse('lookup.user_summary', args=[user_id]))
开发者ID:chrisdavidmills,项目名称:zamboni,代码行数:15,代码来源:views.py

示例7: transaction_refund

def transaction_refund(request, uuid):
    contrib = get_object_or_404(Contribution, uuid=uuid,
                                type=amo.CONTRIB_PURCHASE)
    if contrib.has_refund():
        messages.error(request, _('A refund has already been processed.'))
        return redirect(reverse('lookup.transaction_summary', args=[uuid]))

    form = TransactionRefundForm(request.POST)
    if not form.is_valid():
        messages.error(request, str(form.errors))
        return redirect(reverse('lookup.transaction_summary', args=[uuid]))

    try:
        res = client.api.bango.refund.post({'uuid': contrib.transaction_id})
    except (HttpClientError, HttpServerError):
        # Either doing something not supposed to or Solitude had an issue.
        log.exception('Refund error: %s' % uuid)
        messages.error(
            request,
            _('You cannot make a refund request for this transaction.'))
        return redirect(reverse('lookup.transaction_summary', args=[uuid]))

    if res['status'] == STATUS_PENDING:
        # Create pending Refund.
        contrib.enqueue_refund(
            status=amo.REFUND_PENDING,
            refund_reason=form.cleaned_data['refund_reason'],
            user=request.amo_user)
        log.info('Refund pending: %s' % uuid)
        email_buyer_refund_pending(contrib)
        messages.success(
            request, _('Refund for this transaction now pending.'))
    elif res['status'] == STATUS_COMPLETED:
        # Create approved Refund.
        contrib.enqueue_refund(
            status=amo.REFUND_APPROVED,
            refund_reason=form.cleaned_data['refund_reason'],
            user=request.amo_user)
        log.info('Refund approved: %s' % uuid)
        email_buyer_refund_approved(contrib)
        messages.success(
            request, _('Refund for this transaction successfully approved.'))
    elif res['status'] == STATUS_FAILED:
        # Bango no like.
        log.error('Refund failed: %s' % uuid)
        messages.error(
            request, _('Refund request for this transaction failed.'))

    return redirect(reverse('lookup.transaction_summary', args=[uuid]))
开发者ID:fwenzel,项目名称:zamboni,代码行数:49,代码来源:views.py

示例8: refund_reason

def refund_reason(request, contribution, wizard):
    addon = contribution.addon
    if not 'request' in wizard.get_progress():
        return redirect('support', contribution.pk, 'request')

    if contribution.transaction_id is None:
        messages.error(request,
            _('A refund cannot be applied for yet. Please try again later. '
              'If this error persists contact [email protected]'))
        paypal_log.info('Refund requested for contribution with no '
                        'transaction_id: %r' % contribution.pk)
        return redirect('account.purchases')

    if contribution.is_refunded():
        messages.error(request, _('This has already been refunded.'))
        paypal_log.info('Already refunded: %s' % contribution.pk)
        return redirect('account.purchases')

    if contribution.is_instant_refund():
        if waffle.flag_is_active(request, 'solitude-payments'):
            try:
                client.post_refund(data={'uuid': contribution.transaction_id})
            except client.Error, e:
                paypal_log.error('Paypal error with refund', exc_info=True)
                messages.error(request, _('There was an error with your '
                                          'instant refund.'))
                contribution.record_failed_refund(e, request.amo_user)
                return redirect('account.purchases')
        else:
            # TODO(solitude): remove this.
            try:
                paypal.refund(contribution.paykey)
            except PaypalError, e:
                paypal_log.error('Paypal error with refund', exc_info=True)
                messages.error(request, _('There was an error with your '
                                          'instant refund.'))
                contribution.record_failed_refund(e, request.amo_user)
                return redirect('account.purchases')
开发者ID:MaxDumont,项目名称:zamboni,代码行数:38,代码来源:views.py

示例9: transaction_refund

def transaction_refund(request, tx_uuid):
    contrib = get_object_or_404(Contribution, uuid=tx_uuid, type=amo.CONTRIB_PURCHASE)
    refund_contribs = contrib.get_refund_contribs()
    refund_contrib = refund_contribs[0] if refund_contribs.exists() else None

    if refund_contrib:
        messages.error(request, _("A refund has already been processed."))
        return redirect(reverse("lookup.transaction_summary", args=[tx_uuid]))

    form = TransactionRefundForm(request.POST)
    if not form.is_valid():
        return jingo.render(
            request,
            "lookup/transaction_summary.html",
            dict(
                {"uuid": tx_uuid, "tx_refund_form": form, "tx_form": TransactionSearchForm()}.items()
                + _transaction_summary(tx_uuid).items()
            ),
        )

    data = {"uuid": contrib.transaction_id, "manual": form.cleaned_data["manual"]}
    if settings.BANGO_FAKE_REFUNDS:
        data["fake_response_status"] = {"responseCode": form.cleaned_data["fake"]}

    try:
        res = client.api.bango.refund.post(data)
    except (HttpClientError, HttpServerError):
        # Either doing something not supposed to or Solitude had an issue.
        log.exception("Refund error: %s" % tx_uuid)
        messages.error(request, _("You cannot make a refund request for this transaction."))
        return redirect(reverse("lookup.transaction_summary", args=[tx_uuid]))

    if res["status"] in [PENDING, COMPLETED]:
        # Create refund Contribution by cloning the payment Contribution.
        refund_contrib = Contribution.objects.get(id=contrib.id)
        refund_contrib.id = None
        refund_contrib.save()
        refund_contrib.update(
            type=amo.CONTRIB_REFUND,
            related=contrib,
            uuid=hashlib.md5(str(uuid.uuid4())).hexdigest(),
            amount=-refund_contrib.amount if refund_contrib.amount else None,
            transaction_id=res["uuid"],
        )

    if res["status"] == PENDING:
        # Create pending Refund.
        refund_contrib.enqueue_refund(
            amo.REFUND_PENDING, request.amo_user, refund_reason=form.cleaned_data["refund_reason"]
        )
        log.info("Refund pending: %s" % tx_uuid)
        email_buyer_refund_pending(contrib)
        messages.success(request, _("Refund for this transaction now pending."))
    elif res["status"] == COMPLETED:
        # Create approved Refund.
        refund_contrib.enqueue_refund(
            amo.REFUND_APPROVED, request.amo_user, refund_reason=form.cleaned_data["refund_reason"]
        )
        log.info("Refund approved: %s" % tx_uuid)
        email_buyer_refund_approved(contrib)
        messages.success(request, _("Refund for this transaction successfully approved."))
    elif res["status"] == FAILED:
        # Bango no like.
        log.error("Refund failed: %s" % tx_uuid)
        messages.error(request, _("Refund request for this transaction failed."))

    return redirect(reverse("lookup.transaction_summary", args=[tx_uuid]))
开发者ID:vinu76jsr,项目名称:zamboni,代码行数:67,代码来源:views.py

示例10: transaction_refund

def transaction_refund(request, tx_uuid):
    contrib = get_object_or_404(Contribution, uuid=tx_uuid,
                                type=amo.CONTRIB_PURCHASE)
    refund_contribs = contrib.get_refund_contribs()
    refund_contrib = refund_contribs[0] if refund_contribs.exists() else None

    if refund_contrib:
        messages.error(request, _('A refund has already been processed.'))
        return redirect(reverse('lookup.transaction_summary', args=[tx_uuid]))

    form = TransactionRefundForm(request.POST)
    if not form.is_valid():
        messages.error(request, str(form.errors))
        return redirect(reverse('lookup.transaction_summary', args=[tx_uuid]))

    try:
        res = client.api.bango.refund.post({'uuid': contrib.transaction_id})
    except (HttpClientError, HttpServerError):
        # Either doing something not supposed to or Solitude had an issue.
        log.exception('Refund error: %s' % tx_uuid)
        messages.error(
            request,
            _('You cannot make a refund request for this transaction.'))
        return redirect(reverse('lookup.transaction_summary', args=[tx_uuid]))

    if res['status'] in [PENDING, COMPLETED]:
        # Create refund Contribution by cloning the payment Contribution.
        refund_contrib = Contribution.objects.get(id=contrib.id)
        refund_contrib.id = None
        refund_contrib.save()
        refund_contrib.update(
            type=amo.CONTRIB_REFUND, related=contrib,
            uuid=hashlib.md5(str(uuid.uuid4())).hexdigest(),
            amount=-refund_contrib.amount if refund_contrib.amount else None,
            transaction_id=client.get(res['transaction'])['uuid'])

    if res['status'] == PENDING:
        # Create pending Refund.
        refund_contrib.enqueue_refund(
            amo.REFUND_PENDING, request.amo_user,
            refund_reason=form.cleaned_data['refund_reason'])
        log.info('Refund pending: %s' % tx_uuid)
        email_buyer_refund_pending(contrib)
        messages.success(
            request, _('Refund for this transaction now pending.'))
    elif res['status'] == COMPLETED:
        # Create approved Refund.
        refund_contrib.enqueue_refund(
            amo.REFUND_APPROVED, request.amo_user,
            refund_reason=form.cleaned_data['refund_reason'])
        log.info('Refund approved: %s' % tx_uuid)
        email_buyer_refund_approved(contrib)
        messages.success(
            request, _('Refund for this transaction successfully approved.'))
    elif res['status'] == FAILED:
        # Bango no like.
        log.error('Refund failed: %s' % tx_uuid)
        messages.error(
            request, _('Refund request for this transaction failed.'))

    return redirect(reverse('lookup.transaction_summary', args=[tx_uuid]))
开发者ID:almet,项目名称:zamboni,代码行数:61,代码来源:views.py

示例11: refund_reason

def refund_reason(request, contribution, wizard):
    if not contribution.can_we_refund():
        return http.HttpResponseForbidden()

    addon = contribution.addon
    if not "request" in wizard.get_progress():
        return redirect("support", contribution.pk, "request")

    if contribution.transaction_id is None:
        messages.error(
            request,
            _(
                "A refund cannot be applied for yet. Please try again later. "
                "If this error persists contact [email protected]"
            ),
        )
        paypal_log.info("Refund requested for contribution with no " "transaction_id: %r" % contribution.pk)
        return redirect("account.purchases")

    if contribution.is_instant_refund():
        paypal.refund(contribution.paykey)
        # TODO: Consider requiring a refund reason for instant refunds.
        refund = contribution.enqueue_refund(amo.REFUND_APPROVED_INSTANT)
        paypal_log.info("Refund %r issued for contribution %r" % (refund.pk, contribution.pk))
        # Note: we have to wait for PayPal to issue an IPN before it's
        # completely refunded.
        messages.success(request, _("Refund is being processed."))
        return redirect("account.purchases")

    form = forms.ContactForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        reason = form.cleaned_data["text"]
        template = jingo.render_to_string(
            request,
            wizard.tpl("emails/refund-request.txt"),
            context={
                "product": addon,
                "form": form,
                "user": request.amo_user,
                "contribution": contribution,
                "refund_url": contribution.get_absolute_refund_url(),
                "refund_reason": reason,
            },
        )
        log.info("Refund request sent by user: %s for addon: %s" % (request.amo_user.pk, addon.pk))

        # L10n: %s is the app name.
        support_mail(
            _(u"New Refund Request for %s" % addon.name),
            template,
            sender=settings.NOBODY_EMAIL,
            recipients=[smart_str(addon.support_email)],
        )

        # Add this refund request to the queue.
        contribution.enqueue_refund(amo.REFUND_PENDING, reason)
        return redirect(reverse("support", args=[contribution.pk, "refund-sent"]))

    return wizard.render(
        request,
        wizard.tpl("refund.html"),
        {"product": addon, "contribution": contribution, "form": form, "title": _("Request Refund")},
    )
开发者ID:pjajara,项目名称:zamboni,代码行数:63,代码来源:views.py


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