damned-lies r1376 - in trunk: . vertimus



Author: claudep
Date: Tue Jan 20 21:51:46 2009
New Revision: 1376
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1376&view=rev

Log:
2009-01-20  Claude Paroz  <claude 2xlibre net>

	* vertimus/models.py: If pot file does not exist, do not merge. Make
	vertimus tests pass again.
	* vertimus/views.py: Provide for the case where there isn't a merged
	file.

Modified:
   trunk/ChangeLog
   trunk/vertimus/models.py
   trunk/vertimus/views.py

Modified: trunk/vertimus/models.py
==============================================================================
--- trunk/vertimus/models.py	(original)
+++ trunk/vertimus/models.py	Tue Jan 20 21:51:46 2009
@@ -677,7 +677,10 @@
 def merge_uploaded_file(sender, instance, **kwargs):
     """ post_save callback for ActionDb that automatically merge uploaded file with latest pot file """
     if instance.file and instance.file.path.endswith('.po'):
-        stat = Statistics.objects.get(branch=instance.state_db.branch, domain=instance.state_db.domain, language=None)
+        try:
+            stat = Statistics.objects.get(branch=instance.state_db.branch, domain=instance.state_db.domain, language=None)
+        except Statistics.DoesNotExist:
+            return
         potfile = stat.po_path()
         instance.merge_file_with_pot(potfile)
 post_save.connect(merge_uploaded_file, sender=ActionDb)

Modified: trunk/vertimus/views.py
==============================================================================
--- trunk/vertimus/views.py	(original)
+++ trunk/vertimus/views.py	Tue Jan 20 21:51:46 2009
@@ -116,6 +116,8 @@
     action_db1 = get_object_or_404(ActionDb, pk=action_id)
     state = action_db1.state_db
     file_path1 = action_db1.get_action().merged_file()['path']
+    if not file_path1:
+        file_path1 = action_db1.file.path
     content1 = [l.decode('utf-8') for l in open(file_path1, 'U').readlines()]
     descr1 = _("Uploaded file by %(name)s on %(date)s") % { 'name': action_db1.person.name,
                                                             'date': action_db1.created }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]