コード例 #1
0
ファイル: models.py プロジェクト: zeus911/MyJobs
    def handle_search_results_redirect(self, request):
        """
        Used on search result pages, this returns a redirect to the
        appropriate url if:
            1. helpers.determine_redirect() supplies a redirect.
               The redirect rules that function uses are defined
               in the determine_redirect function.
            2. There are no facet_counts (Redirect to home page).
            3. There are no featured jobs, no default jobs, and
               no query term applied. This means there are either
               no jobs for the site or a series of filters that
               should not be able to be applied were applied
               (Redirects to home page).

        If there is no redirect, returns None.
        """

        filters = context_tools.get_filters(request)
        query_string = context_tools.get_query_string(request)

        redirect_url = helpers.determine_redirect(request, filters)
        if redirect_url:
            return redirect_url

        jobs_and_counts = context_tools.get_jobs_and_counts(request)
        default_jobs = jobs_and_counts[0]
        featured_jobs = jobs_and_counts[2]
        facet_counts = jobs_and_counts[4]
        if not facet_counts:
            return redirect("/")
        if (len(default_jobs) == 0 and len(featured_jobs) == 0
                and not query_string):
            return redirect("/")

        return
コード例 #2
0
    def get_template(self, request):
        filters = context_tools.get_filters(request)

        facet_slugs = []
        if filters.get('facet_slugs', None):
            facet_slugs = filters['facet_slug'].split('/')

        context = self.context(request)
        context.update({
            'body':
            mark_safe(self.get_body()),
            'google_analytics':
            context_tools.get_google_analytics(request),
            'head':
            mark_safe(self.get_head()),
            'max_filter_settings':
            settings.ROBOT_FILTER_LEVEL,
            # see how many active filters there are and then add total number of
            # facet slugs as there may be multiple filters in the facet slug entry
            'num_filters':
            len([
                k for (k, v) in filters.iteritems() if v and k != 'facet_slug'
            ]) + len(facet_slugs),
            'page':
            self,
            'STATIC_URL':
            settings.STATIC_URL,
        })
        template = Template(raw_base_template(self))
        return template.render(Context(context))
コード例 #3
0
ファイル: models.py プロジェクト: zeus911/MyJobs
    def get_template(self, request):
        filters = context_tools.get_filters(request)

        context = {
            'body': mark_safe(self.get_body()),
            'google_analytics': context_tools.get_google_analytics(request),
            'head': mark_safe(self.get_head()),
            'max_filter_settings': settings.ROBOT_FILTER_LEVEL,
            'num_filters': len([k for (k, v) in filters.iteritems() if v]),
            'page': self,
            'STATIC_URL': settings.STATIC_URL,
        }
        template = Template(raw_base_template(self))
        return template.render(Context(context))
コード例 #4
0
ファイル: models.py プロジェクト: DirectEmployers/MyJobs
    def get_template(self, request):
        filters = context_tools.get_filters(request)

        facet_slugs = []
        if filters.get('facet_slugs', None):
            facet_slugs = filters['facet_slug'].split('/')

        context = self.context(request)
        context.update({
            'body': mark_safe(self.get_body()),
            'google_analytics': context_tools.get_google_analytics(request),
            'head': mark_safe(self.get_head()),
            'max_filter_settings': settings.ROBOT_FILTER_LEVEL,
            # see how many active filters there are and then add total number of
            # facet slugs as there may be multiple filters in the facet slug entry
            'num_filters': len([k for (k, v) in filters.iteritems()
                                if v and k != 'facet_slug']) + len(facet_slugs),
            'page': self,
            'STATIC_URL': settings.STATIC_URL,
        })
        template = Template(raw_base_template(self))
        return template.render(Context(context))
コード例 #5
0
    def handle_search_results_redirect(self, request):
        """
        Used on search result pages, this returns a redirect to the
        appropriate url if:

        1.  helpers.determine_redirect() supplies a redirect.
            The redirect rules that function uses are defined
            in the determine_redirect function.
        2.  There are no facet_counts (Redirect to home page).
        3.  There are no featured jobs, no default jobs, and
            no query term applied. This means there are either
            no jobs for the site or a series of filters that
            should not be able to be applied were applied
            (Redirects to home page).

        If there is no redirect, returns None.

        """

        filters = context_tools.get_filters(request)
        query_string = context_tools.get_query_string(request)

        redirect_url = helpers.determine_redirect(request, filters)
        if redirect_url:
            return redirect_url

        jobs_and_counts = context_tools.get_jobs_and_counts(request)
        default_jobs = jobs_and_counts[0]
        featured_jobs = jobs_and_counts[2]
        facet_counts = jobs_and_counts[4]
        if not facet_counts:
            return redirect("/")
        if (len(default_jobs) == 0 and len(featured_jobs) == 0
                and not query_string):
            return redirect("/")

        return