docs: def add_badge(self, kind):
          '''Perform an atomic prepend for a new badge'''
          badge = self.get_badge(kind)
          if badge:
              return badge
          if kind not in getattr(self, '__badges__', {}):
              msg = 'Unknown badge type for {model}: {kind}'
              raise db.ValidationError(msg.format(model=self.__class__.__name__,
                                                  kind=kind))
          badge = Badge(kind=kind)
          if current_user.is_authenticated:
              badge.created_by = current_user.id
  
          self.update(__raw__={
              '$push': {
                  'badges': {
                      '$each': [badge.to_mongo()],
                      '$position': 0
                  }
              }
          })
          self.reload()
          post_save.send(self.__class__, document=self)
          on_badge_added.send(self, kind=kind)
          return self.get_badge(kind)