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

Python views.user_denied函数代码示例

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

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



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

示例1: ticket_set_status

def ticket_set_status(request, ticket_id, status_id, response_format='html'):
    "Ticket quick set: Status"
    ticket = get_object_or_404(Ticket, pk=ticket_id)
    if not request.user.get_profile().has_permission(ticket, mode='w'):
        return user_denied(request, message="You don't have access to this Ticket")

    status = get_object_or_404(TicketStatus, pk=status_id)
    if not request.user.get_profile().has_permission(status):
        return user_denied(request, message="You don't have access to this Ticket Status")

    if not ticket.status == status:
        ticket.status = status
        ticket.save()

    return ticket_view(request, ticket_id, response_format)
开发者ID:5n1p,项目名称:treeio,代码行数:15,代码来源:views.py


示例2: stream_edit

def stream_edit(request, stream_id, response_format='html'):
    "Stream edit page"
    user = request.user.get_profile()
    
    stream = get_object_or_404(MessageStream, pk=stream_id)
    if not request.user.get_profile().has_permission(stream, mode="w"):
        return user_denied(request, message="You don't have access to this Stream", 
                           response_format=response_format)
    
    if request.POST:
        if not 'cancel' in request.POST:
            form = MessageStreamForm(user, request.POST, instance=stream)
            if form.is_valid():
                stream = form.save()
                return HttpResponseRedirect(reverse('messaging_stream_view', args=[stream.id]))
        else:
            return HttpResponseRedirect(reverse('messaging_stream_view', args=[stream.id]))
    else:
        form = MessageStreamForm(user, instance=stream)
        
    context = _get_default_context(request)
    context.update({'form': form,
                    'stream':stream})
    
    return render_to_response('messaging/stream_edit', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
开发者ID:3atmospheres,项目名称:treeio,代码行数:27,代码来源:views.py


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


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


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


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


示例7: ticket_edit

def ticket_edit(request, ticket_id, response_format='html'):
    "Ticket edit"

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

    ticket = get_object_or_404(Ticket, pk=ticket_id)
    if not request.user.get_profile().has_permission(ticket, mode='w'):
        return user_denied(request, message="You don't have access to this Ticket")

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

    context.update({'form': form,
                    'ticket': ticket})

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


示例8: queue_delete

def queue_delete(request, queue_id, response_format='html'):
    "Queue delete"

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

    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                queue.trash = True
                queue.save()
            else:
                queue.delete()
            return HttpResponseRedirect(reverse('services_settings_view'))
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('services_queue_view', args=[queue.id]))

    query = Q(queue=queue) & Q(status__hidden=False)
    tickets = Object.filter_by_request(request, Ticket.objects.filter(query))
    subqueues = Object.filter_by_request(
        request, TicketQueue.objects.filter(parent=queue))

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

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


示例9: status_add

def status_add(request, response_format='html'):
    "ItemStatus edit"

    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)

    if request.POST:
        if not 'cancel' in request.POST:
            item_status = ItemStatus()
            form = ItemStatusForm(request.POST, instance=item_status)
            if form.is_valid():
                item_status = form.save(request)
                item_status.set_user_from_request(request)
                return HttpResponseRedirect(reverse('infrastructure_status_view', args=[item_status.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_settings_view'))
    else:
        form = ItemStatusForm()

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

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


示例10: status_edit

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

    item_status = get_object_or_404(ItemStatus, pk=status_id)
    if not request.user.get_profile().has_permission(item_status, mode='w'):
        return user_denied(request, message="You don't have access to this Item Status",
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = ItemStatusForm(request.POST, instance=item_status)
            if form.is_valid():
                item_status = form.save(request)
                return HttpResponseRedirect(reverse('infrastructure_status_view', args=[item_status.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_status_view', args=[item_status.id]))
    else:
        form = ItemStatusForm(instance=item_status)

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

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


示例11: field_add

def field_add(request, response_format='html'):
    "ItemField add"

    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",
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            field = ItemField()
            form = ItemFieldForm(request.POST, instance=field)
            if form.is_valid():
                field = form.save(request)
                field.set_user_from_request(request)
                return HttpResponseRedirect(reverse('infrastructure_field_view', args=[field.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_settings_view'))
    else:
        form = ItemFieldForm()

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

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


示例12: field_edit

def field_edit(request, field_id, response_format='html'):
    "ItemField edit"

    field = get_object_or_404(ItemField, pk=field_id)
    if not request.user.get_profile().has_permission(field, mode='w'):
        return user_denied(request, message="You don't have access to this Field Type",
                           response_format=response_format)

    if request.POST:
        if not 'cancel' in request.POST:
            form = ItemFieldForm(request.POST, instance=field)
            if form.is_valid():
                item = form.save(request)
                return HttpResponseRedirect(reverse('infrastructure_field_view', args=[item.id]))
        else:
            return HttpResponseRedirect(reverse('infrastructure_field_view', args=[item.id]))
    else:
        form = ItemFieldForm(instance=field)

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

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


示例13: type_edit

def type_edit(request, type_id, response_format='html'):
    "ItemType edit"

    item_type = get_object_or_404(ItemType, pk=type_id)
    if not request.user.get_profile().has_permission(item_type, mode='w'):
        return user_denied(request, message="You don't have access to this Item Type",
                           response_format=response_format)
    infrastructure = Object.filter_by_request(request,
                                              Item.objects.filter(item_type=item_type).order_by('name'))

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

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

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


示例14: mlist_delete

def mlist_delete(request, mlist_id, response_format='html'):
    "Delete mlist page"
    
    mlist = get_object_or_404(MailingList, pk=mlist_id)
    if not request.user.get_profile().has_permission(mlist, mode="w"):
        return user_denied(request, message="You don't have access to this Mailing List", 
                           response_format=response_format)
    
    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                mlist.trash = True
                mlist.save()
            else:
                mlist.delete()
            return HttpResponseRedirect('/messaging/')
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('messaging_mlist_view', args=[mlist.id]))
        
    context = _get_default_context(request)
    context.update({'mlist':mlist})

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


示例15: stream_delete

def stream_delete(request, stream_id, response_format='html'):
    "Delete stream page"
    
    stream = get_object_or_404(MessageStream, pk=stream_id)
    if not request.user.get_profile().has_permission(stream, mode="w"):
        return user_denied(request, message="You don't have access to this Stream", 
                           response_format=response_format)
    
    if request.POST:
        if 'delete' in request.POST:
            if 'trash' in request.POST:
                stream.trash = True
                stream.save()
            else:
                stream.delete()
            return HttpResponseRedirect('/messaging/')
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('messaging_stream_view', args=[stream.id]))
        
    context = _get_default_context(request)
    context.update({'stream':stream})

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


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


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


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


示例19: queue_add

def queue_add(request, response_format='html'):
    "Queue 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:
            queue = TicketQueue()
            form = QueueForm(
                request.user.get_profile(), request.POST, instance=queue)
            if form.is_valid():
                queue = form.save()
                queue.set_user_from_request(request)
                return HttpResponseRedirect(reverse('services_queue_view', args=[queue.id]))
        else:
            return HttpResponseRedirect(reverse('services_settings_view'))
    else:
        form = QueueForm(request.user.get_profile())

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

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


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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