Commits

Diego Búrigo Zacarão  committed 0710a06

Added Tx repository revision into the footer

- Helpful to identify the exactly revision used to
run a Tx instance using a devel branch.

  • Participants
  • Parent commits efe6351

Comments (0)

Files changed (3)

File transifex/templates/base-sample.html

       {% block footerlinks %}{% trans "About" %} | <a href="{% url contact_form %}" title="{% trans "Drops us a line" %}">{% trans "Feedback" %}</a>{% endblock %}
     </p>
     {% block powered %}<p class="powered">{% blocktrans %}Powered by <a href="http://transifex.org/" title="Transifex community">Transifex</a>, the Open Translation Platform{% endblocktrans %}</p>{% endblock %}
-    {% block txversionblock %}<p class="version">v{% txversion %}</p>{% endblock %}
+    {% block txversionblock %}<p class="version">v{% txversion_full %} </p>{% endblock %}
     {% block extrafooter %}{% endblock %}
   {% endblock %}</div>
 {% block bodyend %}{% endblock %}

File transifex/txcommon/__init__.py

-version_info = (0, 9, 0, 'devel', 0)
+import os
+from mercurial import hg, ui
+
+version_info = (0, 9, 0, 'devel')
 
 _verpart = ''
 if version_info[3] != 'final':
 
 version = '.'.join(str(v) for v in version_info[:3]) + _verpart
 
+try:
+    # Take the revision of the updated/working none/changeset
+    revision = 'r%s' % hg.repository(ui.ui(),
+        __file__.split('/transifex/txcommon')[0])[None].parents()[0].rev()
+except Exception:
+    revision = ''
+
+# A 'final' version should have its revision hidden even in the full version
+if revision and _verpart:
+    version_full = version + '-' + revision
+else:
+    version_full = version
+
 del _verpart
 
 def import_to_python(import_str):

File transifex/txcommon/templatetags/txcommontags.py

     """Return the version of Transifex"""
     return txcommon.version
 
+@register.simple_tag
+def txrevision():
+    """
+    Return the revision of the Transifex repository in case it's running on 
+    top of a checkout. If it's not, return an empty string.
+    """
+    return txcommon.revision
+
+@register.simple_tag
+def txversion_full():
+    """
+    Return the full version of Transifex.
+    
+    For versions that are not 'final' return the current version of Transifex 
+    plus the revision of the repository, in case it's running on top of a 
+    checkout.
+    """
+    return txcommon.version_full
 
 class CounterNode(ResolverNode):
     """A template node to count how many times it was called."""