##// END OF EJS Templates
Cache tag localized names
neko259 -
r1888:832beb99 default
parent child Browse files
Show More
@@ -86,7 +86,6 b' class Tag(models.Model, Viewable):'
86 parent = models.ForeignKey('Tag', null=True, blank=True,
86 parent = models.ForeignKey('Tag', null=True, blank=True,
87 related_name='children')
87 related_name='children')
88
88
89 @cached_result()
90 def get_name(self):
89 def get_name(self):
91 return self.aliases.get(locale=DEFAULT_LOCALE).name
90 return self.aliases.get(locale=DEFAULT_LOCALE).name
92
91
@@ -124,6 +123,10 b' class Tag(models.Model, Viewable):'
124 def is_required(self):
123 def is_required(self):
125 return self.required
124 return self.required
126
125
126 def _get_locale_cache_key(self):
127 return '{}_{}'.format(self.id, get_language())
128
129 @cached_result(key_method=_get_locale_cache_key)
127 def get_view(self):
130 def get_view(self):
128 locale = get_language()
131 locale = get_language()
129
132
@@ -191,4 +194,3 b' class Tag(models.Model, Viewable):'
191 attachment_posts__thread__tags__in=[self]).filter(
194 attachment_posts__thread__tags__in=[self]).filter(
192 mimetype__in=FILE_TYPES_IMAGE).order_by('-attachment_posts__pub_time')
195 mimetype__in=FILE_TYPES_IMAGE).order_by('-attachment_posts__pub_time')
193
196
194
General Comments 0
You need to be logged in to leave comments. Login now