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

Python rendering.render_to_response函数代码示例

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

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



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

示例1: report_view

def report_view(request, response_format='html', report_id=None):
    "Display the report"

    report = get_object_or_404(Report, pk=report_id)
    report_context = _get_report_content(report, request)
    context = _get_default_context(request)
    context.update(report_context)

    if response_format == "csv":
        return render_to_response('reports/gen', context,
                                  context_instance=RequestContext(request),
                                  response_format='csv')

    report_content = str(render_to_response('reports/gen', context,
                                            context_instance=RequestContext(
                                                request),
                                            response_format='html')).replace('Content-Type: text/html', '')

    charts = report.chart_set.filter(trash=False)

    # Now take the rendered report and embed it in the report view page.
    context = _get_default_context(request)
    context.update({'report': report,
                    'charts': charts,
                    'report_content': report_content})

    return render_to_response('reports/report_view', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:29,代码来源:views.py


示例2: authorize_request_token

def authorize_request_token(request, form_class=AuthorizeRequestTokenForm, template_name='core/api/auth/authorize', verification_template_name='core/api/auth/authorize_verification_code'):
    if 'oauth_token' not in request.REQUEST:
        return HttpResponseBadRequest('No request token specified.')

    oauth_request = get_oauth_request(request)

    try:
        request_token = store.fetch_request_token(request, oauth_request, request.REQUEST['oauth_token'])
    except InvalidTokenError:
        return HttpResponseBadRequest('Invalid request token.')

    consumer = store.get_consumer_for_request_token(request, oauth_request, request_token)

    if request.method == 'POST':
        form = form_class(request.POST)
        if form.is_valid() and form.cleaned_data['authorize_access']:
            request_token = store.authorize_request_token(request, oauth_request, request_token)
            if request_token.callback is not None and request_token.callback != 'oob':
                domain = RequestSite(request).domain
                return HttpResponseRedirect('%s&%s' % (request_token.get_callback_url(), urlencode({'oauth_token': request_token.key, 'domain': domain})))
            else:
                return render_to_response(verification_template_name,
                                          {'consumer': consumer, 'verification_code': request_token.verifier},
                                          context_instance=RequestContext(request), response_format='html')
    else:
        form = form_class(initial={'oauth_token': request_token.key})

    return render_to_response(template_name, {'consumer': consumer, 'form': form},
                              context_instance=RequestContext(request), response_format='html')
开发者ID:3atmospheres,项目名称:treeio,代码行数:29,代码来源:views.py


示例3: report_view

def report_view(request, response_format="html", report_id=None):
    "Display the report"

    report = get_object_or_404(Report, pk=report_id)
    report_context = _get_report_content(report, request)
    context = _get_default_context(request)
    context.update(report_context)

    if response_format == "csv":
        return render_to_response(
            "reports/gen", context, context_instance=RequestContext(request), response_format="csv"
        )

    report_content = str(
        render_to_response("reports/gen", context, context_instance=RequestContext(request), response_format="html")
    ).replace("Content-Type: text/html", "")

    charts = report.chart_set.filter(trash=False)

    # Now take the rendered report and embed it in the report view page.
    context = _get_default_context(request)
    context.update({"report": report, "charts": charts, "report_content": report_content})

    return render_to_response(
        "reports/report_view", context, context_instance=RequestContext(request), response_format=response_format
    )
开发者ID:jmfield2,项目名称:treeio,代码行数:26,代码来源:views.py


示例4: widget_contact_me

def widget_contact_me(request, response_format='html'):
    "My Contact card"
    
    contact = request.user.get_profile().get_contact()
    if not request.user.get_profile().has_permission(contact):
        return user_denied(request, message="You don't have access to this Contact")
    types = Object.filter_by_request(request, ContactType.objects.order_by('name'))
    if contact:
        return render_to_response('identities/widgets/contact_me',
                                  {'contact': contact, 'types': types},
                                  context_instance=RequestContext(request), response_format=response_format)
    else:
        return render_to_response('identities/widgets/contact_me_missing', {'types': types},
                                  context_instance=RequestContext(request), response_format=response_format)
开发者ID:BenoitNorrin,项目名称:treeio,代码行数:14,代码来源:views.py


示例5: sla_add

def sla_add(request, response_format='html'):
    "ServiceLevelAgreement add"

    if not request.user.get_profile().is_admin('treeio.services'):
        return user_denied(request,
                           message="You don't have administrator access to the Service Support module")

    if request.POST:
        if not 'cancel' in request.POST:
            sla = ServiceLevelAgreement()
            form = ServiceLevelAgreementForm(
                request.user.get_profile(), request.POST, instance=sla)
            if form.is_valid():
                sla = form.save()
                sla.set_user_from_request(request)
                return HttpResponseRedirect(reverse('services_sla_view', args=[sla.id]))
        else:
            return HttpResponseRedirect(reverse('services'))
    else:
        form = ServiceLevelAgreementForm(request.user.get_profile())

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('services/sla_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:26,代码来源:views.py


示例6: service_edit

def service_edit(request, service_id, response_format='html'):
    "Service edit"

    service = get_object_or_404(Service, pk=service_id)
    if not request.user.get_profile().has_permission(service, mode='w') \
            and not request.user.get_profile().is_admin('treeio_services'):
        return user_denied(request, message="You don't have access to this Service")

    if request.POST:
        if not 'cancel' in request.POST:
            form = ServiceForm(
                request.user.get_profile(), request.POST, instance=service)
            if form.is_valid():
                service = form.save()
                return HttpResponseRedirect(reverse('services_service_view', args=[service.id]))
        else:
            return HttpResponseRedirect(reverse('services_service_view', args=[service.id]))
    else:
        form = ServiceForm(request.user.get_profile(), instance=service)

    context = _get_default_context(request)
    context.update({'form': form, 'service': service})

    return render_to_response('services/service_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:25,代码来源:views.py


示例7: sla_edit

def sla_edit(request, sla_id, response_format='html'):
    "ServiceLevelAgreement edit"

    sla = get_object_or_404(ServiceLevelAgreement, pk=sla_id)
    if not request.user.get_profile().has_permission(sla, mode='w'):
        return user_denied(request, message="You don't have access to this Service Level Agreement")

    if request.POST:
        if not 'cancel' in request.POST:
            form = ServiceLevelAgreementForm(
                request.user.get_profile(), request.POST, instance=sla)
            if form.is_valid():
                sla = form.save()
                return HttpResponseRedirect(reverse('services_sla_view', args=[sla.id]))
        else:
            return HttpResponseRedirect(reverse('services_sla_view', args=[sla.id]))
    else:
        form = ServiceLevelAgreementForm(
            request.user.get_profile(), instance=sla)

    context = _get_default_context(request)
    context.update({'sla': sla, 'form': form})

    return render_to_response('services/sla_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:25,代码来源:views.py


示例8: category_delete

def category_delete(request, knowledgeCategory_id, response_format='html'):
    "Knowledge Category delete"

    category = get_object_or_404(KnowledgeCategory, pk=knowledgeCategory_id)
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    if not request.user.get_profile().has_permission(category, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Category")
    
    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                category.trash = True
                category.save()
            else:
                category.delete()
            return HttpResponseRedirect(reverse('knowledge_index'))
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('knowledge_category_view', args=[category.treepath]))
        
    context = _get_default_context(request)
    context.update({'category': category, 
                    'items':items})
        
    return render_to_response('knowledge/category_delete', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
开发者ID:3atmospheres,项目名称:treeio,代码行数:27,代码来源:views.py


示例9: item_add_typed

def item_add_typed(request, type_id, response_format='html'):
    "Item add with preselected type"

    item_type = get_object_or_404(ItemType, pk=type_id)
    if not request.user.get_profile().has_permission(item_type, mode='x'):
        return user_denied(request, message="You don't have access to create " + unicode(item_type),
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = ItemForm(
                request.user.get_profile(), item_type, request.POST, files=request.FILES)
            if form.is_valid():
                item = form.save(request)
                return HttpResponseRedirect(reverse('infrastructure_item_view', args=[item.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_index'))
    else:
        form = ItemForm(request.user.get_profile(), item_type)

    context = _get_default_context(request)
    context.update({'item_type': item_type,
                    'form': form})

    return render_to_response('infrastructure/item_add_typed', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:26,代码来源:views.py


示例10: item_add

def item_add(request, response_format='html'):
    "Add new knowledge item"
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    if request.POST:
        if not 'cancel' in request.POST:
            item = KnowledgeItem()
            form = KnowledgeItemForm(request.user.get_profile(), None, request.POST, instance=item)
            if form.is_valid():
                item = form.save()
                item.set_user_from_request(request)
                return HttpResponseRedirect(reverse('knowledge_item_view', 
                                                    args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge'))
    else:   
        form = KnowledgeItemForm(request.user.get_profile(), None)
        
    context = _get_default_context(request)
    context.update({'items': items,
                    'form':form})
    
    return render_to_response('knowledge/item_add', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
开发者ID:3atmospheres,项目名称:treeio,代码行数:25,代码来源:views.py


示例11: item_edit

def item_edit(request, knowledgeItem_id, response_format='html'):
    "Knowledge item edit page"
    item = get_object_or_404(KnowledgeItem, pk=knowledgeItem_id)
    items = Object.filter_permitted(manager=KnowledgeItem.objects, user=request.user.get_profile(), mode='r')
    
    if not request.user.get_profile().has_permission(item, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Item")
    
    if request.POST:
        if not 'cancel' in request.POST:
            form = KnowledgeItemForm(request.user.get_profile(), None, request.POST, instance=item)
            if form.is_valid():
                item = form.save()
                return HttpResponseRedirect(reverse('knowledge_item_view', 
                                                    args=[item.folder.treepath, item.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge_item_view', 
                                                    args=[item.folder.treepath, item.treepath]))
    else:
        form = KnowledgeItemForm(request.user.get_profile(), None, instance=item)
        
    context = _get_default_context(request)
    context.update({'form': form,
                    'item':item,
                    'items':items})
        
    return render_to_response('knowledge/item_edit', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
开发者ID:3atmospheres,项目名称:treeio,代码行数:29,代码来源:views.py


示例12: index_assigned

def index_assigned(request, response_format='html'):
    "Tickets assigned to current user"

    context = _get_default_context(request)
    agent = context['agent']

    if agent:
        query = Q(assigned=agent)
        if request.GET:
            if 'status' in request.GET and request.GET['status']:
                query = query & _get_filter_query(request.GET)
            else:
                query = query & Q(
                    status__hidden=False) & _get_filter_query(request.GET)
        else:
            query = query & Q(status__hidden=False)
        tickets = Object.filter_by_request(
            request, Ticket.objects.filter(query))
    else:
        return user_denied(request, "You are not a Service Support Agent.", response_format=response_format)

    filters = FilterForm(request.user.get_profile(), 'assigned', request.GET)

    context.update({'tickets': tickets,
                    'filters': filters})

    return render_to_response('services/index_assigned', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:28,代码来源:views.py


示例13: status_edit

def status_edit(request, status_id, response_format='html'):
    "TicketStatus edit"

    status = get_object_or_404(TicketStatus, pk=status_id)
    if not request.user.get_profile().has_permission(status, mode='w') \
            and not request.user.get_profile().is_admin('treeio_services'):
        return user_denied(request, "You don't have access to this Ticket Status", response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = TicketStatusForm(
                request.user.get_profile(), request.POST, instance=status)
            if form.is_valid():
                status = form.save()
                return HttpResponseRedirect(reverse('services_status_view', args=[status.id]))
        else:
            return HttpResponseRedirect(reverse('services_status_view', args=[status.id]))
    else:
        form = TicketStatusForm(request.user.get_profile(), instance=status)

    context = _get_default_context(request)
    context.update({'form': form,
                    'status': status})

    return render_to_response('services/status_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:26,代码来源:views.py


示例14: service_record_add

def service_record_add(request, response_format='html'):
    "New service_record form"

    if not request.user.get_profile().is_admin('treeio.infrastructure'):
        return user_denied(request,
                           message="You don't have administrator access to the Infrastructure module")

    service_record = ItemServicing()

    if request.POST:
        if not 'cancel' in request.POST:
            form = ServiceRecordForm(
                request.user.get_profile(), service_record, request.POST)
            if form.is_valid():
                record = form.save(request)
                return HttpResponseRedirect(reverse('infrastructure_service_record_view', args=[record.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_service_record_index'))
    else:
        form = ServiceRecordForm(request.user.get_profile(), service_record)

    context = _get_default_context(request)
    context.update({'service_record': service_record,
                    'form': form})

    return render_to_response('infrastructure/service_record_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:27,代码来源:views.py


示例15: service_record_edit

def service_record_edit(request, service_record_id, response_format='html'):
    "ServiceRecord edit page"

    service_record = get_object_or_404(ItemServicing, pk=service_record_id)
    if not request.user.get_profile().has_permission(service_record, mode="w"):
        return user_denied(request, message="You don't have write access to this ServiceRecord",
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = ServiceRecordForm(
                request.user.get_profile(), None, request.POST, instance=service_record)
            if form.is_valid():
                service_record = form.save(request)
                return HttpResponseRedirect(reverse('infrastructure_service_record_view',
                                                    args=[service_record.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_service_record_view',
                                                args=[service_record.id]))
    else:
        form = ServiceRecordForm(
            request.user.get_profile(), None, instance=service_record)

    context = _get_default_context(request)
    context.update({'service_record': service_record,
                    'form': form})

    return render_to_response('infrastructure/service_record_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:29,代码来源:views.py


示例16: settings_view

def settings_view(request, response_format='html'):
    "Settings"

    if not request.user.get_profile().is_admin('treeio.infrastructure'):
        return user_denied(request, message="You are not an Administrator of the Infrastructure module",
                           response_format=response_format)

    item_types = ItemType.objects.all().filter(trash=False)
    item_statuses = ItemStatus.objects.all().filter(trash=False)
    item_fields = ItemField.objects.all().filter(trash=False)

    default_item_status = None
    try:
        conf = ModuleSetting.get_for_module(
            'treeio.infrastructure', 'default_item_status')[0]
        default_item_status = ItemStatus.objects.get(
            pk=long(conf.value), trash=False)
    except Exception:
        pass

    context = _get_default_context(request)
    context.update({'item_types': item_types,
                    'item_fields': item_fields,
                    'item_statuses': item_statuses,
                    'default_item_status': default_item_status})

    return render_to_response('infrastructure/settings_view', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:28,代码来源:views.py


示例17: location_edit

def location_edit(request, location_id, response_format='html'):
    "Location edit page"
    location = get_object_or_404(Location, pk=location_id)
    if not request.user.get_profile().has_permission(location, mode="w"):
        return user_denied(request, message="You don't have write access to this Location",
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = LocationForm(
                request.user.get_profile(), None, request.POST, instance=location)
            if form.is_valid():
                location = form.save(request)
                return HttpResponseRedirect(reverse('infrastructure_location_view', args=[location.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_location_view', args=[location.id]))
    else:
        form = LocationForm(
            request.user.get_profile(), None, instance=location)

    context = _get_default_context(request)
    context.update({'location': location,
                    'form': form})

    return render_to_response('infrastructure/location_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:26,代码来源:views.py


示例18: item_edit

def item_edit(request, item_id, response_format='html'):
    "Item edit page"
    item = get_object_or_404(Item, pk=item_id)
    if not request.user.get_profile().has_permission(item, mode="w"):
        return user_denied(request, message="You don't have write access to this Item",
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = ItemForm(request.user.get_profile(), item.item_type, request.POST,
                            files=request.FILES, instance=item)
            if form.is_valid():
                item = form.save(request)
                return HttpResponseRedirect(reverse('infrastructure_item_view', args=[item.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_item_view', args=[item.id]))
    else:
        form = ItemForm(
            request.user.get_profile(), item.item_type, instance=item)

    context = _get_default_context(request)
    context.update({'item': item,
                    'form': form})

    return render_to_response('infrastructure/item_edit', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:26,代码来源:views.py


示例19: folder_edit

def folder_edit(request, knowledgeType_id, response_format='html'):
    "Knowledge folder edit page"
    
    folder = get_object_or_404(KnowledgeFolder, pk=knowledgeType_id)
    items = Object.filter_by_request(request, manager=KnowledgeItem.objects.filter(folder=folder)) 
    
    if not request.user.get_profile().has_permission(folder, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Type")
    
    if request.POST:
        if not 'cancel' in request.POST:
            form = KnowledgeFolderForm(request.user.get_profile(), None, request.POST, instance=folder)
            if form.is_valid():
                folder = form.save()
                return HttpResponseRedirect(reverse('knowledge_folder_view', args=[folder.treepath]))
        else:
            return HttpResponseRedirect(reverse('knowledge_folder_view', args=[folder.treepath]))
    else:
        form = KnowledgeFolderForm(request.user.get_profile(), None, instance=folder)       

    context = _get_default_context(request)
    context.update({'items': items,
                    'folder': folder,
                    'form': form})
        
    return render_to_response('knowledge/folder_edit', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
开发者ID:3atmospheres,项目名称:treeio,代码行数:28,代码来源:views.py


示例20: queue_view

def queue_view(request, queue_id, response_format='html'):
    "Queue view"

    queue = get_object_or_404(TicketQueue, pk=queue_id)
    if not request.user.get_profile().has_permission(queue):
        return user_denied(request, message="You don't have access to this Queue")

    query = Q(queue=queue)
    if request.GET:
        if 'status' in request.GET and request.GET['status']:
            query = query & _get_filter_query(request.GET)
        else:
            query = query & Q(
                status__hidden=False) & _get_filter_query(request.GET)
    else:
        query = query & Q(status__hidden=False)
    tickets = Object.filter_by_request(request, Ticket.objects.filter(query))

    filters = FilterForm(request.user.get_profile(), 'queue', request.GET)
    subqueues = Object.filter_by_request(
        request, TicketQueue.objects.filter(parent=queue))

    context = _get_default_context(request)
    context.update({'queue': queue,
                    'subqueues': subqueues,
                    'filters': filters,
                    'tickets': tickets})

    return render_to_response('services/queue_view', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:AlexLX2,项目名称:treeio,代码行数:30,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python rendering.render_to_string函数代码示例发布时间:2022-05-27
下一篇:
Python models.Perspective类代码示例发布时间: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