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


Python messages.success函数代码示例

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


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

示例1: account_settings

def account_settings(request):
    ctx = {}

    # Don't use `request.amo_user` because it's too cached.
    user = request.user
    if user.is_authenticated():
        amo_user = user.get_profile()
        if request.method == 'POST':
            if 'authorized_apps' in request.POST:
                ids = request.POST.getlist('authorized_apps')
                Token.objects.filter(pk__in=ids).delete()
                form = forms.UserEditForm(None, instance=amo_user)
            else:
                form = forms.UserEditForm(request.POST, instance=amo_user)
                if form.is_valid():
                    form.save()
                    messages.success(request, _('Settings Updated.'))
                    amo.log(amo.LOG.USER_EDITED)
                    response = redirect('account.settings')
                    # TODO: Detect when we're changing the user's
                    # locale and region and bust on '/', bust on
                    # '/settings' for everything else.
                    bust_fragments(response, '/')
                    return response
                else:
                    messages.form_errors(request)
        else:
            form = forms.UserEditForm(None, instance=amo_user)
        tokens = Token.objects.filter(user=user, token_type=ACCESS_TOKEN)
        ctx = {'form': form, 'amouser': amo_user, 'tokens': tokens}
    else:
        if request.method == 'POST':
            messages.success(request, _('Settings Updated.'))

    return jingo.render(request, 'account/settings.html', ctx)
开发者ID:MikeLing,项目名称:zamboni,代码行数:35,代码来源:views.py

示例2: 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

示例3: account_settings

def account_settings(request):
    ctx = {}

    # Don't use `request.amo_user` because it's too cached.
    user = request.user
    if user.is_authenticated():
        amo_user = user.get_profile()
        form = forms.UserEditForm(request.POST or None, instance=amo_user)
        if request.method == 'POST':
            if form.is_valid():
                form.save()
                messages.success(request, _('Settings Updated.'))
                amo.log(amo.LOG.USER_EDITED)
                response = redirect('account.settings')
                # TODO: Detect when we're changing the user's locale and region
                # and bust on '/', bust on '/settings' for everything else.
                bust_fragments(response, '/')
                return response
            else:
                messages.form_errors(request)
        ctx = {'form': form, 'amouser': amo_user}
    else:
        if request.method == 'POST':
            messages.success(request, _('Settings Updated.'))

    return jingo.render(request, 'account/settings.html', ctx)
开发者ID:MaxDumont,项目名称:zamboni,代码行数:26,代码来源:views.py

示例4: 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

示例5: delete_photo

def delete_photo(request):
    request.amo_user.update(picture_type='')
    delete_photo_task.delay(request.amo_user.picture_path)
    log.debug(u'User (%s) deleted photo' % request.amo_user)
    messages.success(request, _('Photo Deleted'))
    amo.log(amo.LOG.USER_EDITED)
    return http.HttpResponse()
开发者ID:MaxDumont,项目名称:zamboni,代码行数:7,代码来源:views.py

示例6: add

def add(request, addon):
    if addon.has_author(request.user):
        # Don't let app owners review their own apps.
        return http.HttpResponseForbidden()

    data = request.POST or None
    form = ReviewForm(data)
    if data and form.is_valid():
        review = Review.objects.create(**_review_details(request, addon, form))
        Addon.objects.invalidate(*[addon])
        amo.log(amo.LOG.ADD_REVIEW, addon, review)
        log.debug('New review: %s' % review.id)
        messages.success(request, _('Your review was successfully added!'))

        # reply_url = addon.get_ratings_url('reply', args=[addon, review.id],
        #                                   add_prefix=False)
        # data = {'name': addon.name,
        #         'rating': '%s out of 5 stars' % details['rating'],
        #         'review': details['body'],
        #         'reply_url': absolutify(reply_url)}

        # emails = addon.values_list('email', flat=True)
        # send_mail('reviews/emails/add_review.ltxt',
        #           u'Mozilla Marketplace User Review: %s' % addon.name,
        #           emails, Context(data), 'new_review')

        return redirect(addon.get_ratings_url('list'))

    return jingo.render(request, 'ratings/add.html',
                        {'product': addon, 'form': form})
开发者ID:albre2252,项目名称:zamboni,代码行数:30,代码来源:views.py

示例7: reply

def reply(request, addon, review_id):
    is_admin = acl.action_allowed(request, 'Addons', 'Edit')
    is_author = acl.check_addon_ownership(request, addon, dev=True)
    if not (is_admin or is_author):
        raise PermissionDenied

    review = get_object_or_404(Review.objects, pk=review_id, addon=addon)
    form = ReviewReplyForm(request.POST or None)
    if form.is_valid():
        d = dict(reply_to=review, addon=addon,
                 defaults=dict(user=request.amo_user))
        reply, new = Review.objects.get_or_create(**d)
        for k, v in _review_details(request, addon, form).items():
            setattr(reply, k, v)
        reply.save()
        action = 'New' if new else 'Edited'
        if new:
            amo.log(amo.LOG.ADD_REVIEW, addon, reply)
        else:
            amo.log(amo.LOG.EDIT_REVIEW, addon, reply)

        log.debug('%s reply to %s: %s' % (action, review_id, reply.id))
        messages.success(request,
                         _('Your reply was successfully added.') if new else
                         _('Your reply was successfully updated.'))

    return http.HttpResponse()
开发者ID:darkwing,项目名称:zamboni,代码行数:27,代码来源:views.py

示例8: abuse

def abuse(request, profile):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, profile, form.cleaned_data["text"])
        messages.success(request, _("Abuse reported."))
        return redirect(profile.get_url_path())
    else:
        return jingo.render(request, "account/abuse.html", {"abuse_form": form, "profile": profile})
开发者ID:jvillalobos,项目名称:zamboni,代码行数:8,代码来源:views.py

示例9: admin_edit

def admin_edit(request, user_id):
    amouser = get_object_or_404(UserProfile, pk=user_id)
    form = forms.AdminUserEditForm(request.POST or None, request.FILES or None, instance=amouser)
    if request.method == "POST" and form.is_valid():
        form.save()
        messages.success(request, _("Profile Updated"))
        return redirect("zadmin.index")
    return jingo.render(request, "account/settings.html", {"form": form, "amouser": amouser})
开发者ID:jvillalobos,项目名称:zamboni,代码行数:8,代码来源:views.py

示例10: abuse_recaptcha

def abuse_recaptcha(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data["text"])
        messages.success(request, _("Abuse reported."))
        return redirect(addon.get_url_path())
    else:
        return jingo.render(request, "detail/abuse_recaptcha.html", {"product": addon, "abuse_form": form})
开发者ID:dbialer,项目名称:zamboni,代码行数:8,代码来源:views.py

示例11: abuse

def abuse(request, addon):
    form = AbuseForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        send_abuse_report(request, addon, form.cleaned_data['text'])
        messages.success(request, _('Abuse reported.'))
        return redirect(addon.get_url_path())
    else:
        return jingo.render(request, 'detail/abuse.html',
                            {'product': addon, 'abuse_form': form})
开发者ID:MaxDumont,项目名称:zamboni,代码行数:9,代码来源:views.py

示例12: admin_edit

def admin_edit(request, user_id):
    amouser = get_object_or_404(UserProfile, pk=user_id)
    form = forms.AdminUserEditForm(request.POST or None, request.FILES or None,
                                   instance=amouser)
    if request.method == 'POST' and form.is_valid():
        form.save()
        messages.success(request, _('Profile Updated'))
        return redirect('zadmin.index')
    return jingo.render(request, 'account/settings.html',
                        {'form': form, 'amouser': amouser})
开发者ID:MaxDumont,项目名称:zamboni,代码行数:10,代码来源:views.py

示例13: delete

def delete(request):
    amouser = request.amo_user
    form = forms.UserDeleteForm(request.POST or None, request=request)
    if request.method == "POST" and form.is_valid():
        messages.success(request, _("Profile Deleted"))
        amouser.anonymize()
        logout(request)
        form = None
        return redirect("users.login")
    return jingo.render(request, "account/delete.html", {"form": form, "amouser": amouser})
开发者ID:jvillalobos,项目名称:zamboni,代码行数:10,代码来源:views.py

示例14: delete

def delete(request):
    amouser = request.amo_user
    form = forms.UserDeleteForm(request.POST or None, request=request)
    if request.method == 'POST' and form.is_valid():
        messages.success(request, _('Profile Deleted'))
        amouser.anonymize()
        logout(request)
        form = None
        return redirect('users.login')
    return jingo.render(request, 'account/delete.html',
                        {'form': form, 'amouser': amouser})
开发者ID:MaxDumont,项目名称:zamboni,代码行数:11,代码来源:views.py

示例15: motd

def motd(request):
    form = None
    motd = unmemoized_get_config('mkt_reviewers_motd')
    if acl.action_allowed(request, 'AppReviewerMOTD', 'Edit'):
        form = MOTDForm(request.POST or None, initial={'motd': motd})
    if form and request.method == 'POST' and form.is_valid():
        set_config(u'mkt_reviewers_motd', form.cleaned_data['motd'])
        messages.success(request, _('Changes successfully saved.'))
        return redirect(reverse('reviewers.apps.motd'))
    data = context(request, form=form)
    return render(request, 'reviewers/motd.html', data)
开发者ID:petercpg,项目名称:zamboni,代码行数:11,代码来源:views.py


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