def get_subject_and_chapter_name(self): obj = {} from models.subject import Subject from models.chapter import Chapter subjects = Subject.all() for s in subjects: clist = Chapter.find_all(subject_id=s.id) temp = [] for c in clist: temp.append(c.__dict__) obj[s.id] = temp return obj
def new(): from models.subject import Subject subject_list = Subject.all() cookie = token_cookie() template = render_template( "chapter/edit_chapter.html", chapter=None, subjects=subject_list, token=cookie['token'], ) r = make_response(template) r.set_cookie(cookie['token'], cookie['id'], max_age=300) return r
def new(): from models.subject import Subject subject_list = Subject.all() obj = Article.get_subject_and_chapter_name() cookie = token_cookie() template = render_template( "article/edit_article.html", article=None, subjects=subject_list, obj=json_util.dumps(obj), token=cookie['token'], ) r = make_response(template) r.set_cookie(cookie['token'], cookie['id'], max_age=300) return r
def new(): from models.subject import Subject from models.problem import Problem subject_list = Subject.all() problem_type = Problem.get_problem_type_list() cookie = token_cookie() template = render_template( "problem/new_problem.html", subjects=subject_list, types=problem_type, token=cookie['token'], ) r = make_response(template) r.set_cookie(cookie['token'], cookie['id'], max_age=300) return r
def get(self): # Load all Guardians path = os.path.join(os.path.dirname(__file__), 'data/voogdouder.txt') my_file = open(path) fileReader = csv.reader(my_file, delimiter=";") for row in fileReader: new_guardian = Guardian(key_name=row[0].strip()) new_guardian.title=row[1].strip() new_guardian.initials=row[2].strip() new_guardian.preposition=row[3].strip() new_guardian.lastname=row[4].strip() new_guardian.streetname=row[6].strip() new_guardian.housenumber=row[7].strip() new_guardian.city=row[8].strip() new_guardian.postalcode=row[9].strip() new_guardian.email=row[12].strip() new_guardian.save() print "Guardian " + new_guardian.key().id_or_name() + " stored" # Load all Students path = os.path.join(os.path.dirname(__file__), 'data/leerlingen.txt') my_file = open(path) fileReader = csv.reader(my_file, delimiter=";") for row in fileReader: new_student = Student(key_name=row[0].strip()) new_student.firstname=row[1].strip() new_student.preposition=row[2].strip() new_student.lastname=row[3].strip() new_student.gender=row[4].strip() new_student.class_id=row[5].strip() new_student.guardian=Guardian.all().filter("__key__ >=", Key.from_path('Guardian', row[6].strip())).get() new_student.save() print "Student " + new_student.key().id_or_name() + " stored" # Load all Teachers path = os.path.join(os.path.dirname(__file__), 'data/docenten.txt') my_file = open(path) fileReader = csv.reader(my_file, delimiter=";") for row in fileReader: new_teacher = Teacher(key_name=row[0].strip()) new_teacher.name=row[1].strip() new_teacher.boxnumber=int(row[2].strip()) new_teacher.email=row[3].strip() new_teacher.save() print "Teacher " + new_teacher.key().id_or_name() + " stored" # Load all Subjects path = os.path.join(os.path.dirname(__file__), 'data/vakken.txt') my_file = open(path) fileReader = csv.reader(my_file, delimiter=";") for row in fileReader: new_subject = Subject(key_name=row[0].strip()) new_subject.name=row[1].strip() new_subject.save() print "Subject " + new_subject.key().id_or_name() + " stored" # Load all Students path = os.path.join(os.path.dirname(__file__), 'data/docent_vak.txt') my_file = open(path) fileReader = csv.reader(my_file, delimiter=";") for row in fileReader: new_combination = Combination() new_combination.class_id=row[0].strip() new_combination.subject=Subject.all().filter("__key__ >=", Key.from_path('Subject', row[1].strip())).get() new_combination.teacher=Teacher.all().filter("__key__ >=", Key.from_path('Teacher', row[2].strip())).get() new_combination.save() print "Combination " + str(new_combination.key().id_or_name()) + " stored" self.redirect("/fix")
def get_subject_list(): all_subject = Subject.all() subject_list = [s.__dict__ for s in all_subject] return Response(json_util.dumps(subject_list, ensure_ascii=False), content_type='application/json')