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:
@@ -92,13 +92,13 @@ def user_update_preferences(user_id, preferences):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# If the preference exists and has a new value.
|
# 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
|
pref.cast_value = value
|
||||||
api_base.entity_update(models.UserPreference, pref.id, dict(pref))
|
api_base.entity_update(models.UserPreference, pref.id, dict(pref))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# If the preference does not exist and a new value exists.
|
# 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, {
|
api_base.entity_create(models.UserPreference, {
|
||||||
'user_id': user_id,
|
'user_id': user_id,
|
||||||
'key': key,
|
'key': key,
|
||||||
|
|||||||
Reference in New Issue
Block a user