def get(self): """Handles GET requests.""" # The following headers are added to prevent caching of this response. self.response.cache_control.no_store = True if self.username: user_actions = user_services.get_user_actions_info( self.user_id).actions user_settings = user_services.get_user_settings(self.user_id, strict=False) self.render_json({ 'roles': self.roles, 'is_moderator': (user_services.is_moderator(self.user_id)), 'is_curriculum_admin': user_services.is_curriculum_admin(self.user_id), 'is_super_admin': self.current_user_is_super_admin, 'is_topic_manager': (user_services.is_topic_manager(self.user_id)), 'can_create_collections': bool(role_services.ACTION_CREATE_COLLECTION in user_actions), 'preferred_site_language_code': (user_settings.preferred_site_language_code), 'username': user_settings.username, 'email': user_settings.email, 'user_is_logged_in': True }) else: self.render_json({'user_is_logged_in': False})
def map(user_settings_model): user_id = user_settings_model.id email_preferences = user_services.get_email_preferences(user_id) if not email_preferences.can_receive_email_updates: return query_id = ( jobs.BaseMapReduceOneOffJobManager.get_mapper_param('query_id')) query_model = user_models.UserQueryModel.get(query_id) job_class = UserQueryOneOffJob if user_id == query_model.submitter_id or ( user_services.is_moderator(user_id)): return query_criteria_satisfied = True predicates = constants.EMAIL_DASHBOARD_PREDICATE_DEFINITION for predicate in predicates: value = getattr(query_model, predicate['backend_attr']) if value != predicate['default_value']: query_criteria_satisfied = getattr( job_class, '_is_%s_query_satisfied' % predicate['backend_id'])( user_settings_model, query_model) if not query_criteria_satisfied: return yield (query_id, user_id)