3 from django.utils.translation import ugettext as _
6 class ActiveTagManager(UndeletedObjectManager):
7 def get_query_set(self):
8 return super(UndeletedObjectManager, self).get_query_set().exclude(used_count=0)
11 class Tag(BaseModel, DeletableContent):
12 name = models.CharField(max_length=255, unique=True)
13 created_by = models.ForeignKey(User, related_name='created_tags')
14 marked_by = models.ManyToManyField(User, related_name="marked_tags", through="MarkedTag")
16 used_count = models.PositiveIntegerField(default=0)
18 active = ActiveTagManager()
20 class Meta(DeletableContent.Meta):
22 ordering = ('-used_count', 'name')
24 def __unicode__(self):
27 class MarkedTag(models.Model):
28 TAG_MARK_REASONS = (('good',_('interesting')),('bad',_('ignored')))
29 tag = models.ForeignKey(Tag, related_name='user_selections')
30 user = models.ForeignKey(User, related_name='tag_selections')
31 reason = models.CharField(max_length=16, choices=TAG_MARK_REASONS)