Show links to source files

This commit is contained in:
Michal Čihař 2012-02-28 16:01:07 +01:00
parent a358491a87
commit 84c24dc1c7
2 changed files with 12 additions and 1 deletions

View File

@ -19,7 +19,7 @@
{% else %}
<tr><td>{{ unit.source }}</td><td colspan="2">{{ form.target }}</td></tr>
{% endif %}
<tr><td>{{ unit.location }}</td></tr>
<tr><td>{{ unit.get_location_links }}</td></tr>
<tr><td></td><td>
<input type="submit" value="{% trans "Save" %}" />
<a href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;oldpos={{ unit.position }}">{% trans "Skip" %}</a>

View File

@ -3,6 +3,7 @@ from django.db.models import Q
from django.conf import settings
from lang.models import Language
from django.utils.translation import ugettext_lazy, ugettext as _
from django.utils.safestring import mark_safe
from glob import glob
import os
import os.path
@ -363,3 +364,13 @@ class Unit(models.Model):
else:
del kwargs['backend']
super(Unit, self).save(*args, **kwargs)
def get_location_links(self):
ret = []
for location in self.location.split(','):
location = location.strip()
filename, line = location.split(':')
link = 'https://github.com/phpmyadmin/phpmyadmin/blob/master/%s#L%s' % (filename, line)
ret.append('<a href="%s">%s</a>' % (link, location))
return mark_safe('\n'.join(ret))