예제 #1
0
파일: views.py 프로젝트: k0001/pinax
def tasks(request, group_slug=None, template_name="tasks/task_list.html", bridge=None):
    
    try:
        group = bridge.get_group(group_slug)
    except ObjectDoesNotExist:
        raise Http404
    
    if not request.user.is_authenticated():
        is_member = False
    else:
        is_member = group.user_is_member(request.user)

    group_by = request.GET.get("group_by")
    
    if group:
        tasks = group.get_related_objects(Task)
    else:
        tasks = Task.objects.filter(object_id=None)

    # exclude states
    hide_state  = request.GET.get("hide_state")
    if hide_state:
        for exclude in hide_state.split(','):
            if exclude in STATE_ID_LIST:
                tasks = tasks.exclude(state__exact=exclude)

            state = REVERSE_STATE_CHOICES.get(exclude, None)
            if state:
                tasks = tasks.exclude(state__exact=state)


    state_displays = []
    for state in STATE_CHOICES:
        state_displays.append(dict(id=state[0], description=state[1]))

    return render_to_response(template_name, {
        "group": group,
        "tasks": tasks,
        "group_by": group_by,
        "is_member": is_member,
        "hide_state": hide_state,
        "state_displays": state_displays,
    }, context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: BlackWizard/pinax
def tasks(request, group_slug=None, template_name="tasks/task_list.html"):
    group = None # get_object_or_404(Project, slug=slug)

    # @@@ if group.deleted:
    # @@@     raise Http404

    is_member = True # @@@ groups.has_member(request.user)

    group_by = request.GET.get("group_by")


    if group:
        tasks = group.tasks.all() # @@@ assumes GR
    else:
        tasks = Task.objects.filter(object_id__isnull=True)

    # exclude states
    hide_state  = request.GET.get("hide_state")
    if hide_state:
        for exclude in hide_state.split(','):
            if exclude in STATE_ID_LIST:
                tasks = tasks.exclude(state__exact=exclude)

            state = REVERSE_STATE_CHOICES.get(exclude, None)
            if state:
                tasks = tasks.exclude(state__exact=state)


    state_displays = []
    for state in STATE_CHOICES:
        state_displays.append(dict(id=state[0], description=state[1]))

    return render_to_response(template_name, {
        "group": group,
        "tasks": tasks,
        "group_by": group_by,
        "is_member": is_member,
        "hide_state": hide_state,
        "state_displays": state_displays,
    }, context_instance=RequestContext(request))