Ejemplo n.º 1
0
    def get_filters(self, request, filter_language=True):
        """
        Construct queryset filter kwargs, to limit the queryset for the current user
        """
        filters = {"entry__sites__id__exact": settings.SITE_ID}

        if filter_language:
            # Filter by language
            preferences = get_preferences()
            language_filter = preferences["language_filter"]
            if DEBUG_LANG_FILTER:
                messages.debug(request,
                               "language filter: %s" % language_filter)

            if language_filter == BlogPrefForm.CURRENT_LANGUAGE:
                # Display only blog entries in current language (select on the page)
                filters["language"] = request.PYLUCID.current_language
            elif language_filter == BlogPrefForm.PREFERED_LANGUAGES:
                # Filter by client prefered languages (set in browser and send by HTTP_ACCEPT_LANGUAGE header)
                filters["language__in"] = request.PYLUCID.languages

        if not request.user.has_perm(
                "blog.change_blogentry") or not request.user.has_perm(
                    "blog.change_blogentrycontent"):
            filters["entry__is_public"] = True
            filters["is_public"] = True

        if DEBUG_LANG_FILTER:
            messages.debug(request, "queryset filter: %s" % repr(filters))

        return filters
Ejemplo n.º 2
0
    def get_filters(self, request, filter_language=True):
        """
        Construct queryset filter kwargs, to limit the queryset for the current user
        """
        filters = {"entry__sites__id__exact": settings.SITE_ID}

        if filter_language:
            # Filter by language
            preferences = get_preferences()
            language_filter = preferences["language_filter"]
            if DEBUG_LANG_FILTER:
                messages.debug(request, "language filter: %s" % language_filter)

            if language_filter == BlogPrefForm.CURRENT_LANGUAGE:
                # Display only blog entries in current language (select on the page)             
                filters["language"] = request.PYLUCID.current_language
            elif language_filter == BlogPrefForm.PREFERED_LANGUAGES:
                # Filter by client prefered languages (set in browser and send by HTTP_ACCEPT_LANGUAGE header)
                filters["language__in"] = request.PYLUCID.languages

        if not request.user.has_perm("blog.change_blogentry") or not request.user.has_perm("blog.change_blogentrycontent"):
            filters["entry__is_public"] = True
            filters["is_public"] = True

        if DEBUG_LANG_FILTER:
            messages.debug(request, "queryset filter: %s" % repr(filters))

        return filters
Ejemplo n.º 3
0
    def get_filtered_queryset(self, request, tags=None, filter_language=True):
        """
        returns paginator with all blog entries
        e.g. for summary
        """
        queryset = self.get_prefiltered_queryset(request, tags=tags, filter_language=filter_language)

        # Get number of entries allowed by the users see on a page. 
        preferences = get_preferences()
        if request.user.is_anonymous():
            max_count = preferences.get("max_anonym_count", 10)
        else:
            max_count = preferences.get("max_user_count", 30)

        paginator = self.paginator_by_queryset(request, queryset, max_count)
        return paginator
Ejemplo n.º 4
0
    def get_filtered_queryset(self, request, tags=None, filter_language=True):
        """
        returns paginator with all blog entries
        e.g. for summary
        """
        queryset = self.get_prefiltered_queryset(
            request, tags=tags, filter_language=filter_language)

        # Get number of entries allowed by the users see on a page.
        preferences = get_preferences()
        if request.user.is_anonymous():
            max_count = preferences.get("max_anonym_count", 10)
        else:
            max_count = preferences.get("max_user_count", 30)

        paginator = self.paginator_by_queryset(request, queryset, max_count)
        return paginator