本文整理汇总了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')
示例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
示例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()
示例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'))
示例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)
示例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)