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


Python Object.filter_by_request方法代码示例

本文整理汇总了Python中anaf.core.models.Object.filter_by_request方法的典型用法代码示例。如果您正苦于以下问题:Python Object.filter_by_request方法的具体用法?Python Object.filter_by_request怎么用?Python Object.filter_by_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在anaf.core.models.Object的用法示例。


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

示例1: task_delete

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def task_delete(request, task_id, response_format='html'):
    """Task delete"""

    task = get_object_or_404(Task, pk=task_id)
    if not request.user.profile.has_permission(task, mode='w'):
        return user_denied(request, message="You don't have access to this Task")

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

    subtasks = Object.filter_by_request(
        request, Task.objects.filter(parent=task))
    time_slots = Object.filter_by_request(
        request, TaskTimeSlot.objects.filter(task=task))

    context = _get_default_context(request)
    context.update({'task': task,
                    'subtasks': subtasks,
                    'time_slots': time_slots})

    return render_to_response('projects/task_delete', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:32,代码来源:views.py

示例2: contact_view

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def contact_view(request, contact_id, attribute='', response_format='html'):
    "Contact view"

    contact = get_object_or_404(Contact, pk=contact_id)
    if not request.user.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'))

    subcontacts = Object.filter_by_request(request, contact.child_set)
    contact_values = contact.contactvalue_set.order_by('field__name')

    objects = get_contact_objects(
        request.user.profile, contact, preformat=True)

    module = None
    for key in objects:
        if not attribute and objects[key]['count']:
            # attribute = objects[key]['objects'].keys()[0]
            module = objects[key]['module']
        elif attribute in objects[key]['objects'].keys():
            module = objects[key]['module']
            break

    return render_to_response('identities/contact_view',
                              {'contact': contact,
                               'subcontacts': subcontacts,
                               'objects': objects,
                               'current_module': module,
                               'attribute': attribute,
                               'types': types,
                               'contact_values': contact_values},
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:35,代码来源:views.py

示例3: queue_view

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def queue_view(request, queue_id, response_format='html'):
    "Queue view"

    queue = get_object_or_404(TicketQueue, pk=queue_id)
    if not request.user.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.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:tovmeod,项目名称:anaf,代码行数:32,代码来源:views.py

示例4: index_in_progress

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def index_in_progress(request, response_format='html'):
    """A page with a list of tasks in progress"""

    query = Q(parent__isnull=True)
    if request.GET:
        query = query & Q(
            status__hidden=False) & _get_filter_query(request.GET)
    else:
        query = query & Q(status__hidden=False)

    tasks = Object.filter_by_request(request, Task.objects.filter(query))

    milestones = Object.filter_by_request(
        request, Milestone.objects.filter(status__hidden=False))
    filters = FilterForm(request.user.profile, 'status', request.GET)
    time_slots = Object.filter_by_request(
        request, TaskTimeSlot.objects.filter(time_from__isnull=False, time_to__isnull=True))

    context = _get_default_context(request)
    context.update({'milestones': milestones,
                    'tasks': tasks,
                    'filters': filters,
                    'time_slots': time_slots})

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

示例5: get_events

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def get_events(request):
    """Return a list of EventRenderers from available Tasks and Milestones"""
    events = []

    query = (Q(start_date__isnull=False) | Q(end_date__isnull=False)) & Q(
        status__hidden=False)
    tasks = Object.filter_by_request(
        request, manager=Task.objects.filter(query))
    for task in tasks:
        if task.end_date:
            event = EventRenderer(
                task.name, task.start_date, task.end_date, task.get_absolute_url())
        else:
            event = EventRenderer(
                task.name, None, task.start_date, task.get_absolute_url())
        event.css_class += " projects-calendar-task"
        events.append(event)

    query = (Q(start_date__isnull=False) | Q(end_date__isnull=False)) & Q(
        status__hidden=False)
    milestones = Object.filter_by_request(
        request, manager=Milestone.objects.filter(query))
    for milestone in milestones:
        name = "    " + milestone.name
        if milestone.end_date:
            event = EventRenderer(name, milestone.start_date, milestone.end_date,
                                  milestone.get_absolute_url())
        else:
            event = EventRenderer(
                name, None, milestone.start_date, milestone.get_absolute_url())
        event.css_class += " projects-calendar-milestone"
        events.append(event)

    return events
开发者ID:tovmeod,项目名称:anaf,代码行数:36,代码来源:events.py

示例6: index_by_status

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def index_by_status(request, status_id, response_format='html'):
    """Sort tasks by status"""

    status = get_object_or_404(TaskStatus, pk=status_id)

    if not request.user.profile.has_permission(status):
        return user_denied(request, message="You don't have access to this Task Status")

    query = Q(parent__isnull=True, status=status)
    if request.GET:
        query = query & _get_filter_query(request.GET)
    tasks = Object.filter_by_request(request, Task.objects.filter(query))

    milestones = Object.filter_by_request(
        request, Milestone.objects.filter(task__status=status).distinct())
    filters = FilterForm(request.user.profile, 'status', request.GET)

    context = _get_default_context(request)
    context.update({'milestones': milestones,
                    'tasks': tasks,
                    'status': status,
                    'filters': filters})

    return render_to_response('projects/index_by_status', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:27,代码来源:views.py

示例7: index_assigned

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def index_assigned(request, response_format='html'):
    """Tasks assigned to current user"""

    query = Q(parent__isnull=True, assigned=request.user.profile)
    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)

    tasks = Object.filter_by_request(request, Task.objects.filter(query))

    milestones = Object.filter_by_request(
        request, Milestone.objects.filter(status__hidden=False))
    filters = FilterForm(request.user.profile, 'assigned', request.GET)

    context = _get_default_context(request)
    context.update({'milestones': milestones,
                    'tasks': tasks,
                    'filters': filters})

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

示例8: queue_delete

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def queue_delete(request, queue_id, response_format='html'):
    "Queue delete"

    queue = get_object_or_404(TicketQueue, pk=queue_id)
    if not request.user.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:tovmeod,项目名称:anaf,代码行数:32,代码来源:views.py

示例9: task_time_slot_add

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def task_time_slot_add(request, task_id, response_format='html'):
    """Time slot add to preselected task"""

    task = get_object_or_404(Task, pk=task_id)
    if not request.user.profile.has_permission(task, mode='x'):
        return user_denied(request, message="You don't have access to this Task")

    if request.POST:
        task_time_slot = TaskTimeSlot(
            task=task, time_to=datetime.now(), user=request.user.profile)
        form = TaskTimeSlotForm(
            request.user.profile, task_id, request.POST, instance=task_time_slot)
        if 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
        elif form.is_valid():
            task_time_slot = form.save()
            task_time_slot.set_user_from_request(request)
            return HttpResponseRedirect(reverse('projects_task_view', args=[task.id]))
    else:
        form = TaskTimeSlotForm(request.user.profile, task_id)

    subtasks = Object.filter_by_request(
        request, Task.objects.filter(parent=task))
    time_slots = Object.filter_by_request(
        request, TaskTimeSlot.objects.filter(task=task))

    context = _get_default_context(request)
    context.update({'form': form,
                    'task': task,
                    'subtasks': subtasks,
                    'time_slots': time_slots})

    return render_to_response('projects/task_time_add', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:36,代码来源:views.py

示例10: _get_default_context

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def _get_default_context(request):
    "Returns default context as a dict()"

    projects = Object.filter_by_request(request, Project.objects)
    statuses = Object.filter_by_request(request, TaskStatus.objects)
    massform = MassActionForm(request.user.profile)

    context = {'projects': projects,
               'statuses': statuses,
               'massform': massform}

    return context
开发者ID:tovmeod,项目名称:anaf,代码行数:14,代码来源:views.py

示例11: folder_edit

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
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.profile.has_permission(folder, mode="w"):
        return user_denied(request, message="You don't have access to this Knowledge Type")

    if request.POST:
        if 'cancel' not in request.POST:
            form = KnowledgeFolderForm(
                request.user.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.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:tovmeod,项目名称:anaf,代码行数:33,代码来源:views.py

示例12: type_edit

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
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.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 'cancel' not in request.POST:
            form = ItemTypeForm(
                request.user.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.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:tovmeod,项目名称:anaf,代码行数:31,代码来源:views.py

示例13: status_view

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def status_view(request, status_id, response_format='html'):
    "Status view"

    status = get_object_or_404(ChangeSetStatus, pk=status_id)

    if not request.user.profile.has_permission(status) \
            and not request.user.profile.is_admin('anaf.changes'):
        return user_denied(request, "You don't have access to this Change Set Status.",
                           response_format=response_format)

    query = Q(object__in=Object.filter_by_request(request, Object.objects)) & Q(
        status=status)
    if request.GET:
        query = query & _get_filter_query(request.GET)
        filters = FilterForm(request.user.profile, 'status', request.GET)
    else:
        filters = FilterForm(request.user.profile, 'status')

    changesets = ChangeSet.objects.filter(query)

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

    return render_to_response('changes/status_view', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:29,代码来源:views.py

示例14: settings_view

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def settings_view(request, response_format='html'):
    "Settings"

    if not request.user.profile.is_admin('anaf.identities'):
        return user_denied(request, message="You are not an Administrator of the Identities module",
                           response_format=response_format)

    contact_types = ContactType.objects.all().filter(trash=False)
    contact_fields = ContactField.objects.all().filter(trash=False)
    contacts = Object.filter_by_request(
        request, Contact.objects.order_by('name'))

    context = _get_default_context(request)
    context.update({'contact_types': contact_types,
                    'contact_fields': contact_fields,
                    'contacts': contacts})

    if request.POST and 'file' in request.FILES:
        csv_file = request.FILES['file']

        # TODO: check file extension
        content = csv_file.read()
        import_c = ProcessContacts()
        import_c.import_contacts(content)

        return HttpResponseRedirect(reverse('identities_index'))

    return render_to_response('identities/settings_view', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:31,代码来源:views.py

示例15: milestone_delete

# 需要导入模块: from anaf.core.models import Object [as 别名]
# 或者: from anaf.core.models.Object import filter_by_request [as 别名]
def milestone_delete(request, milestone_id, response_format='html'):
    """Milestone delete"""

    milestone = get_object_or_404(Milestone, pk=milestone_id)
    project = milestone.project
    if not request.user.profile.has_permission(milestone, mode='w'):
        return user_denied(request, message="You don't have access to this Milestone")

    query = Q(milestone=milestone, parent__isnull=True)
    if request.GET:
        query = query & _get_filter_query(request.GET)
    tasks = Object.filter_by_request(request, Task.objects.filter(query))

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

    context = _get_default_context(request)
    context.update({'milestone': milestone,
                    'tasks': tasks,
                    'project': project})

    return render_to_response('projects/milestone_delete', context,
                              context_instance=RequestContext(request), response_format=response_format)
开发者ID:tovmeod,项目名称:anaf,代码行数:33,代码来源:views.py


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