Commit 9bd0aeab authored by Michal Čihař's avatar Michal Čihař

Store lock/unlock events in history

Fixes #624
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent d47f1d87
......@@ -149,6 +149,8 @@ class Change(models.Model):
ACTION_DICTIONARY_EDIT = 11
ACTION_DICTIONARY_UPLOAD = 12
ACTION_NEW_SOURCE = 13
ACTION_LOCK = 14
ACTION_UNLOCK = 15
ACTION_CHOICES = (
(ACTION_UPDATE, ugettext_lazy('Resource update')),
......@@ -165,6 +167,8 @@ class Change(models.Model):
(ACTION_DICTIONARY_EDIT, ugettext_lazy('Glossary updated')),
(ACTION_DICTIONARY_UPLOAD, ugettext_lazy('Glossary uploaded')),
(ACTION_NEW_SOURCE, ugettext_lazy('New source string')),
(ACTION_LOCK, ugettext_lazy('Component locked')),
(ACTION_UNLOCK, ugettext_lazy('Component unlocked')),
)
unit = models.ForeignKey('Unit', null=True)
......
......@@ -1331,8 +1331,20 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
"""Locks component."""
self.locked = True
self.save()
if self.translation_set.exists():
Change.objects.create(
translation=self.translation_set.all()[0],
user=user,
action=Change.ACTION_LOCK,
)
def do_unlock(self, user):
"""Locks component."""
self.locked = False
self.save()
if self.translation_set.exists():
Change.objects.create(
translation=self.translation_set.all()[0],
user=user,
action=Change.ACTION_UNLOCK,
)
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