Show More
@@ -4,7 +4,7 b' import re' | |||
|
4 | 4 | from boards.models.attachment import FILE_TYPES_IMAGE |
|
5 | 5 | from django.template.loader import render_to_string |
|
6 | 6 | from django.db import models |
|
7 | from django.db.models import Count | |
|
7 | from django.db.models import Count, Q | |
|
8 | 8 | from django.core.urlresolvers import reverse |
|
9 | 9 | from django.utils.translation import get_language |
|
10 | 10 | |
@@ -130,14 +130,19 b' class Tag(models.Model, Viewable):' | |||
|
130 | 130 | def get_view(self): |
|
131 | 131 | locale = get_language() |
|
132 | 132 | |
|
133 | try: | |
|
134 | localized_tag_name = self.aliases.get(locale=locale).name | |
|
135 | except TagAlias.DoesNotExist: | |
|
136 |
|
|
|
133 | aliases = self.aliases.filter(Q(locale=locale) | Q(locale=DEFAULT_LOCALE)) | |
|
134 | ||
|
135 | localized_tag_name = None | |
|
136 | default_tag_name = None | |
|
137 | 137 | |
|
138 | default_name = self.get_name() | |
|
138 | for alias in aliases: | |
|
139 | if alias.locale == locale: | |
|
140 | localized_tag_name = alias.name | |
|
141 | elif alias.locale == DEFAULT_LOCALE: | |
|
142 | default_tag_name = alias.name | |
|
139 | 143 | |
|
140 |
name = '{} ({})'.format(default_name, localized_tag_name) |
|
|
144 | name = '{} ({})'.format(default_tag_name, localized_tag_name) \ | |
|
145 | if localized_tag_name else default_tag_name | |
|
141 | 146 | link = '<a class="tag" href="{}">{}</a>'.format( |
|
142 | 147 | self.get_absolute_url(), name) |
|
143 | 148 | if self.is_required(): |
General Comments 0
You need to be logged in to leave comments.
Login now