Skip to content

Commit 9e2e42f

Browse files
mathjazzeemeli
andauthored
If the project using configuration file has unsynced locales, perform forced sync (#3615)
Co-authored-by: Eemeli Aro <eemeli@gmail.com>
1 parent 6296607 commit 9e2e42f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pontoon/base/models/project.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.db.models import Sum
88
from django.db.models.manager import BaseManager
99
from django.utils import timezone
10+
from django.utils.functional import cached_property
1011

1112
from pontoon.base.aggregated_stats import AggregatedStats
1213
from pontoon.base.models.locale import Locale
@@ -231,6 +232,17 @@ class Meta:
231232
def __str__(self):
232233
return self.name
233234

235+
@cached_property
236+
def unsynced_locales(self):
237+
"""
238+
Project Locales that haven't been synchronized yet.
239+
"""
240+
return self.locales.exclude(
241+
pk__in=Locale.objects.filter(
242+
translatedresources__resource__project=self
243+
).values_list("pk", flat=True)
244+
)
245+
234246
def serialize(self):
235247
return {
236248
"pk": self.pk,

pontoon/sync/core/checkout.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ def checkout_repos(
9999
"""
100100
source: Checkout | None = None
101101
target: Checkout | None = None
102+
103+
# If the project using configuration file has unsynced locales, perform forced sync
104+
if not force and project.configuration_file and project.unsynced_locales:
105+
force = True
106+
102107
for repo in cast(BaseManager[Repository], project.repositories).all():
103108
if repo.source_repo:
104109
if source:

0 commit comments

Comments
 (0)