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

Python utils.render函数代码示例

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

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



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

示例1: payments

def payments(request, addon_id, addon, webapp=False):
    premium_form = forms_payments.PremiumForm(
        request.POST or None, request=request, addon=addon,
        user=request.user)

    region_form = forms.RegionForm(
        request.POST or None, product=addon, request=request)

    if request.method == 'POST':

        if region_form.is_valid() and premium_form.is_valid():
            region_form.save()
            premium_form.save()
            messages.success(request, _('Changes successfully saved.'))
            return redirect(addon.get_dev_url('payments'))

    return render(request, 'developers/payments/premium.html',
                  {'addon': addon, 'webapp': webapp,
                   'region_form': region_form,
                   'is_paid': (addon.premium_type in mkt.ADDON_PREMIUMS or
                               addon.premium_type == mkt.ADDON_FREE_INAPP),
                   'form': premium_form,
                   'is_fxos': DEVICE_GAIA.id in (
                       addon.addondevicetype_set.values_list('device_type',
                                                             flat=True)),
                   'PLATFORMS_NAMES': PLATFORMS_NAMES})
开发者ID:digideskio,项目名称:zamboni,代码行数:26,代码来源:views_payments.py


示例2: moderatelog_detail

def moderatelog_detail(request, eventlog_id):
    log = get_object_or_404(
        ActivityLog.objects.editor_events(), pk=eventlog_id)
    review = None
    if len(log.arguments) > 1 and isinstance(log.arguments[1], Review):
        review = log.arguments[1]

    form = ModerateLogDetailForm(request.POST or None)
    is_admin = acl.action_allowed(request, 'ReviewerAdminTools', 'View')
    can_undelete = review and review.deleted and (
        is_admin or request.user.pk == log.user.pk)

    if (request.method == 'POST' and form.is_valid() and
            form.cleaned_data['action'] == 'undelete'):
        if not can_undelete:
            if not review:
                raise RuntimeError('Review doesn`t exist.')
            elif not review.deleted:
                raise RuntimeError('Review isn`t deleted.')
            else:
                raise PermissionDenied
        ReviewerScore.award_moderation_points(
            log.user, review.addon, review.id, undo=True)
        review.undelete()
        return redirect('reviewers.apps.moderatelog.detail', eventlog_id)
    data = context(request, log=log, form=form, review=review,
                   can_undelete=can_undelete)
    return render(request, 'reviewers/moderatelog_detail.html', data)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:28,代码来源:views.py


示例3: website_abuse

def website_abuse(request, website):
    reports = AbuseReport.objects.filter(website=website).order_by('-created')
    total = reports.count()
    reports = paginate(request, reports, count=total)
    return render(request, 'reviewers/abuse.html',
                  context(request, item=website, reports=reports,
                          total=total))
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:views.py


示例4: logs

def logs(request):
    data = request.GET.copy()

    if not data.get('start') and not data.get('end'):
        today = datetime.date.today()
        data['start'] = today - datetime.timedelta(days=30)

    form = forms.ReviewLogForm(data)

    approvals = ActivityLog.objects.review_queue(webapp=True)

    if form.is_valid():
        data = form.cleaned_data
        if data.get('start'):
            approvals = approvals.filter(created__gte=data['start'])
        if data.get('end'):
            approvals = approvals.filter(created__lt=data['end'])
        if data.get('search'):
            term = data['search']
            approvals = approvals.filter(
                Q(commentlog__comments__icontains=term) |
                Q(applog__addon__name__localized_string__icontains=term) |
                Q(applog__addon__app_slug__icontains=term) |
                Q(user__display_name__icontains=term) |
                Q(user__email__icontains=term)).distinct()

    pager = paginate(request, approvals, 50)
    data = context(request, form=form, pager=pager, ACTION_DICT=mkt.LOG_BY_ID,
                   tab='logs')
    return render(request, 'reviewers/logs.html', data)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:30,代码来源:views.py


示例5: user_summary

def user_summary(request, user_id):
    user = get_object_or_404(UserProfile, pk=user_id)
    is_admin = acl.action_allowed(request, 'Users', 'Edit')
    app_summary = _app_summary(user.pk)
    # All refunds that this user has requested (probably as a consumer).
    req = Refund.objects.filter(contribution__user=user)
    # All instantly-approved refunds that this user has requested.
    appr = req.filter(status=mkt.REFUND_APPROVED_INSTANT)
    refund_summary = {'approved': appr.count(),
                      'requested': req.count()}
    user_addons = user.addons.order_by('-created')
    user_addons = paginate(request, user_addons, per_page=15)

    payment_data = (AddonPaymentData.objects.filter(addon__authors=user)
                    .values(*AddonPaymentData.address_fields())
                    .distinct())

    # If the user is deleted, get the log detailing the delete.
    try:
        delete_log = ActivityLog.objects.for_user(user).filter(
            action=mkt.LOG.DELETE_USER_LOOKUP.id)[0]
    except IndexError:
        delete_log = None

    group_membership_formset = APIGroupMembershipFormSet()

    provider_portals = get_payment_provider_portals(user=user)
    return render(request, 'lookup/user_summary.html',
                  {'account': user, 'app_summary': app_summary,
                   'delete_form': DeleteUserForm(), 'delete_log': delete_log,
                   'is_admin': is_admin, 'refund_summary': refund_summary,
                   'user_addons': user_addons, 'payment_data': payment_data,
                   'provider_portals': provider_portals,
                   'group_membership_formset': group_membership_formset})
开发者ID:digideskio,项目名称:zamboni,代码行数:34,代码来源:views.py


示例6: app_abuse

def app_abuse(request, addon):
    reports = AbuseReport.objects.filter(addon=addon).order_by('-created')
    total = reports.count()
    reports = paginate(request, reports, count=total)
    return render(request, 'reviewers/abuse.html',
                  context(request, item=addon, reports=reports,
                          total=total))
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:views.py


示例7: api

def api(request):
    roles = request.user.groups.filter(name='Admins').exists()
    form = APIConsumerForm()
    if roles:
        messages.error(request,
                       _('Users with the admin role cannot use the API.'))

    elif request.method == 'POST':
        if 'delete' in request.POST:
            try:
                consumer = Access.objects.get(pk=request.POST.get('consumer'),
                                              user=request.user)
                consumer.delete()
            except Access.DoesNotExist:
                messages.error(request, _('No such API key.'))
        else:
            access = Access.create_for_user(request.user)
            form = APIConsumerForm(request.POST, instance=access)
            if form.is_valid():
                form.save()
                messages.success(request, _('New API key generated.'))
            else:
                access.delete()
    consumers = list(Access.objects.filter(user=request.user))
    return render(request, 'developers/api.html',
                  {'consumers': consumers, 'roles': roles, 'form': form,
                   'domain': settings.DOMAIN, 'site_url': settings.SITE_URL})
开发者ID:jasonthomas,项目名称:zamboni,代码行数:27,代码来源:views.py


示例8: browse

def browse(request, viewer, key=None, type_='file'):
    form = forms.FileCompareForm(request.POST or None, addon=viewer.addon,
                                 initial={'left': viewer.file})
    response = check_compare_form(request, form)
    if response:
        return response

    data = setup_viewer(request, viewer.file)
    data['viewer'] = viewer
    data['poll_url'] = reverse('mkt.files.poll', args=[viewer.file.id])
    data['form'] = form

    if not viewer.is_extracted():
        extract_file(viewer.file.id)

    if viewer.is_extracted():
        data.update({'status': True, 'files': viewer.get_files()})
        key = viewer.get_default(key)
        if key not in data['files']:
            raise http.Http404

        viewer.select(key)
        data['key'] = key

        binary = viewer.is_binary()
        if (not viewer.is_directory() and
                (not binary or binary != 'image')):
            data['content'] = viewer.read_file()

    else:
        extract_file.delay(viewer.file.id)

    tmpl = 'content' if type_ == 'fragment' else 'viewer'
    return render(request, 'fileviewer/%s.html' % tmpl, data)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:34,代码来源:views.py


示例9: authorize

def authorize(request):
    if request.method == 'GET' and 'oauth_token' in request.GET:
        try:
            t = Token.objects.get(token_type=REQUEST_TOKEN,
                                  key=request.GET['oauth_token'])
        except Token.DoesNotExist:
            log.error('Invalid OAuth request for obtaining user authorization')
            return HttpResponse(status=401)
        return render(request, 'developers/oauth_authorize.html',
                      {'app_name': t.creds.app_name,
                       'oauth_token': request.GET['oauth_token']})
    elif request.method == 'POST':
        token = request.POST.get('oauth_token')
        try:
            t = Token.objects.get(token_type=REQUEST_TOKEN,
                                  key=token)
        except Token.DoesNotExist:
            return HttpResponse(status=401)
        if 'grant' in request.POST:
            t.user = request.user
            t.save()
            return HttpResponseRedirect(
                urlparams(t.creds.redirect_uri, oauth_token=token,
                          oauth_verifier=t.verifier))
        elif 'deny' in request.POST:
            t.delete()
            return HttpResponse(status=200)
    else:
        log.error('Invalid OAuth request for user access authorization')
        return HttpResponse(status=401)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:30,代码来源:oauth.py


示例10: file_validation

def file_validation(request, addon_id, addon, file_id):
    file = get_object_or_404(File, id=file_id)

    v = addon.get_dev_url('json_file_validation', args=[file.id])
    return render(request, 'developers/validation.html',
                  dict(validate_url=v, filename=file.filename,
                       timestamp=file.created, addon=addon))
开发者ID:jasonthomas,项目名称:zamboni,代码行数:7,代码来源:views.py


示例11: monitor

def monitor(request, format=None):

    # For each check, a boolean pass/fail status to show in the template
    status_summary = {}
    results = {}

    checks = ['memcache', 'libraries', 'elastic', 'package_signer', 'path',
              'receipt_signer', 'settings_check', 'solitude']

    for check in checks:
        with statsd.timer('monitor.%s' % check) as timer:
            status, result = getattr(monitors, check)()
        # state is a string. If it is empty, that means everything is fine.
        status_summary[check] = {'state': not status,
                                 'status': status}
        results['%s_results' % check] = result
        results['%s_timer' % check] = timer.ms

    # If anything broke, send HTTP 500.
    status_code = 200 if all(a['state']
                             for a in status_summary.values()) else 500

    if format == '.json':
        return HttpResponse(json.dumps(status_summary), status=status_code)
    ctx = {}
    ctx.update(results)
    ctx['status_summary'] = status_summary

    return render(request, 'services/monitor.html', ctx, status=status_code)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:29,代码来源:views.py


示例12: api

def api(request):
    roles = request.user.groups.filter(name="Admins").exists()
    form = APIConsumerForm()
    if roles:
        messages.error(request, _("Users with the admin role cannot use the API."))

    elif request.method == "POST":
        if "delete" in request.POST:
            try:
                consumer = Access.objects.get(pk=request.POST.get("consumer"), user=request.user)
                consumer.delete()
            except Access.DoesNotExist:
                messages.error(request, _("No such API key."))
        else:
            access = Access.create_for_user(request.user)
            form = APIConsumerForm(request.POST, instance=access)
            if form.is_valid():
                form.save()
                messages.success(request, _("New API key generated."))
            else:
                access.delete()
    consumers = list(Access.objects.filter(user=request.user))
    return render(
        request,
        "developers/api.html",
        {
            "consumers": consumers,
            "roles": roles,
            "form": form,
            "domain": settings.DOMAIN,
            "site_url": settings.SITE_URL,
        },
    )
开发者ID:pkdevboxy,项目名称:zamboni,代码行数:33,代码来源:views.py


示例13: validate_app

def validate_app(request):
    return render(request, 'developers/validate_app.html', {
        'upload_hosted_url':
            reverse('mkt.developers.standalone_hosted_upload'),
        'upload_packaged_url':
            reverse('mkt.developers.standalone_packaged_upload'),
    })
开发者ID:jasonthomas,项目名称:zamboni,代码行数:7,代码来源:views.py


示例14: transaction_search

def transaction_search(request):
    tx_form = TransactionSearchForm(request.GET)
    if tx_form.is_valid():
        return redirect(reverse('lookup.transaction_summary',
                                args=[tx_form.cleaned_data['q']]))
    else:
        return render(request, 'lookup/home.html', {'tx_form': tx_form})
开发者ID:digideskio,项目名称:zamboni,代码行数:7,代码来源:views.py


示例15: in_app_products

def in_app_products(request, addon_id, addon, webapp=True, account=None):
    owner = acl.check_addon_ownership(request, addon)
    products = addon.inappproduct_set.all()
    new_product = InAppProduct(webapp=addon)
    form = InAppProductForm()

    if addon.origin:
        inapp_origin = addon.origin
    elif addon.guid:
        # Derive a marketplace specific origin out of the GUID.
        # This is for apps that do not specify a custom origin.
        inapp_origin = 'marketplace:{}'.format(addon.guid)
    else:
        # Theoretically this is highly unlikely. A hosted app will
        # always have a domain and a packaged app will always have
        # a generated GUID.
        raise TypeError(
            'Cannot derive origin: no declared origin, no GUID')

    list_url = _fix_origin_link(reverse('in-app-products-list',
                                        kwargs={'origin': inapp_origin}))
    detail_url = _fix_origin_link(reverse('in-app-products-detail',
                                          # {guid} is replaced in JS.
                                          kwargs={'origin': inapp_origin,
                                                  'guid': "{guid}"}))

    return render(request, 'developers/payments/in-app-products.html',
                  {'addon': addon, 'form': form, 'new_product': new_product,
                   'owner': owner, 'products': products, 'form': form,
                   'list_url': list_url, 'detail_url': detail_url,
                   'active_lang': request.LANG.lower()})
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:31,代码来源:views_payments.py


示例16: transactions

def transactions(request):
    form, transactions = _get_transactions(request)
    return render(
        request, 'developers/transactions.html',
        {'form': form, 'CONTRIB_TYPES': mkt.CONTRIB_TYPES,
         'count': transactions.count(),
         'transactions': paginate(request, transactions, per_page=50)})
开发者ID:jasonthomas,项目名称:zamboni,代码行数:7,代码来源:views.py


示例17: app_summary

def app_summary(request, addon_id):
    if unicode(addon_id).isdigit():
        query = {'pk': addon_id}
    else:
        query = {'app_slug': addon_id}
    app = get_object_or_404(Webapp.with_deleted, **query)

    if request.FILES:
        promo_img_form = PromoImgForm(request.POST, request.FILES)
    else:
        promo_img_form = PromoImgForm()
    if 'promo_img' in request.FILES and promo_img_form.is_valid():
        promo_img_form.save(app)
        messages.success(
            request, 'Promo image successfully uploaded.'
            ' You may have to refresh the page again to see it below.')
        return redirect(reverse('lookup.app_summary', args=[app.pk]))

    if 'prioritize' in request.POST and not app.priority_review:
        prioritize_app(app, request.user)

    authors = (app.authors.filter(addonuser__role__in=(mkt.AUTHOR_ROLE_DEV,
                                                       mkt.AUTHOR_ROLE_OWNER))
               .order_by('display_name'))

    if app.premium and app.premium.price:
        price = app.premium.price
    else:
        price = None

    purchases, refunds = _app_purchases_and_refunds(app)
    provider_portals = get_payment_provider_portals(app=app)
    versions = None

    status_form = APIStatusForm(initial={
        'status': mkt.STATUS_CHOICES_API[app.status]
    })
    version_status_forms = {}
    if app.is_packaged:
        versions = app.versions.all().order_by('-created')
        for v in versions:
            version_status_forms[v.pk] = APIFileStatusForm(initial={
                'status': mkt.STATUS_CHOICES_API[v.all_files[0].status]
            })

    permissions = {}
    if app.latest_version:
        permissions = app.latest_version.manifest.get('permissions', {})

    return render(request, 'lookup/app_summary.html', {
        'abuse_reports': app.abuse_reports.count(), 'app': app,
        'authors': authors, 'purchases': purchases, 'refunds': refunds,
        'price': price, 'provider_portals': provider_portals,
        'status_form': status_form, 'versions': versions,
        'is_tarako': app.tags.filter(tag_text=QUEUE_TARAKO).exists(),
        'version_status_forms': version_status_forms,
        'permissions': permissions,
        'promo_img_form': promo_img_form,
    })
开发者ID:digideskio,项目名称:zamboni,代码行数:59,代码来源:views.py


示例18: user_purchases

def user_purchases(request, user_id):
    """Shows the purchase page for another user."""
    user = get_object_or_404(UserProfile, pk=user_id)
    is_admin = acl.action_allowed(request, 'Users', 'Edit')
    products = purchase_list(request, user)
    return render(request, 'lookup/user_purchases.html',
                  {'pager': products, 'account': user, 'is_admin': is_admin,
                   'single': bool(None), 'show_link': False})
开发者ID:digideskio,项目名称:zamboni,代码行数:8,代码来源:views.py


示例19: price_tiers

def price_tiers(request):
    output = []
    form = PriceTiersForm(request.POST or None, request.FILES)
    if request.method == 'POST' and form.is_valid():
        output = update_from_csv(form.cleaned_data['prices'])

    return render(request, 'zadmin/update-prices.html',
                  {'result': output, 'form': form})
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:views.py


示例20: motd

def motd(request):
    message = unmemoized_get_config("mkt_developers_motd")
    form = MOTDForm(request.POST or None, initial={"motd": message})
    if request.method == "POST" and form and form.is_valid():
        set_config("mkt_developers_motd", form.cleaned_data["motd"])
        messages.success(request, _("Changes successfully saved."))
        return redirect(reverse("mkt.developers.motd"))
    return render(request, "developers/motd.html", {"form": form})
开发者ID:pkdevboxy,项目名称:zamboni,代码行数:8,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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