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

Python models.delete_translation函数代码示例

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

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



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

示例1: _collapse_summary

def _collapse_summary(app):

    task_log.info('[Webapp:%s] Collapsing summary.' % app.id)

    # No prior summary so do nothing.
    if app.summary_id is None:
        return

    # Handle no prior description.
    if app.description_id is None:
        # These should be translation ids and copy easily.
        app.description_id = app.summary_id
        app.summary_id = None
        app.save()
        task_log.info('[Webapp:%s] No description, copied translation %s.' % (
            app.id, app.description_id))
        return

    # The other cases require looking at the localized strings in the
    # translation table in all locales.
    for summary in Translation.objects.filter(id=app.summary_id):
        try:
            descr = Translation.objects.get(id=app.description_id,
                                            locale=summary.locale)
        except Translation.DoesNotExist:
            # We have a summary in this locale but not a description.
            try:
                Translation.objects.create(
                    id=app.description_id, locale=summary.locale,
                    localized_string=summary.localized_string,
                    localized_string_clean=summary.localized_string_clean)
                task_log.info('[Webapp:%s] Created description in locale %s '
                              'with translation %s.' % (app.id, summary.locale,
                                                        app.description_id))
            except IntegrityError:
                task_log.info('[Webapp:%s] Tried inserting a new description '
                              'for translation %s and locale %s from summary '
                              'but failed.' % (app.id, summary.id,
                                               summary.locale))
            continue

        # If summary is a truncated description, delete the summary.
        if (descr.localized_string and
            descr.localized_string.startswith(summary.localized_string)):
            task_log.info('[Webapp:%s] Description starts with summary for '
                          'translation %s and locale %s.' % (
                              app.id, summary.id, summary.locale))
            continue

        # Otherwise, concat summary and description together.
        descr.localized_string = u'%s\n%s' % (
            summary.localized_string, descr.localized_string)
        descr.localized_string_clean = u'%s\n%s' % (
            summary.localized_string_clean, descr.localized_string_clean)
        descr.save()
        task_log.info('[Webapp:%s] Concatenated summary and description for '
                      'translation %s and locale %s' % (app.id, descr.id,
                                                        descr.locale))

    delete_translation(app, 'summary')
开发者ID:markh-bz,项目名称:zamboni,代码行数:60,代码来源:tasks.py


示例2: save

    def save(self, commit=True):
        ob = super(PolicyForm, self).save(commit)
        for k, field in (("has_eula", "eula"), ("has_priv", "privacy_policy")):
            if not self.cleaned_data[k]:
                delete_translation(self.instance, field)

        if "privacy_policy" in self.changed_data:
            amo.log(amo.LOG.CHANGE_POLICY, self.addon, self.instance)

        return ob
开发者ID:nearlyfreeapps,项目名称:olympia,代码行数:10,代码来源:forms.py


示例3: tearDownClass

 def tearDownClass(cls):
     try:
         if hasattr(cls, '_addons'):
             addons = Addon.objects.filter(
                 pk__in=[a.id for a in cls._addons])
             # First delete all the translations.
             for addon in addons:
                 for field in addon._meta.translated_fields:
                     delete_translation(addon, field.name)
             # Then delete the addons themselves.
             addons.delete()
             unindex_addons([a.id for a in cls._addons])
         amo.SEARCH_ANALYZER_MAP = cls._SEARCH_ANALYZER_MAP
     finally:
         # Make sure we're calling super's tearDownClass even if something
         # went wrong in the code above, as otherwise we'd run into bug
         # 960598.
         super(ESTestCase, cls).tearDownClass()
开发者ID:psyko0815,项目名称:olympia,代码行数:18,代码来源:__init__.py


示例4: remove_profile

def remove_profile(request, addon_id, addon, webapp=False):
    delete_translation(addon, 'the_reason')
    delete_translation(addon, 'the_future')
    if addon.wants_contributions:
        addon.update(wants_contributions=False)
    return redirect(addon.get_dev_url('profile'))
开发者ID:bearstech,项目名称:zamboni,代码行数:6,代码来源:views.py


示例5: remove_profile

def remove_profile(request, addon_id, addon):
    delete_translation(addon, 'the_reason')
    delete_translation(addon, 'the_future')
    if addon.wants_contributions:
        addon.update(wants_contributions=False)
    return redirect('devhub.addons.profile', addon.slug)
开发者ID:AutomatedTester,项目名称:zamboni,代码行数:6,代码来源:views.py


示例6: save

 def save(self, commit=True):
     super(PolicyForm, self).save(commit)
     for k, field in (('has_eula', 'eula'), ('has_priv', 'privacy_policy')):
         if not self.cleaned_data[k]:
             delete_translation(self.instance, field)
开发者ID:exezaid,项目名称:zamboni,代码行数:5,代码来源:forms.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.PurifiedTranslation类代码示例发布时间:2022-05-27
下一篇:
Python helpers.truncate函数代码示例发布时间: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