本文整理汇总了Python中models.UserData.current方法的典型用法代码示例。如果您正苦于以下问题:Python UserData.current方法的具体用法?Python UserData.current怎么用?Python UserData.current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.UserData
的用法示例。
在下文中一共展示了UserData.current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self):
coach = UserData.current()
if coach:
user_override = self.request_user_data("coach_email")
if user_override and user_override.are_students_visible_to(coach):
# Only allow looking at a student list other than your own
# if you are a dev, admin, or coworker.
coach = user_override
student_lists = StudentList.get_for_coach(coach.key())
student_lists_list = [{
'key': 'allstudents',
'name': 'כל התלמידים'.decode("utf8"),
}];
for student_list in student_lists:
student_lists_list.append({
'key': str(student_list.key()),
'name': student_list.name,
})
list_id, _ = get_last_student_list(self, student_lists, coach==UserData.current())
current_list = None
for student_list in student_lists_list:
if student_list['key'] == list_id:
current_list = student_list
selected_graph_type = self.request_string("selected_graph_type") or ClassProgressReportGraph.GRAPH_TYPE
if selected_graph_type == 'progressreport' or selected_graph_type == 'goals': # TomY This is temporary until all the graphs are API calls
initial_graph_url = "/api/v1/user/students/%s?coach_email=%s&%s" % (selected_graph_type, urllib.quote(coach.email), urllib.unquote(self.request_string("graph_query_params", default="")))
else:
initial_graph_url = "/profile/graph/%s?coach_email=%s&%s" % (selected_graph_type, urllib.quote(coach.email), urllib.unquote(self.request_string("graph_query_params", default="")))
initial_graph_url += 'list_id=%s' % list_id
exercises = models.Exercise.get_all_use_cache()
exercises.sort(key=lambda ex: ex.display_name)
template_values = {
'user_data_coach': coach,
'coach_email': coach.email,
'list_id': list_id,
'student_list': current_list,
'student_lists': student_lists_list,
'student_lists_json': json.dumps(student_lists_list),
'coach_nickname': coach.nickname,
'selected_graph_type': selected_graph_type,
'initial_graph_url': initial_graph_url,
'exercises': exercises,
'is_profile_empty': not coach.has_students(),
'selected_nav_link': 'coach',
"view": self.request_string("view", default=""),
'stats_charts_class': 'coach-view',
}
self.render_jinja2_template('viewclassprofile.html', template_values)
else:
self.redirect(util.create_login_url(self.request.uri))
示例2: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self):
coach = UserData.current()
if coach:
user_override = self.request_user_data("coach_email")
if user_override and user_override.are_students_visible_to(coach):
# Only allow looking at a student list other than your own
# if you are a dev, admin, or coworker.
coach = user_override
student_lists = StudentList.get_for_coach(coach.key())
student_lists_list = [{"key": "allstudents", "name": "All students"}]
for student_list in student_lists:
student_lists_list.append({"key": str(student_list.key()), "name": student_list.name})
list_id, _ = get_last_student_list(self, student_lists, coach == UserData.current())
current_list = None
for student_list in student_lists_list:
if student_list["key"] == list_id:
current_list = student_list
selected_graph_type = self.request_string("selected_graph_type") or ClassProgressReportGraph.GRAPH_TYPE
initial_graph_url = "/profile/graph/%s?coach_email=%s&%s" % (
selected_graph_type,
urllib.quote(coach.email),
urllib.unquote(self.request_string("graph_query_params", default="")),
)
initial_graph_url += "list_id=%s" % list_id
template_values = {
"user_data_coach": coach,
"coach_email": coach.email,
"list_id": list_id,
"student_list": current_list,
"student_lists": student_lists_list,
"student_lists_json": simplejson.dumps(student_lists_list),
"coach_nickname": coach.nickname,
"selected_graph_type": selected_graph_type,
"initial_graph_url": initial_graph_url,
"exercises": models.Exercise.get_all_use_cache(),
"is_profile_empty": not coach.has_students(),
"selected_nav_link": "coach",
"view": self.request_string("view", default=""),
}
self.render_jinja2_template("viewclassprofile.html", template_values)
else:
self.redirect(util.create_login_url(self.request.uri))
示例3: can_control_gandalf
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def can_control_gandalf():
"""CUSTOMIZE can_control_gandalf however you want to specify
whether or not the currently-logged-in user has access
to Gandalf dashboard."
"""
user_data = UserData.current(bust_cache=True)
return users.is_current_user_admin() or (user_data and user_data.developer)
示例4: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self):
user_data = UserData.current()
if not user_data:
self.redirect(util.create_login_url(self.request.uri))
return
accept_coach = self.request_bool("accept", default = False)
user_data_coach = self.request_user_data("coach_email")
user_data_student = self.request_user_data('student_email')
if bool(user_data_coach) == bool(user_data_student):
raise Exception('must provide coach_email xor student_email')
if user_data_coach:
user_data_student = user_data
elif user_data_student:
user_data_coach = user_data
if user_data_coach and not user_data_student.is_coached_by(user_data_coach):
coach_request = CoachRequest.get_for(user_data_coach, user_data_student)
if coach_request:
coach_request.delete()
if user_data.key_email == user_data_student.key_email and accept_coach:
user_data_student.coaches.append(user_data_coach.key_email)
user_data_student.put()
if not self.is_ajax_request():
self.redirect("/coaches")
示例5: render_login_outer
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def render_login_outer(self):
"""Render the login page.
Note that part of the contents of this page is hosted on an iframe
and rendered by this same RequestHandler (render_login_form)
"""
cont = self.request_continue_url()
direct = self.request_bool('direct', default=False)
user_data = UserData.current()
if user_data and not user_data.is_phantom:
# Don't let users see the login page if they're already logged in.
# This avoids dangerous edge cases in which users have conflicting
# Google/FB cookies, and google.appengine.api.users.get_current_user
# returns a different user than the actual person logged in.
self.redirect(cont)
return
template_values = {
'continue': cont,
'direct': direct,
'google_url': users.create_login_url(cont),
}
self.render_jinja2_template('login.html', template_values)
示例6: post
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def post(self):
template_values = {}
user_data = UserData.current()
status_file = StringIO.StringIO(self.request_string("status_file"))
reader = csv.reader(status_file)
student_list = []
for line in reader:
student_email = line[0]
student_status = line[1]
student_comment = line[2]
student = SummerStudent.all().filter("email =", student_email).get()
if student is None:
logging.error("Student %s not found" % student_email)
continue
student.application_status = student_status
student.comment = student_comment
if student_status == "Accepted":
student.accepted = True
student_list.append(student)
db.put(student_list)
self.response.out.write("OK")
self.response.set_status(200)
示例7: post
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def post(self):
user_data = UserData.current()
if user_data:
expanded = self.request_bool("expanded")
user_data.expanded_all_exercises = expanded
user_data.put()
示例8: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self):
student = UserData.current() or UserData.pre_phantom()
user_override = self.request_student_user_data(legacy=True)
if user_override and user_override.key_email != student.key_email:
if not user_override.is_visible_to(student):
# If current user isn't an admin or student's coach, they can't
# look at anything other than their own profile.
self.redirect("/profile")
return
else:
# Allow access to this student's profile
student = user_override
user_badges = util_badges.get_user_badges(student)
selected_graph_type = (self.request_string("selected_graph_type") or
ActivityGraph.GRAPH_TYPE)
# TODO: deal with this one-off hackery. Some graphs use the API
# to fetch data, instead of the /profile/graph methods.
if selected_graph_type == "exerciseprogress":
initial_graph_url = ("/api/v1/user/exercises?email=%s" %
urllib.quote(student.email))
elif selected_graph_type == "goals":
initial_graph_url = ("/api/v1/user/goals?email=%s" %
urllib.quote(student.email))
else:
initial_graph_url = "/profile/graph/%s?student_email=%s&%s" % (
selected_graph_type,
urllib.quote(student.email),
urllib.unquote(self.request_string("graph_query_params",
default="")))
tz_offset = self.request_int("tz_offset", default=0)
template_values = {
'student_email': student.email,
'student_nickname': student.nickname,
'selected_graph_type': selected_graph_type,
'initial_graph_url': initial_graph_url,
'tz_offset': tz_offset,
'student_points': student.points,
'count_videos': models.Setting.count_videos(),
'count_videos_completed': student.get_videos_completed(),
'count_exercises': models.Exercise.get_count(),
'count_exercises_proficient': len(student.all_proficient_exercises),
'badge_collections': user_badges['badge_collections'],
'user_badges_bronze': user_badges['bronze_badges'],
'user_badges_silver': user_badges['silver_badges'],
'user_badges_gold': user_badges['gold_badges'],
'user_badges_platinum': user_badges['platinum_badges'],
'user_badges_diamond': user_badges['diamond_badges'],
'user_badges_master': user_badges['user_badges_master'],
'user_badges': [user_badges['bronze_badges'], user_badges['silver_badges'], user_badges['gold_badges'], user_badges['platinum_badges'], user_badges['diamond_badges'],user_badges['user_badges_master']],
'user_data_student': student,
"show_badge_frequencies": self.request_bool("show_badge_frequencies", default=False),
"view": self.request_string("view", default=""),
}
self.render_jinja2_template('viewprofile.html', template_values)
示例9: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self):
user_data = UserData.current()
context = {
'user_data': user_data,
# Get pregenerated library content from our in-memory/memcache
# two-layer cache
'library_content': library_content_html(),
}
self.render_jinja2_template("goals/creategoal.html", context)
示例10: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self, url_id=""):
url = Url.get_by_id(int(url_id))
if url is None:
raise MissingUrlException("Missing url '%s'" % url_id)
user_data = UserData.current()
if user_data:
goals_updated = GoalList.update_goals(user_data, lambda goal: goal.just_visited_url(user_data, url))
self.redirect(url.url.encode("utf8"))
示例11: do_request
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def do_request(self, student, coach, redirect_to):
if not UserData.current():
self.redirect(util.create_login_url(self.request.uri))
return
if student and coach:
self.remove_student_from_coach(student, coach)
if not self.is_ajax_request():
self.redirect(redirect_to)
示例12: post
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def post(self):
coach_data = UserData.current()
if not coach_data:
return
student_list = util_profile.get_list(coach_data, self)
student_list.delete()
if not self.is_ajax_request():
self.redirect_to('/students')
示例13: get_profile_target_user_data
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get_profile_target_user_data(self):
coach = UserData.current()
if coach:
user_override = self.request_user_data("coach_email")
if user_override and user_override.are_students_visible_to(coach):
# Only allow looking at a student list other than your own
# if you are a dev, admin, or coworker.
coach = user_override
return coach
示例14: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self):
template_values = {}
user_data = UserData.current()
if user_data is not None:
return self.authenticated_response()
else:
template_values = {"authenticated": False}
self.add_global_template_values(template_values)
self.render_jinja2_template("summer/summer_process.html", template_values)
示例15: get
# 需要导入模块: from models import UserData [as 别名]
# 或者: from models.UserData import current [as 别名]
def get(self):
user_data = UserData.current()
if user_data == None:
return
user_video_css = models.UserVideoCss.get_for_user_data(user_data)
self.response.headers['Content-Type'] = 'text/css'
if user_video_css.version == user_data.uservideocss_version:
# Don't cache if there's a version mismatch and update isn't finished
self.response.headers['Cache-Control'] = 'public,max-age=1000000'
self.response.out.write(user_video_css.video_css)