• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.set_language_changer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中menus.utils.set_language_changer函数的典型用法代码示例。如果您正苦于以下问题:Python set_language_changer函数的具体用法?Python set_language_changer怎么用?Python set_language_changer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: blog_archive_day

def blog_archive_day(request, **kwargs):
    blog_slug = kwargs.pop('blog_slug')
    kwargs['queryset'] = kwargs['queryset'].published().filter(
        blog__slug=blog_slug)
    set_language_changer(request, language_changer)
    return archive_day(request, extra_context={ 'blog_slug': blog_slug },
                       **kwargs)
开发者ID:Lacrymology,项目名称:cmsplugin-blog,代码行数:7,代码来源:urls.py


示例2: get

    def get(self, request, *args, **kwargs):
        try:
            category = self.get_category()
        except FallbackLanguageResolved as flr:
            # We have the category, but it is in a fallback language.
            category = flr.object

        # only look at questions within this category
        queryset = self.get_queryset().filter(category=category.pk)
        question = self.get_object(queryset=queryset)
        set_language_changer(request, question.get_absolute_url)

        if hasattr(request, 'toolbar'):
            request.toolbar.set_object(question)

        setattr(request, request_faq_category_identifier, question.category)
        setattr(request, request_faq_question_identifier, question)
        response = super(FaqAnswerView, self).get(request, *args, **kwargs)

        # FIXME: We should check for unique visitors using sessions.
        # update number of visits
        question_only_queryset = self.get_queryset().filter(pk=question.pk)
        question_only_queryset.update(
            number_of_visits=models.F('number_of_visits') + 1)
        return response
开发者ID:trawick,项目名称:aldryn-faq,代码行数:25,代码来源:views.py


示例3: get_context_data

    def get_context_data (self, **kwargs):
        context = super(Detail, self).get_context_data(**kwargs)
        obj = context['obj']
        context['url_feed'] = reverse('draftlaw_feed_detail', args=[obj.pk])

        set_language_changer(self.request, obj.get_absolute_url)
        return context
开发者ID:ddohler,项目名称:myparliament,代码行数:7,代码来源:views.py


示例4: blog_archive_tagged

def blog_archive_tagged(request, **kwargs):
    blog_slug = kwargs.pop('blog_slug')
    kwargs['queryset_or_model'] = (kwargs['queryset_or_model'].published()
                                   .filter(blog__slug=blog_slug))
    set_language_changer(request, language_changer)
    return tagged_object_list(request, extra_context={ 'blog_slug': blog_slug },
                              **kwargs)
开发者ID:Lacrymology,项目名称:cmsplugin-blog,代码行数:7,代码来源:urls.py


示例5: get

 def get(self, request, *args, **kwargs):
     response = super(PostDetailView, self).get(request, *args, **kwargs)
     post = response.context_data.get('post', None)
     if post:
         setattr(request, request_post_identifier, post)
         if post.language:
             set_language_changer(request, post_language_changer)
     return response
开发者ID:aldryn,项目名称:aldryn-blog,代码行数:8,代码来源:views.py


示例6: get_context_data

    def get_context_data (self, **kwargs):
        context = super(Detail, self).get_context_data(**kwargs)

        context['form'] = _get_form(self, context['obj'].representative)
        context['url_feed'] = reverse('question_feed_list')
        set_language_changer(self.request, context['obj'].get_absolute_url)

        return context
开发者ID:GeorgeLubaretsi,项目名称:shenmartav,代码行数:8,代码来源:views.py


示例7: blog_archive_author

def blog_archive_author(request, **kwargs):
    author = kwargs.pop('author')
    kwargs['queryset'] = kwargs['queryset'].published().filter(entrytitle__author__username=author)
    kwargs['extra_context'] = {
        'author': get_object_or_404(User, username=author),
    }
    set_language_changer(request, language_changer)
    return object_list(request, **kwargs)
开发者ID:ptoal,项目名称:cmsplugin-blog,代码行数:8,代码来源:urls.py


示例8: get_context_data

    def get_context_data (self, **kwargs):
        context = super(Detail, self).get_context_data(**kwargs)
        draftlaw_url = 'https://matsne.gov.ge/index.php?geo=on&searchTarget=title&searchDocumentsFilter=all&courtDecisionsARGUMENT=&sortCombo=signingDate_asc&queryString=&option=com_ldmssearch&view=docSearchResults&searchType=advanced&limitstart=0&lang=ge&documentNumber='
        obj = context['obj']
        context['stages'] = DraftLawForList(obj,obj.bureau_date) 
        context['url_feed'] = reverse('draftlaw_feed_detail', args=[obj.pk])
        context['draftlaw_url'] = draftlaw_url

        set_language_changer(self.request, obj.get_absolute_url)
        return context
开发者ID:tigeorgia,项目名称:shenmartav,代码行数:10,代码来源:views.py


示例9: blog_archive_author

def blog_archive_author(request, **kwargs):
    blog_slug = kwargs.pop('blog_slug')
    author = kwargs.pop('author')
    kwargs['queryset'] = kwargs['queryset'].published().filter(
        blog__slug=blog_slug, entrytitle__author__username=author).distinct()
    kwargs['extra_context'] = {
        'author': author,
        'blog_slug': blog_slug,
    }
    set_language_changer(request, language_changer)
    return object_list(request, **kwargs)
开发者ID:Lacrymology,项目名称:cmsplugin-blog,代码行数:11,代码来源:urls.py


示例10: process_request

	def process_request(self, request):
		set_language_changer(request, _SimpleLanguageChanger(request))
		
		host = request.get_host().lower().strip()
		if 'localhost' in host or not host or host=='testserver' or settings.INSIDE_TESTING:
			return None

		if host[:3] in ('www','dev'):
			host = host[4:]
		if ':' in host:
			host = host[:host.find(':')]

		host_hash = md5(host+'iddqd').hexdigest()


		return None
开发者ID:cheetos007,项目名称:owantsbeta_git,代码行数:16,代码来源:middleware.py


示例11: get_context_data

    def get_context_data (self, **kwargs):
        context = super(Detail, self).get_context_data(**kwargs)


        context['counts1'] = VotingRecordResult.get_counts(record=context['obj'],session=1)
        context['votes1'] = VotingRecordResult.objects.filter(record=context['obj'], session=1)
	context['counts2'] = VotingRecordResult.get_counts(record=context['obj'],session=2)
        context['votes2'] = VotingRecordResult.objects.filter(record=context['obj'], session=2)
        context['counts3'] = VotingRecordResult.get_counts(record=context['obj'],session=3)
        context['votes3'] = VotingRecordResult.objects.filter(record=context['obj'], session=3)

        order_by = VotingRecord._meta.ordering
        context['amended_by'] =\
            context['obj'].amended_by.all().order_by(*order_by)
        context['amending'] =\
            context['obj'].amending.all().order_by(*order_by)

        set_language_changer(self.request, context['obj'].get_absolute_url)
        return context
开发者ID:araneta,项目名称:shenmartav,代码行数:19,代码来源:views.py


示例12: get

    def get(self, request, *args, **kwargs):
        # triggers a redirect if the old category url format is used.
        category = self.get_category_or_404()
        category_url = category.get_absolute_url(self.current_language)

        if request.path != category_url:
            # say we have one category with two translations:
            # /en/faq/category-en/
            # /de/faq/category-de/
            # with this check we make sure that any request to
            # /en/faq/category-de/ gets redirected to /en/faq/category-en/
            return HttpResponsePermanentRedirect(category_url)

        self.category = category

        setattr(self.request, request_faq_category_identifier, self.category)
        set_language_changer(self.request, self.category.get_absolute_url)
        response = super(FaqByCategoryView, self).get(request, *args, **kwargs)
        return response
开发者ID:czpython,项目名称:aldryn-faq,代码行数:19,代码来源:views.py


示例13: get_object

    def get_object(self):
        try:
            obj = super(EntryDateDetailView, self).get_object()
        except Http404 as e:
            # No entry has been found for a given language, we fallback to search for an entry in any language
            # Could find multiple entries, in this way we cannot decide which one is the right one, so we let
            # exception be propagated FIXME later
            if is_multilingual():
                try:
                    queryset = self.get_unfiltered_queryset()
                    obj = super(EntryDateDetailView, self).get_object(queryset=queryset)
                except Entry.MultipleObjectsReturned as s:
                    raise e
                # We know there is only one title for this entry, so we can simply use get()
                raise Redirect(obj.entrytitle_set.get().get_absolute_url())
            else:
                raise e

        set_language_changer(self.request, obj.language_changer)
        return obj
开发者ID:infernonet,项目名称:cmsplugin-blog,代码行数:20,代码来源:views.py


示例14: get

    def get(self, request, *args, **kwargs):
        """
        This handles non-permalinked URLs according to preferences as set in
        NewsBlogConfig.
        """
        if not hasattr(self, 'object'):
            self.object = self.get_object()
        set_language_changer(request, self.object.get_absolute_url)
        url = self.object.get_absolute_url()
        if (self.config.non_permalink_handling == 200 or request.path == url):
            # Continue as normal
            return super(ArticleDetail, self).get(request, *args, **kwargs)

        # Check to see if the URL path matches the correct absolute_url of
        # the found object
        if self.config.non_permalink_handling == 302:
            return HttpResponseRedirect(url)
        elif self.config.non_permalink_handling == 301:
            return HttpResponsePermanentRedirect(url)
        else:
            raise Http404('This is not the canonical uri of this object.')
开发者ID:Nekmo,项目名称:aldryn-newsblog,代码行数:21,代码来源:views.py


示例15: dispatch

    def dispatch(self, request, *args, **kwargs):
        self.namespace, self.config = get_app_instance(request)
        self.request_language = get_language(request)
        self.queryset = (
            Event.objects.namespace(self.namespace)
                         .published()
                         .language(self.request_language)
                         .order_by(*ORDERING_FIELDS)
        )
        self.event = self.queryset.active_translations(
            self.request_language, slug=kwargs['slug']).first()
        if not self.event:
            raise Http404("Event not found")

        set_language_changer(request, self.event.get_absolute_url)
        setattr(self.request, request_events_event_identifier, self.event)

        if hasattr(request, 'toolbar'):
            request.toolbar.set_object(self.event)

        return super(EventDetailView, self).dispatch(request, *args, **kwargs)
开发者ID:Marketionist,项目名称:aldryn-events,代码行数:21,代码来源:views.py


示例16: blog_archive_tagged

def blog_archive_tagged(request, **kwargs):
    kwargs['queryset_or_model'] = kwargs['queryset_or_model'].published()
    set_language_changer(request, language_changer)
    return tagged_object_list(request, **kwargs)
开发者ID:ptoal,项目名称:cmsplugin-blog,代码行数:4,代码来源:urls.py


示例17: blog_archive_day

def blog_archive_day(request, **kwargs):
    kwargs['queryset'] = kwargs['queryset'].published()
    set_language_changer(request, language_changer)
    return archive_day(request, **kwargs)
开发者ID:ptoal,项目名称:cmsplugin-blog,代码行数:4,代码来源:urls.py


示例18: set_language_changer

 def set_language_changer(self, category):
     """Translate the slug while changing the language."""
     set_language_changer(self.request, category.get_absolute_url)
开发者ID:aldryn,项目名称:aldryn-jobs,代码行数:3,代码来源:views.py


示例19: get_queryset

 def get_queryset(self):
     queryset = super(BlogTaggedArchiveView, self).get_queryset().published()
     if queryset:
         set_language_changer(self.request, queryset[0].language_changer)
     return queryset
开发者ID:Mindscope,项目名称:cmsplugin-blog,代码行数:5,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.MEP类代码示例发布时间:2022-05-27
下一篇:
Python menu_tags.show_menu函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap