if commit: self.save() content_type = ContentType.objects.get_for_model(self) Follow.objects.filter(content_type=content_type, object_id=self.id).delete() class TaggedQuestion(TaggedItemBase): content_object = models.ForeignKey("Question") sites = models.ManyToManyField(Site) # objects = models.Manager() # objects = CurrentSiteManager() def can_vote(entity, user): ''' returns whether a secific user can upvote/downvote a question in the entity ''' return user.is_authenticated() and user.profile.locality == entity Entity.add_to_class('can_vote', can_vote) class Question(BaseModel): # TODO: rename to just `slug` unislug = models.CharField( _('unicode slug'), max_length=MAX_LENGTH_Q_SUBJECT, null=True, blank=True, editable=False ) author = models.ForeignKey(User, related_name="questions", verbose_name=_("author")) subject = models.CharField(_("question"), max_length=MAX_LENGTH_Q_SUBJECT) content = models.TextField(_("details"), max_length=MAX_LENGTH_Q_CONTENT, help_text=_("Please enter your content in no more than %s letters") % MAX_LENGTH_Q_CONTENT,
class TaggedQuestion(TaggedItemBase): content_object = models.ForeignKey("Question") sites = models.ManyToManyField(Site) # objects = models.Manager() # objects = CurrentSiteManager() def can_vote(entity, user): ''' returns whether a secific user can upvote/downvote a question in the entity ''' return user.is_authenticated() and user.profile.locality == entity Entity.add_to_class('can_vote', can_vote) class Question(BaseModel): # TODO: rename to just `slug` unislug = models.CharField(_('unicode slug'), max_length=MAX_LENGTH_Q_SUBJECT, null=True, blank=True, editable=False) author = models.ForeignKey(User, related_name="questions", verbose_name=_("author")) subject = models.CharField(_("question"), max_length=MAX_LENGTH_Q_SUBJECT) content = models.TextField(