Skip to content

Commit

Permalink
Merge pull request #6037 from readthedocs/agj/fix-translation-form-save
Browse files Browse the repository at this point in the history
Fix issue with save on translation form
  • Loading branch information
ericholscher authored Aug 7, 2019
2 parents e80b0da + 3304404 commit a5dadaa
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,12 +614,18 @@ def get_translation_queryset(self):
)
return queryset

def save(self):
project = self.parent.translations.add(self.translation)
# Run symlinking and other sync logic to make sure we are in a good
# state.
self.parent.save()
return project
def save(self, commit=True):
if commit:
# Don't use ``self.parent.translations.add()`` here as this
# triggeres a problem with database routing and multiple databases.
# Directly set the ``main_language_project`` instead of doing a
# bulk update.
self.translation.main_language_project = self.parent
self.translation.save()
# Run symlinking and other sync logic to make sure we are in a good
# state.
self.parent.save()
return self.parent


class TranslationForm(SettingsOverrideObject):
Expand Down

0 comments on commit a5dadaa

Please sign in to comment.