Skip to content

Commit

Permalink
Fix update of translations for content created before package install…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
hvelarde committed Sep 7, 2016
1 parent 946bf7c commit 376b586
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,9 @@ Changelog
1.0b2 (unreleased)
^^^^^^^^^^^^^^^^^^

- Nothing changed yet.
- An error message was shown while updating content created before the installation of this package;
now, before updating, we check if the translation exists; if not, we create a new one.
[hvelarde]


1.0b1 (2016-09-07)
Expand Down
10 changes: 8 additions & 2 deletions src/brasil/gov/vlibrasnews/subscribers.py
Expand Up @@ -137,8 +137,14 @@ def update_content_handler(context, event):

vlibrasnews = VLibrasNews(token=token)
payload = get_content(context)
logger.debug('Updating LIBRAS translation for ' + context.absolute_url())
vlibrasnews.update(context.UID(), payload)
if vlibrasnews.get(context.UID()):
# if the translation exists, update it
logger.debug('Updating LIBRAS translation for ' + context.absolute_url())
vlibrasnews.update(context.UID(), payload)
else:
# otherwise, create it
logger.debug('Creating translation for ' + context.absolute_url())
vlibrasnews.create(context.UID(), payload)

return True

Expand Down

0 comments on commit 376b586

Please sign in to comment.