def __init__(self, lesson_number=None, error_code=0): self.lesson_list = lessonlib.get_lesson_list() if lesson_number: lesson_query = notedb.Lesson_Note.query(ancestor=notedb.lesson_dir(lesson_number)) concept_query = notedb.Concept.query(ancestor=notedb.lesson_db(lesson_number)).order(+notedb.Concept.id_number) lesson = lesson_query.fetch() concepts = concept_query.fetch() self.lesson_name = lesson[0].name self.lesson_number = lesson_number self.concept_list = concepts user = users.get_current_user() if user: if lesson_number: post_query = postclasses.Post.query(ancestor = postclasses.lesson_key(lesson_number))\ .filter(postclasses.Post.author.identity == user.user_id()).order(-postclasses.Post.date) self.posts = post_query.fetch() self.user_name = user.nickname() self.user_url = users.create_logout_url('/') self.user_linktext = "Logout" self.is_user = True else: self.user_name = "Not Logged In" self.user_url = users.create_login_url('/') self.user_linktext = "Login" self.is_user = False self.posts = None if error_code == 1: self.error_message = "Sorry but that is not a valid lesson number. Please select from the menu." elif error_code == 2: self.error_message = "Note must have content, please resubmit with something worth noting!"
def build_lesson_table(lesson_number): lesson = noteclasses.Lesson(lesson_number) lesson_table = notedb.Lesson_Note(parent=notedb.lesson_dir(lesson_number)) lesson_table.name = lesson.name concept_dbid = 1 for concept in lesson.concepts: concept_table = notedb.Concept(parent=notedb.lesson_db(lesson_number)) concept_table.concept_id = concept['concept_id'] concept_table.title = concept['title'] concept_table.description = concept['description'] concept_table.id_number = concept_dbid concept_table.put() concept_dbid += 1 lesson_table.concepts = notedb.lesson_db(lesson_number) lesson_table.put()
def build_lesson_table(lesson_number): lesson = noteclasses.Lesson(lesson_number) lesson_table = notedb.Lesson_Note(parent=notedb.lesson_dir(lesson_number)) lesson_table.name = lesson.name concept_dbid = 1 for concept in lesson.concepts: concept_table = notedb.Concept(parent=notedb.lesson_db(lesson_number)) concept_table.concept_id = concept["concept_id"] concept_table.title = concept["title"] concept_table.description = concept["description"] concept_table.id_number = concept_dbid concept_table.put() concept_dbid += 1 lesson_table.concepts = notedb.lesson_db(lesson_number) lesson_table.put()
def __init__(self, lesson_number=None, error_code=0): self.lesson_list = lessonlib.get_lesson_list() if lesson_number: lesson_query = notedb.Lesson_Note.query( ancestor=notedb.lesson_dir(lesson_number)) concept_query = notedb.Concept.query(ancestor=notedb.lesson_db( lesson_number)).order(+notedb.Concept.id_number) lesson = lesson_query.fetch() concepts = concept_query.fetch() self.lesson_name = lesson[0].name self.lesson_number = lesson_number self.concept_list = concepts user = users.get_current_user() if user: if lesson_number: post_query = postclasses.Post.query(ancestor = postclasses.lesson_key(lesson_number))\ .filter(postclasses.Post.author.identity == user.user_id()).order(-postclasses.Post.date) self.posts = post_query.fetch() self.user_name = user.nickname() self.user_url = users.create_logout_url('/') self.user_linktext = "Logout" self.is_user = True else: self.user_name = "Not Logged In" self.user_url = users.create_login_url('/') self.user_linktext = "Login" self.is_user = False self.posts = None if error_code == 1: self.error_message = "Sorry but that is not a valid lesson number. Please select from the menu." elif error_code == 2: self.error_message = "Note must have content, please resubmit with something worth noting!"