'Filter objects so only the ones with a user\'s writing access
are included'

def can_write(self, user):

    if user.has_perm(u'wiki.moderator'):
        return self
    if user.is_anonymous():
        q = self.filter(other_write=True)
    else:
        q = self.filter(((Q(other_write=True) | Q(owner=user)) | (Q(group__user=user) & Q(group_write=True))))
    return q
