本文整理汇总了Python中models.Course.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Course.get_by_id方法的具体用法?Python Course.get_by_id怎么用?Python Course.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Course
的用法示例。
在下文中一共展示了Course.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: myget
# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import get_by_id [as 别名]
def myget(self, course_id):
course = Course.get_by_id(int(course_id))
if course is None:
return self.error(404)
if not self.user.has_permission(course):
self.redirect(LIST_COURSES_URL)
return {'course': course}
示例2: join_course
# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import get_by_id [as 别名]
def join_course(self, course_id, code=None):
from models import Course, UserCourse # do this because users.py & courses.py import each other
if code is not None:
course = Course.all().filter('code =', code).get()
elif course_id is not None:
course = Course.get_by_id(course_id)
else:
return ''
if course is None:
return 'Invalid code'
if UserCourse.all().filter('user =', self).filter('course =', course).get():
return 'You are already in the course'
if course.teacher.key().id() == self.key().id():
return 'You teach that course'
UserCourse(user=self, course=course).put()
return course