def _user_data(self): results = [] # Iterate through each user for user_dict in self._all_users: widgets = UserCode.js_for_user(user_dict["name"]) user_dict["widgets"] = widgets # Looking for Matching Soundeffects matching_effects = [ sfx for sfx in self._all_sfxs if user_dict["name"] == sfx.name[: -len(sfx.suffix)] ] if matching_effects: command_file = matching_effects[0] user_dict["command_file"] = command_file.name if user_dict["name"] in self.command_users: command_info = self.command_users[user_dict["name"]]["commands"] total_propery_value = sum([command["cost"] for command in command_info]) user_dict["wealth"] = user_dict.get("cool_points", 0) + total_propery_value # This small change to have all the command info user_dict["commands"] = [ cmd for cmd in self._all_cmds if user_dict["name"] in cmd["permitted_users"] ] user_dict["sfx_count"] = len(user_dict["commands"]) results.append(user_dict) return list(reversed(sorted(results, key=lambda user: user.get("wealth", 0))))
def test_deactivate_widgets(self): UserCode( user="******", code_link="https://gitlab.com/real_url/raw/bubbles.js", code_type="js", owners=["future"], approved=True, ).save() UserCode( user="******", code_link="https://gitlab.com/real_url/raw/fun.js", code_type="js", owners=["future"], approved=False, ).save() UserPage.bootstrap_user_page("future", ["bubbles", "fun"]) UserPage.deactivate("future", "fun") result = UserCode.js_for_user("future") assert result == { "approved": ["bubbles.js"], "unapproved": ["fun.js"], "deactivated": ["fun.js"], }