[damned-lies] Updated image URLs for the GitLab system



commit 733224dd0f244dd60d24d9d7cee35d8e4dcf483e
Author: Claude Paroz <claude 2xlibre net>
Date:   Wed Jun 27 14:26:22 2018 +0200

    Updated image URLs for the GitLab system

 stats/models.py      | 14 ++++++--------
 stats/tests/tests.py |  2 +-
 2 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 277b2794..77c9bc38 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -259,11 +259,7 @@ class Branch(models.Model):
 
     @property
     def img_url_prefix(self):
-        return self.module.vcs_type == 'git' and "plain" or ""
-
-    @property
-    def img_url_suffix(self):
-        return self.module.vcs_type == 'git' and "?h=%s" % self.name or ""
+        return self.module.vcs_type == 'git' and "raw" or ""
 
     def is_head(self):
         return self.name in BRANCH_HEAD_NAMES
@@ -1527,9 +1523,11 @@ class Statistics(models.Model):
             [{'path':, 'hash':, 'fuzzy':, 'translated':, 'translated_file':}, ...] """
         figures = []
         if self.full_po and self.domain.dtype == 'doc' and self.full_po.figures:
-            # something like: "https://gitlab.gnome.org/GNOME/vinagre / plain / help / %s / %s ?h=master"
-            url_model = utils.url_join(self.branch.get_vcs_web_url(), self.branch.img_url_prefix,
-                                       self.domain.directory, '%s', '%s') + self.branch.img_url_suffix
+            # something like: "https://gitlab.gnome.org/GNOME/vinagre / raw / master / help / %s / %s"
+            url_model = utils.url_join(
+                self.branch.get_vcs_web_url(), self.branch.img_url_prefix,
+                self.branch.name, self.domain.directory, '%s', '%s'
+            )
             for fig in self.full_po.figures:
                 fig2 = fig.copy()
                 fig2['orig_remote_url'] = url_model % ('C', fig['path'])
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index a4abbaa9..8daca788 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -668,7 +668,7 @@ class FigureTests(TestCase):
         """ Test if figure urls are properly constructed """
         stat = Statistics.objects.get(branch__module__name='gnome-hello', branch__name='master', 
domain__dtype='doc', language__locale='fr')
         figs = stat.get_figures()
-        self.assertEqual(figs[0]['orig_remote_url'], 
'https://gitlab.gnome.org/GNOME/gnome-hello/plain/help/C/figures/gnome-hello-new.png?h=master')
+        self.assertEqual(figs[0]['orig_remote_url'], 
'https://gitlab.gnome.org/GNOME/gnome-hello/raw/master/help/C/figures/gnome-hello-new.png')
         self.assertFalse('trans_remote_url' in figs[0])
 
     @test_scratchdir


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