docs: def set_preferences(self, user=None, **kwargs):
          """Set preferences from keyword arguments."""
          if user is None:
              user = current_user
  
          d = {pref.key: pref for pref in user.preferences}
          for k, v in kwargs.items():
              if k in d:
                  d[k].value = v
              else:
                  d[k] = UserPreference(user=user, key=k, value=v)
                  db.session.add(d[k])