def get(self): """Handles GET requests.""" # TODO(sll): Implement paging. explorations_dict = ( exp_services.get_recently_edited_public_explorations_summary_dict( )) public_explorations_list = [{ 'id': exp_id, 'title': exp_data['title'], 'category': exp_data['category'], 'last_updated': exp_data['last_updated'], 'community_owned': exp_data['rights']['community_owned'], 'to_playtest': False, } for (exp_id, exp_data) in explorations_dict.iteritems()] # Add private explorations that the user has been specifically invited # to playtest. private_explorations_list = [] if self.user_id: playtest_dict = ( exp_services.get_explicit_viewer_explorations_summary_dict( self.user_id, include_timestamps=True)) private_explorations_list = [{ 'id': exp_id, 'title': exp_data['title'], 'category': exp_data['category'], 'last_updated': exp_data['last_updated'], 'to_playtest': True, } for (exp_id, exp_data) in playtest_dict.iteritems()] self.values.update({ 'public_explorations_list': sorted(public_explorations_list, key=lambda exp: exp['last_updated'], reverse=True), 'private_explorations_list': sorted(private_explorations_list, key=lambda exp: exp['last_updated'], reverse=True) }) self.render_json(self.values)
def get(self): """Handles GET requests.""" viewable_exps = ( exp_services.get_explicit_viewer_explorations_summary_dict( self.user_id)) editable_exps = ( exp_services.get_explicit_editor_explorations_summary_dict( self.user_id)) owned_exps = exp_services.get_owned_explorations_summary_dict( self.user_id) self.values.update({ 'viewable': viewable_exps, 'editable': editable_exps, 'owned': owned_exps }) self.render_json(self.values)
def get(self): """Handles GET requests.""" viewable_exps = ( exp_services.get_explicit_viewer_explorations_summary_dict( self.user_id)) editable_exps = ( exp_services.get_explicit_editor_explorations_summary_dict( self.user_id)) owned_exps = exp_services.get_owned_explorations_summary_dict( self.user_id) user_stats = stats_services.get_user_stats(self.user_id) self.values.update({ 'viewable': viewable_exps, 'editable': editable_exps, 'owned': owned_exps, 'feedback': user_stats['feedback'] }) self.render_json(self.values)
def get(self): """Handles GET requests.""" # TODO(sll): Implement paging. explorations_dict = ( exp_services.get_recently_edited_public_explorations_summary_dict() ) public_explorations_list = [{ 'id': exp_id, 'title': exp_data['title'], 'category': exp_data['category'], 'last_updated': exp_data['last_updated'], 'community_owned': exp_data['rights']['community_owned'], 'to_playtest': False, } for (exp_id, exp_data) in explorations_dict.iteritems()] # Add private explorations that the user has been specifically invited # to playtest. private_explorations_list = [] if self.user_id: playtest_dict = ( exp_services.get_explicit_viewer_explorations_summary_dict( self.user_id, include_timestamps=True)) private_explorations_list = [{ 'id': exp_id, 'title': exp_data['title'], 'category': exp_data['category'], 'last_updated': exp_data['last_updated'], 'to_playtest': True, } for (exp_id, exp_data) in playtest_dict.iteritems()] self.values.update({ 'public_explorations_list': sorted( public_explorations_list, key=lambda exp: exp['last_updated'], reverse=True), 'private_explorations_list': sorted( private_explorations_list, key=lambda exp: exp['last_updated'], reverse=True) }) self.render_json(self.values)
def get(self): """Handles GET requests.""" # TODO(sll): Implement paging. explorations_dict = ( exp_services.get_non_private_explorations_summary_dict()) categories = collections.defaultdict(list) for (eid, exploration_data) in explorations_dict.iteritems(): categories[exploration_data['category']].append({ 'id': eid, 'is_public': ( exploration_data['rights']['status'] == rights_manager.EXPLORATION_STATUS_PUBLIC), 'is_publicized': ( exploration_data['rights']['status'] == rights_manager.EXPLORATION_STATUS_PUBLICIZED), 'title': exploration_data['title'], 'to_playtest': False, }) if self.user_id: playtest_dict = ( exp_services.get_explicit_viewer_explorations_summary_dict( self.user_id)) for (eid, exploration_data) in playtest_dict.iteritems(): categories[exploration_data['category']].append({ 'id': eid, 'is_public': ( exploration_data['rights']['status'] == rights_manager.EXPLORATION_STATUS_PUBLIC), 'is_publicized': ( exploration_data['rights']['status'] == rights_manager.EXPLORATION_STATUS_PUBLICIZED), 'title': exploration_data['title'], 'to_playtest': True, }) self.values.update({ 'categories': categories, }) self.render_json(self.values)
def test_get_explicit_viewer_explorations_summary_dict(self): self.save_new_default_exploration(self.EXP_ID) rights_manager.assign_role( self.OWNER_ID, self.EXP_ID, self.VIEWER_ID, rights_manager.ROLE_VIEWER) self.assertEqual( exp_services.get_explicit_viewer_explorations_summary_dict( self.VIEWER_ID), { self.EXP_ID: { 'title': 'A title', 'category': 'A category', 'rights': { 'owner_names': [self.OWNER_NAME], 'editor_names': [], 'viewer_names': [self.VIEWER_NAME], 'community_owned': False, 'cloned_from': None, 'status': rights_manager.EXPLORATION_STATUS_PRIVATE } } } ) self.assertEqual( exp_services.get_explicit_viewer_explorations_summary_dict( self.EDITOR_ID), {}) self.assertEqual( exp_services.get_explicit_viewer_explorations_summary_dict( self.OWNER_ID), {}) # Set the exploration's status to published. This removes all viewer # ids. rights_manager.publish_exploration(self.OWNER_ID, self.EXP_ID) self.assertEqual( exp_services.get_explicit_viewer_explorations_summary_dict( self.VIEWER_ID), {}) self.assertEqual( exp_services.get_explicit_viewer_explorations_summary_dict( self.EDITOR_ID), {}) self.assertEqual( exp_services.get_explicit_viewer_explorations_summary_dict( self.OWNER_ID), {})