Allow boolean preferences

This patch fixes the checks in update_user_preferences so that boolean
preferences are correctly updated and created. Previously, the
preference having value == False would lead to nothing happening.

Change-Id: Ibc8e1113759b16d45d7ba1f05a9c8d6c782314cd
This commit is contained in:
Adam Coldrick 2015-11-04 15:48:29 +00:00
parent f7c2d2320c
commit 1ecdcb2074

View File

@ -92,13 +92,13 @@ def user_update_preferences(user_id, preferences):
continue
# If the preference exists and has a new value.
if pref and value and pref.cast_value != value:
if pref and value is not None and pref.cast_value != value:
pref.cast_value = value
api_base.entity_update(models.UserPreference, pref.id, dict(pref))
continue
# If the preference does not exist and a new value exists.
if not pref and value:
if not pref and value is not None:
api_base.entity_create(models.UserPreference, {
'user_id': user_id,
'key': key,