Commit 2f13c99d authored by Michal Čihař's avatar Michal Čihař

Fixed suggestion adding after refactor

parent 37b6793f
...@@ -879,10 +879,12 @@ class Unit(models.Model): ...@@ -879,10 +879,12 @@ class Unit(models.Model):
position__lte=self.position + appsettings.NEARBY_MESSAGES, position__lte=self.position + appsettings.NEARBY_MESSAGES,
) )
def add_suggestion(self, target): def add_suggestion(self, target, user):
''' '''
Creates new suggestion for this unit. Creates new suggestion for this unit.
''' '''
from trans.models.unitdata import Suggestion, Change
# Create the suggestion # Create the suggestion
Suggestion.objects.create( Suggestion.objects.create(
target=target, target=target,
...@@ -893,9 +895,9 @@ class Unit(models.Model): ...@@ -893,9 +895,9 @@ class Unit(models.Model):
) )
# Record in change # Record in change
Change.objects.create( Change.objects.create(
unit=unit, unit=self,
action=Change.ACTION_SUGGESTION, action=Change.ACTION_SUGGESTION,
translation=unit.translation, translation=self.translation,
user=user user=user
) )
# Update suggestion count # Update suggestion count
......
...@@ -110,7 +110,8 @@ def translate(request, project, subproject, lang): ...@@ -110,7 +110,8 @@ def translate(request, project, subproject, lang):
) )
# Create the suggestion # Create the suggestion
unit.add_suggestion( unit.add_suggestion(
join_plural(form.cleaned_data['target']) join_plural(form.cleaned_data['target']),
user
) )
# Invite user to become translator if there is nobody else # Invite user to become translator if there is nobody else
recent_changes = Change.objects.content().filter( recent_changes = Change.objects.content().filter(
......
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