diff --git a/emission/core/wrapper/user.py b/emission/core/wrapper/user.py index 45c491958..1120bbac8 100644 --- a/emission/core/wrapper/user.py +++ b/emission/core/wrapper/user.py @@ -234,7 +234,7 @@ def getModes(self): modes = user['modes'] filteredModes = {key: value for key, value in modes.items() if value.get('isActive', False)} sortedModes = dict(sorted(filteredModes.items(), key=lambda x: (x[1]["frequency"]), reverse=True)) - return sortedModes + return list(sortedModes) def updateModes(self, updated_mode): from datetime import datetime @@ -243,7 +243,7 @@ def updateModes(self, updated_mode): old_mode = updated_mode['old_mode'] new_mode = updated_mode['new_mode'] is_new_mode_must_added = updated_mode['is_new_mode_must_added'] - + if new_mode in modes: updated_frequency = modes[new_mode]['frequency'] + 1 modes[new_mode]['frequency'] = updated_frequency diff --git a/emission/net/api/cfc_webapp.py b/emission/net/api/cfc_webapp.py index 944684736..575034ea9 100644 --- a/emission/net/api/cfc_webapp.py +++ b/emission/net/api/cfc_webapp.py @@ -311,17 +311,17 @@ def getUserModes(): logging.debug("Called getUserModes") user_uuid = getUUID(request) user = User.fromUUID(user_uuid) - return user.getModes() + return { 'modes' : user.getModes() } @post('/mode/update') def updateUserMode(): - logging.debug("Called createUserMode") + logging.debug("Called updateUserMode") updated_mode = request.json['updated_mode'] user_uuid = getUUID(request) user = User.fromUUID(user_uuid) to_return = user.updateModes(updated_mode) logging.debug("Successfully updated mode for user %s" % user_uuid) - return {"modes": to_return} + return { 'modes' : to_return } @post('/result/metrics/') def summarize_metrics(time_type):