From 6538ce2192d097290f59e0d98a2714e3afa4aaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 27 Feb 2012 16:29:32 +0100 Subject: [PATCH] Prepare stub for actually loading po file --- trans/managers.py | 3 +-- trans/models.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/trans/managers.py b/trans/managers.py index 86035e38b..40e378c9c 100644 --- a/trans/managers.py +++ b/trans/managers.py @@ -7,11 +7,10 @@ class TranslationManager(models.Manager): ''' Parses translation meta info and creates/updates translation object. ''' - print code lang = Language.objects.get(code = code) trans, created = self.get_or_create( language = lang, subproject = subproject, filename = path) - print trans + trans.update_from_blob(blob) diff --git a/trans/models.py b/trans/models.py index dbd109bc5..c6508237d 100644 --- a/trans/models.py +++ b/trans/models.py @@ -161,6 +161,17 @@ class Translation(models.Model): def __unicode__(self): return '%s@%s' % (self.language.name, self.subproject.__unicode__()) + def update_from_blob(self, blob): + ''' + Updates translation data from blob. + ''' + # Check if we're not already up to date + if self.revision == blob.hexsha: + return + + oldunits = set(self.unit_set.all().values_list('id', flat = True)) + + class Unit(models.Model): translation = models.ForeignKey(Translation) location = models.TextField()