Commit cf3464d8 authored by Michal Čihař's avatar Michal Čihař

Create change object for new strings (issue #241)

parent 9ae5cade
...@@ -144,6 +144,7 @@ class Change(models.Model): ...@@ -144,6 +144,7 @@ class Change(models.Model):
ACTION_DICTIONARY_NEW = 10 ACTION_DICTIONARY_NEW = 10
ACTION_DICTIONARY_EDIT = 11 ACTION_DICTIONARY_EDIT = 11
ACTION_DICTIONARY_UPLOAD = 12 ACTION_DICTIONARY_UPLOAD = 12
ACTION_NEW_SOURCE = 13
ACTION_CHOICES = ( ACTION_CHOICES = (
(ACTION_UPDATE, ugettext_lazy('Resource update')), (ACTION_UPDATE, ugettext_lazy('Resource update')),
...@@ -159,6 +160,7 @@ class Change(models.Model): ...@@ -159,6 +160,7 @@ class Change(models.Model):
(ACTION_DICTIONARY_NEW, ugettext_lazy('Glossary added')), (ACTION_DICTIONARY_NEW, ugettext_lazy('Glossary added')),
(ACTION_DICTIONARY_EDIT, ugettext_lazy('Glossary updated')), (ACTION_DICTIONARY_EDIT, ugettext_lazy('Glossary updated')),
(ACTION_DICTIONARY_UPLOAD, ugettext_lazy('Glossary uploaded')), (ACTION_DICTIONARY_UPLOAD, ugettext_lazy('Glossary uploaded')),
(ACTION_NEW_SOURCE, ugettext_lazy('New source string')),
) )
unit = models.ForeignKey(Unit, null=True) unit = models.ForeignKey(Unit, null=True)
......
...@@ -444,11 +444,23 @@ class Unit(models.Model): ...@@ -444,11 +444,23 @@ class Unit(models.Model):
) )
# Ensure we track source string # Ensure we track source string
Source.objects.get_or_create( dummy, created = Source.objects.get_or_create(
checksum=self.checksum, checksum=self.checksum,
subproject=self.translation.subproject subproject=self.translation.subproject
) )
# Create change object for new source string
if created:
from trans.models.changes import Change
Change.objects.create(
translation=self.translation,
action=Change.ACTION_NEW_SOURCE,
user=request.user,
unit=self,
author=user
)
def is_plural(self): def is_plural(self):
''' '''
Checks whether message is plural. Checks whether message is plural.
......
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