Add related name accesor to the tag properties model
This commit is contained in:
@@ -9,7 +9,8 @@ from .literals import COLOR_CHOICES, COLOR_CODES
|
||||
|
||||
|
||||
class TagProperties(models.Model):
|
||||
tag = models.ForeignKey(Tag, verbose_name=_(u'tag'))
|
||||
# TODO: this should be a One to One relation not a ForeignKey
|
||||
tag = models.ForeignKey(Tag, verbose_name=_(u'tag'), related_name='properties')
|
||||
color = models.CharField(max_length=3, choices=COLOR_CHOICES, verbose_name=_(u'color'))
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -13,7 +13,7 @@ def get_tags_inline_widget(document):
|
||||
tags_template.append(u'<div class="tc">')
|
||||
|
||||
for tag in document.tags.all():
|
||||
tags_template.append(u'<ul class="tags"><li style="background: %s;">%s</li></ul>' % (tag.tagproperties_set.get().get_color_code(), escape(tag.name)))
|
||||
tags_template.append(u'<ul class="tags"><li style="background: %s;">%s</li></ul>' % (tag.properties.get().get_color_code(), escape(tag.name)))
|
||||
|
||||
tags_template.append(u'<div style="clear:both;"></div>')
|
||||
tags_template.append(u'</div>')
|
||||
@@ -46,4 +46,4 @@ def single_tag_widget(tag):
|
||||
|
||||
|
||||
def get_single_tag_template(tag):
|
||||
return '<li style="background: %s">%s</li>' % (tag.tagproperties_set.get().get_color_code(), escape(tag.name).replace(u' ', u' '))
|
||||
return '<li style="background: %s">%s</li>' % (tag.properties.get().get_color_code(), escape(tag.name).replace(u' ', u' '))
|
||||
|
||||
Reference in New Issue
Block a user