示例#1
0
def list(request, list=False, type=False, status=False):
    feedback = Feedback.objects.all().order_by('-created')
    
    if not list:
        list = "open"
    
    title = "Feedback"
    
    if list == "open":
        title = "Open Feedback"
        feedback = feedback.filter(status__status='open')
    elif list == "closed":
        title = "Closed Feedback"
        feedback = feedback.filter(status__status='closed')
    elif list == "mine":
        title = "My Feedback"
        feedback = feedback.filter(user=request.user)
    
    if not type:
        type = "all"
    elif type != "all":
        feedback = feedback.filter(type__slug=type)
    
    if not status:
        status = "all"
    elif status != "all":
        feedback = feedback.filter(status__slug=status)
    
    if request.user.is_staff != True:
        feedback = feedback.filter(private=False)
    
    feedback_list = paginate(feedback, 10, request)
    
    return render_to_response('djangovoice/list.html', {'feedback_list': feedback_list.object_list, 'pagination': feedback_list, 'list': list, 'status': status, 'type': type, 'navigation_active': list, 'title': title,}, context_instance=RequestContext(request))
示例#2
0
def list(request, list=False, type=False, status=False):
    feedback = Feedback.objects.all()

    if not list:
        list = "open"

    title = _("Feedback")

    if list == "open":
        title = _("Open Feedback")
        feedback = feedback.filter(status__status="open")
    elif list == "closed":
        title = _("Closed Feedback")
        feedback = feedback.filter(status__status="closed")
    elif list == "mine":
        title = _("My Feedback")
        if request.user.is_authenticated():
            feedback = feedback.filter(user=request.user)
        else:
            feedback = feedback.none()

    if not type:
        type = "all"
    elif type != "all":
        feedback = feedback.filter(type__slug=type)

    if not status:
        status = "all"
    elif status != "all":
        feedback = feedback.filter(status__slug=status)

    if request.user.is_staff != True:
        feedback = feedback.filter(private=False)

    feedback_list = paginate(feedback, 10, request)

    return render_to_response(
        "djangovoice/list.html",
        {
            "feedback_list": feedback_list.object_list,
            "pagination": feedback_list,
            "list": list,
            "status": status,
            "type": type,
            "navigation_active": list,
            "title": title,
        },
        context_instance=RequestContext(request),
    )
示例#3
0
def list(request, list=False, type=False, status=False):
    feedback = Feedback.objects.all().order_by('-created')

    if not list:
        list = "open"

    title = _("Feedback")

    if list == "open":
        title = _("Open Feedback")
        feedback = feedback.filter(status__status='open')
    elif list == "closed":
        title = _("Closed Feedback")
        feedback = feedback.filter(status__status='closed')
    elif list == "mine":
        title = _("My Feedback")
        if request.user.is_authenticated():
            feedback = feedback.filter(user=request.user)
        else:
            feedback = feedback.none()

    if not type:
        type = "all"
    elif type != "all":
        feedback = feedback.filter(type__slug=type)

    if not status:
        status = "all"
    elif status != "all":
        feedback = feedback.filter(status__slug=status)

    if request.user.is_staff != True:
        feedback = feedback.filter(private=False)

    feedback_list = paginate(feedback, 10, request)

    return render_to_response('djangovoice/list.html', {
        'feedback_list': feedback_list.object_list,
        'pagination': feedback_list,
        'list': list,
        'status': status,
        'type': type,
        'navigation_active': list,
        'title': title,
    },
                              context_instance=RequestContext(request))
示例#4
0
    def get_context_data(self, **kwargs):
        context = super(FeedbackListView, self).get_context_data(**kwargs)
        feedback = Feedback.objects.all().order_by("-created")
        feedback_list = kwargs.get("list", "open")
        feedback_type = kwargs.get("type", "all")
        feedback_status = kwargs.get("status", "all")

        if feedback_list == "open":
            title = _("Open Feedback")
            feedback = feedback.filter(status__status="open")
        elif feedback_list == "closed":
            title = _("Closed Feedback")
            feedback = feedback.filter(status__status="closed")
        elif feedback_list == "mine":
            title = _("My Feedback")
            feedback = feedback.filter(user=self.request.user)
        else:
            title = _("Feedback")

        if feedback_type != "all":
            feedback = feedback.filter(type__slug=feedback_type)

        if feedback_status != "all":
            feedback = feedback.filter(status__slug=feedback_status)

        if not self.request.user.is_staff:
            feedback = feedback.filter(private=False)

        feedback_page = paginate(feedback, 10, self.request)

        context.update(
            {
                "feedback_list": feedback_page.object_list,
                "pagination": feedback_page,
                "list": feedback_list,
                "status": feedback_status,
                "type": feedback_type,
                "navigation_active": feedback_list,
                "title": title,
            }
        )

        return context
示例#5
0
    def get_context_data(self, **kwargs):
        context = super(FeedbackListView, self).get_context_data(**kwargs)
        feedback = Feedback.objects.all().order_by('-created')
        feedback_list = kwargs.get('list', 'open')
        feedback_type = kwargs.get('type', 'all')
        feedback_status = kwargs.get('status', 'all')

        if feedback_list == 'open':
            title = _("Open Feedback")
            feedback = feedback.filter(status__status='open')
        elif feedback_list == 'closed':
            title = _("Closed Feedback")
            feedback = feedback.filter(status__status='closed')
        elif feedback_list == 'mine':
            title = _("My Feedback")
            feedback = feedback.filter(user=self.request.user)
        else:
            title = _("Feedback")

        if feedback_type != 'all':
            feedback = feedback.filter(type__slug=feedback_type)

        if feedback_status != 'all':
            feedback = feedback.filter(status__slug=feedback_status)

        # If user is checking his own feedback, do not filter by private
        if not self.request.user.is_staff and feedback_list != 'mine':
            feedback = feedback.filter(private=False)

        feedback_page = paginate(feedback, 10, self.request)

        context.update({
            'feedback_list': feedback_page.object_list,
            'pagination': feedback_page,
            'list': feedback_list,
            'status': feedback_status,
            'type': feedback_type,
            'navigation_active': feedback_list,
            'title': title
        })

        return context
示例#6
0
    def get_context_data(self, **kwargs):
        context = super(FeedbackListView, self).get_context_data(**kwargs)
        feedback = Feedback.objects.all().order_by('-created')
        feedback_list = kwargs.get('list', 'open')
        feedback_type = kwargs.get('type', 'all')
        feedback_status = kwargs.get('status', 'all')

        if feedback_list == 'open':
            title = _("Open Feedback")
            feedback = feedback.filter(status__status='open')
        elif feedback_list == 'closed':
            title = _("Closed Feedback")
            feedback = feedback.filter(status__status='closed')
        elif feedback_list == 'mine':
            title = _("My Feedback")
            feedback = feedback.filter(user=self.request.user)
        else:
            title = _("Feedback")

        if feedback_type != 'all':
            feedback = feedback.filter(type__slug=feedback_type)

        if feedback_status != 'all':
            feedback = feedback.filter(status__slug=feedback_status)

        if not self.request.user.is_staff:
            feedback = feedback.filter(private=False)

        feedback_page = paginate(feedback, 10, self.request)

        context.update({
            'feedback_list': feedback_page.object_list,
            'pagination': feedback_page,
            'list': feedback_list,
            'status': feedback_status,
            'type': feedback_type,
            'navigation_active': feedback_list,
            'title': title
        })

        return context