Commit 7540d39c authored by Michal Čihař's avatar Michal Čihař

Store language code for update

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 4f58d14a
......@@ -54,7 +54,7 @@ class Command(BaseCommand):
indexupdates.add(update.pk)
delete_search_unit(
update.unitid,
update.translation.language.code
update.language_code
)
# Delete processed updates
......
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-02-02 12:28
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trans', '0056_auto_20160202_1224'),
]
operations = [
migrations.AddField(
model_name='indexupdate',
name='language_code',
field=models.SlugField(default=''),
preserve_default=False,
),
]
......@@ -27,6 +27,7 @@ class IndexUpdate(models.Model):
unitid = models.IntegerField(unique=True)
source = models.BooleanField(default=True)
to_delete = models.BooleanField(default=False)
language_code = models.SlugField()
class Meta(object):
app_label = 'trans'
......
......@@ -190,7 +190,7 @@ def update_index(units, source_units=None):
writer.close()
def add_index_update(unit_id, source, to_delete):
def add_index_update(unit_id, source, to_delete, language_code=''):
from weblate.trans.models.search import IndexUpdate
try:
with transaction.atomic():
......@@ -198,6 +198,7 @@ def add_index_update(unit_id, source, to_delete):
unitid=unit_id,
source=source,
to_delete=to_delete,
language_code=language_code,
)
# pylint: disable=E0712
except IntegrityError:
......@@ -208,6 +209,7 @@ def add_index_update(unit_id, source, to_delete):
update.source = True
if to_delete:
update.to_delete = True
update.language_code = language_code
update.save()
except IndexUpdate.DoesNotExist:
# It did exist, but was deleted meanwhile
......@@ -311,7 +313,7 @@ def clean_search_unit(pk, lang):
"""Cleanups search index on unit deletion."""
if appsettings.OFFLOAD_INDEXING:
from weblate.trans.models.search import IndexUpdate
add_index_update(pk, False, True)
add_index_update(pk, False, True, lang)
else:
delete_search_unit(pk, lang)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment