Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/native/core/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ def test_push_strings_reaches_cds_handler(

strings = [SourceString('a'), SourceString('b')]
mytx = self._get_tx()
mytx.push_source_strings(strings, False, True, True, True)
mock_push_strings.assert_called_once_with(strings, False, True, True, True)
mytx.push_source_strings(strings, False, True, True, True, False)
mock_push_strings.assert_called_once_with(strings, False, True, True, True, False)

@patch('transifex.native.core.MemoryCache.update')
@patch('transifex.native.core.CDSHandler.fetch_translations')
Expand Down
1 change: 1 addition & 0 deletions tests/native/django/test_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def get_transifex_command():
'override_occurrences',
'do_not_keep_translations',
'symlinks',
'force_source_update',

# Invalidate
'purge',
Expand Down
6 changes: 5 additions & 1 deletion transifex/native/cds.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def fetch_translations(self, language_code=None):
def push_source_strings(self, strings, purge=False,
do_not_keep_translations=False,
override_tags=False,
override_occurrences=False):
override_occurrences=False,
force_source_update=False):
"""Push source strings to CDS.

:param list(SourceString) strings: a list of `SourceString` objects
Expand All @@ -219,6 +220,8 @@ def push_source_strings(self, strings, purge=False,
False appends them to existing tags.
:param bool override_occurrences: True replaces all the occurrences of pushed strings.
False appends them to existing occurrences.
:param bool force_source_update: True forces the update of the source strings.
False lets the normal revision logic handle the update.
:return: the HTTP response object
:rtype: requests.Response
"""
Expand All @@ -242,6 +245,7 @@ def push_source_strings(self, strings, purge=False,
'keep_translations': not do_not_keep_translations,
'override_tags': override_tags,
'override_occurrences': override_occurrences,
'force_source_update': force_source_update,
},
}
)
Expand Down
7 changes: 5 additions & 2 deletions transifex/native/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def fetch_translations(self):
def push_source_strings(self, strings, purge=False,
do_not_keep_translations=False,
override_tags=False,
override_occurrences=False):
override_occurrences=False,
force_source_update=False):
"""Push the given source strings to the CDS.

:param list strings: a list of SourceString objects
Expand All @@ -212,13 +213,15 @@ def push_source_strings(self, strings, purge=False,
False appends them to existing tags.
:param bool override_occurrences: True replaces all the occurrences of pushed strings.
False appends them to existing occurrences.
:param bool force_source_update: True forces the update of the source strings.
False lets the normal revision logic handle the update.
:return: a tuple containing the status code and the content of the
response
:rtype: tuple
"""
self._check_initialization()
response = self._cds_handler.push_source_strings(
strings, purge, do_not_keep_translations, override_tags, override_occurrences)
strings, purge, do_not_keep_translations, override_tags, override_occurrences, force_source_update)
return response.status_code, json.loads(response.content)

def get_push_status(self, job_path):
Expand Down
7 changes: 6 additions & 1 deletion transifex/native/django/management/utils/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def add_arguments(self, subparsers):
choices=['source', 'hash'],
help=('Use "hash" or "source" based keys (default: source)'),
)
parser.add_argument(
'--force-source-update', action='store_true', dest='force_source_update', default=False,
help=('Force the update of the source strings'),
)

def handle(self, *args, **options):
self.verbose_output = options['verbose_output']
Expand All @@ -108,6 +112,7 @@ def handle(self, *args, **options):
self.do_not_keep_translations = options['do_not_keep_translations']
self.no_wait = options['no_wait']
self.key_generator = options['key_generator']
self.force_source_update = options['force_source_update']
extensions = options['extensions']
if self.domain == 'djangojs':
exts = extensions if extensions else ['js']
Expand Down Expand Up @@ -200,7 +205,7 @@ def push_strings(self):
status_code, response_content = tx.push_source_strings(
self.string_collection.strings.values(), self.purge,
self.do_not_keep_translations, self.override_tags,
self.override_occurrences
self.override_occurrences, self.force_source_update
)

if self.no_wait:
Expand Down