def current_user_info(self): if self.user_info is None: """Get the current user by lookup if we can""" if self.username: self.user_info = UserInfo.get_by_username(self.username) """Gets the current user. This involves a query. Its more efficient to perform lookups with the username and verify that the user_info is current.""" if self.google_user is not None: users_query = UserInfo.query( UserInfo.google_user==self.google_user) self.user_info = users_query.get() if self.oauth_user_id is not None: users_query = UserInfo.query( UserInfo.oauth_user_id==self.oauth_user_id) self.user_info = users_query.get() if self.user_info and self.username is None: self.username = self.user_info.username if self.user_info is not None and self.is_user_info_current(self.user_info): return self.user_info else: return None
def flush(): ndb.delete_multi(School.query().fetch(keys_only=True)) ndb.delete_multi(QuestionInstance.query().fetch(keys_only=True)) ndb.delete_multi(State_Questions.query().fetch(keys_only=True)) ndb.delete_multi(Topic_States.query().fetch(keys_only=True)) ndb.delete_multi(Question.query().fetch(keys_only=True)) ndb.delete_multi(State.query().fetch(keys_only=True)) ndb.delete_multi(Address.query().fetch(keys_only=True)) ndb.delete_multi(Teacher.query().fetch(keys_only=True)) ndb.delete_multi(Class.query().fetch(keys_only=True)) ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True)) ndb.delete_multi(Student.query().fetch(keys_only=True)) ndb.delete_multi(UserInfo.query().fetch(keys_only=True)) ndb.delete _multi(Student_Assessments.query().fetch(keys_only=True)) ndb.delete_multi(Assessment.query().fetch(keys_only=True)) ndb.delete_multi(Subject.query().fetch(keys_only=True)) ndb.delete_multi(Topic_Questions.query().fetch(keys_only=True)) ndb.delete_multi(State_Questions.query().fetch(keys_only=True)) ndb.delete_multi(Topic_States.query().fetch(keys_only=True)) ndb.delete_multi(Subject_Topics.query().fetch(keys_only=True)) ndb.delete_multi(Student_Assessments.query().fetch(keys_only=True)) ndb.delete_multi(Topic.query().fetch(keys_only=True)) ndb.delete_multi(User.query().fetch(keys_only=True)) ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True)) ndb.delete_multi(State_Types.query().fetch(keys_only=True))
def flush(): ndb.delete_multi(School.query().fetch(keys_only=True)) ndb.delete_multi(QuestionInstance.query().fetch(keys_only=True)) ndb.delete_multi(State_Questions.query().fetch(keys_only=True)) ndb.delete_multi(Topic_States.query().fetch(keys_only=True)) ndb.delete_multi(Question.query().fetch(keys_only=True)) ndb.delete_multi(State.query().fetch(keys_only=True)) ndb.delete_multi(Address.query().fetch(keys_only=True)) ndb.delete_multi(Teacher.query().fetch(keys_only=True)) ndb.delete_multi(Class.query().fetch(keys_only=True)) ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True)) ndb.delete_multi(Student.query().fetch(keys_only=True)) ndb.delete_multi(UserInfo.query().fetch(keys_only=True)) ndb.delete_multi(Student_Assessments.query().fetch(keys_only=True)) ndb.delete_multi(Assessment.query().fetch(keys_only=True)) ndb.delete_multi(Subject.query().fetch(keys_only=True)) ndb.delete_multi(Topic_Questions.query().fetch(keys_only=True)) ndb.delete_multi(State_Questions.query().fetch(keys_only=True)) ndb.delete_multi(Topic_States.query().fetch(keys_only=True)) ndb.delete_multi(Subject_Topics.query().fetch(keys_only=True)) ndb.delete_multi(Student_Assessments.query().fetch(keys_only=True)) ndb.delete_multi(Topic.query().fetch(keys_only=True)) ndb.delete_multi(User.query().fetch(keys_only=True)) ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True)) ndb.delete_multi(State_Types.query().fetch(keys_only=True))
def post(self): user = users.get_current_user() upload_files = self.get_uploads('file') blob_info = upload_files[0] ui = UserInfo.query(UserInfo.user == user).get() ui.delicious = blob_info.key() ui.put() self.redirect('/') deferred.defer(delicious, ui.delicious, user, _queue="delicious")
def get(self): ui = UserInfo.query(UserInfo.user == users.get_current_user()).get() if ui.twitt == False: ui.twitt = True html = '<i class="icon-thumbs-up"></i> <strong>Enabled </strong>' else: ui.twitt = False html = '<i class="icon-thumbs-down"></i> <strong>Disabled</strong>' ui.put() self.response.write(html)
def get(self): for ui in UserInfo.query(): if ui.daily: deferred.defer(utils.daily_digest, ui.user, _target="worker", _queue="admin")