Commit 9d381c45 authored by Michal Čihař's avatar Michal Čihař

Replace unit-state.html with Unit method

parent 1ceacc17
......@@ -35,6 +35,8 @@ from trans.filelock import FileLockException
from trans.util import is_plural, split_plural, join_plural
import weblate
FLAG_TEMPLATE = '<span title="%s" class="flag-icon ui-icon ui-icon-%s"></span>'
class UnitManager(models.Manager):
def update_from_unit(self, translation, unit, pos):
......@@ -992,3 +994,41 @@ class Unit(models.Model):
+ self.translation.subproject.all_flags
)
return self._all_flags
def get_state_flags(self):
'''
Returns state flags.
'''
flags = []
if self.fuzzy:
flags.append(
_('Message is fuzzy'),
'help'
)
elif not self.translated:
flags.append(
_('Message is not translated'),
'document-b'
)
elif self.has_failing_check:
flags.append(
_('Message has failing checks'),
'notice'
)
elif self.translated:
flags.append(
_('Message is translated'),
'check'
)
if self.has_comment:
flags.append(
_('Message has comments'),
'comment'
)
return mark_safe(
'\n'.join([FLAG_TEMPLATE % flag for flag in flags])
)
......@@ -11,7 +11,7 @@
<td>{{ item.translation.subproject }}</td>
<td class="translatetext"><a href="{{ item.get_absolute_url }}">{{ item.source|fmttranslation }}</a></td>
<td class="translatetext" {{ item.translation.language.get_html }}><a href="{{ item.get_absolute_url }}">{{ item.target|fmttranslationdiff:unit }}</a></td>
{% include "unit-state.html" %}
<td>{{ item.get_state_flags }}</td>
<td>
{% if perms.trans.save_translation %}
<a class="mergebutton small-button" href="{{ unit.translation.get_translate_url}}?sid={{ search_id }}&amp;offset={{ offset }}&amp;checksum={{ unit.checksum }}&amp;merge={{ item.id }}" title="{% trans "Use this translation for all subprojects" %}">{% trans "Use this translation" %}</a>
......
......@@ -211,7 +211,7 @@
<td class="number"><a href="{{ item.get_absolute_url }}">{{ item.position }}</a></td>
<td class="translatetext"><a href="{{ item.get_absolute_url }}">{{ item.source|fmttranslation }}</a></td>
<td class="translatetext translation_html_markup" {{ item.translation.language.get_html }}><a href="{{ item.get_absolute_url }}">{{ item.target|fmttranslation:unit.translation.language }}</a></td>
{% include "unit-state.html" %}
<td>{{ item.get_state_flags }}</td>
</tr>
{% endfor %}
</tbody>
......
{% load i18n %}
<td>
{% if item.fuzzy %}<span title="{% trans "Message is fuzzy" %}" class="flag-icon ui-icon ui-icon-help"></span>{% else %}
{% if not item.translated %}<span title="{% trans "Message is not translated" %}" class="flag-icon ui-icon ui-icon-document-b"></span>{% else %}
{% if item.has_failing_check %}<span title="{% trans "Message has failing checks" %}" class="flag-icon ui-icon ui-icon-notice"></span>{% else %}
{% if item.translated %}<span title="{% trans "Message is translated" %}" class="flag-icon ui-icon ui-icon-check"></span>{% endif %}
{% endif %}{% endif %}{% endif %}
{% if item.has_comment %}<span title="{% trans "Message has comments" %}" class="flag-icon ui-icon ui-icon-comment"></span>{% endif %}
</td>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment