Exemplo n.º 1
0
    def post(self):
        core = self.request.get('core')
        material = self.request.get('material')
        length = self.request.get('length')

        first_name = self.request.get('owner_first_name')
        last_name = self.request.get('owner_last_name')

        student_results = Student.query().filter(
            Student.first_name == first_name
            and Student.last_name == last_name).fetch()

        if len(student_results) > 0:
            student = student_results[0]
            new_wand = Wand(core=core,
                            material=material,
                            length=float(length),
                            owner=student.key).put()
        else:
            new_wand = Wand(core=core,
                            material=material,
                            length=float(length),
                            owner=student.key).put()

        wands = Wand.query().order(+Wand.core).fetch()
        wand_template = jinja_env.get_template('templates/wandlist.html')
        self.response.write(wand_template.render({'wands': wands}))
Exemplo n.º 2
0
    def get(self):
        template = jinja_env.get_template("templates/studentlist.html")
        values = {}
        house_input = self.request.get("house")

        if house_input != "":
            # There should only be 1 house with that name, so the [0] at the end
            # gets the 1 element that is in the list, otherwise we have a list of house_infos
            values["house_info"] = House.query(House.name==house_input).fetch()[0]
            values["student_list"] = Student.query(Student.house_name==house_input).fetch()
            print(values["house_info"])
        else:
            # No house, so get all of the students
            values["student_list"] = Student.query().fetch()

        print(values["student_list"])
        self.response.write(template.render(values))
Exemplo n.º 3
0
    def get(self):
        template = jinja_env.get_template("templates/wandlist.html")
        values = {}
        student_input = self.request.get("student")

        if student_input != "":
            values["student"] = student_input
            student_db = Student.query(Student.first_name == student_input).fetch()[0]
            values["wand_list"] = Wand.query(Wand.owner_num == student_db.student_num)
        else:
            values["wand_list"] = Wand.query().fetch()
        self.response.write(template.render(values))
Exemplo n.º 4
0
def seed_data():
    ron_key = Student(student_id=423491377, first_name ="Ron", last_name = "Weasley").put()
    harry_key = Student (student_id=423491782, first_name ="Harry", last_name = "Potter").put()
    hermione_key = Student(student_id=423491249, first_name="Hermione", last_name="Grainger").put()
    malfoy_key = Student(student_id=42391043, first_name="Draco", last_name="Malfoy").put()
    crabbe_key = Student(student_id=42391122, first_name="Vincent", last_name="Crabbe").put()
    goyle_key = Student(student_id=42391063, first_name="Gregory", last_name="Goyle").put()


    ron_wand=Wand(length = 14.0, material = "willow", core="unicorn", owner=ron_key)
    harry_wand=Wand(length = 11.0, material = "holly", core="phoenix feather", owner=harry_key)
    hermione_wand = Wand(length=10.75, material="vinewood", core="dragon heartstring", owner=hermione_key)

    ron_wand.put()
    harry_wand.put()
    hermione_wand.put()

    gryff = House(name="Gryffindor", mascot="Lion", students=[ron_key, harry_key, hermione_key])
    snakes = House(name="Slytherin", mascot="Snake", students=[malfoy_key, crabbe_key, goyle_key])
    hufflepuff = House(name="Hufflepuff", mascot="Badger", students=[])
    ravenclaw = House(name="Ravenclaw",  mascot="Eagle", students=[])

    gryff.put()
    snakes.put()
    hufflepuff.put()
    ravenclaw.put()

    potions = Course(name="Potions", location="dungeon")
    dada = Course(name="Defense Against the Dark Arts", location="3C")
    transfiguration = Course(name="Transfiguration", location="Class 34")
    potions_key = potions.put()
    dada_key = dada.put()
    transfiguration_key = transfiguration.put()

    #dada
    Enrollment(student=ron_key, course=dada_key).put()
    Enrollment(student=harry_key, course=dada_key).put()
    Enrollment(student=hermione_key, course=dada_key).put()

    #potions
    Enrollment(student=hermione_key, course=potions_key).put()
    Enrollment(student=ron_key, course=potions_key).put()
    Enrollment(student=malfoy_key, course=potions_key).put()
    Enrollment(student=crabbe_key, course=potions_key).put()
    Enrollment(student=goyle_key, course=potions_key).put()

    #tranfirguration
    Enrollment(student=harry_key, course=transfiguration_key).put()
    Enrollment(student=hermione_key, course=transfiguration_key).put()
    Enrollment(student=crabbe_key, course=transfiguration_key).put()
    Enrollment(student=goyle_key, course=transfiguration_key).put()

    snape = Teacher(name="Severus Snape", years_experience=5, classes_taught=[potions_key])
    snape.put()
    moody = Teacher(name="Alastor Moody", years_experience=1, classes_taught=[dada_key])
    moody.put()
    mcgonagall = Teacher(name="Minerva McGonagall", years_experience=12, classes_taught=[transfiguration_key])
    mcgonagall.put()
def seed_data():
    # initialize all the houses
    gryff = House(name="Gryffindor", mascot="Lion")
    snakes = House(name="Slytherin", mascot="Snake")
    hufflepuff = House(name="Hufflepuff", mascot="Badger")
    ravenclaw = House(name="Ravenclaw",  mascot="Eagle")
    gryff.put()
    snakes.put()
    hufflepuff.put()
    ravenclaw.put()

    # initialize all the classes
    potions = Course(name="Potions", location="dungeon")
    dada = Course(name="Defense Against the Dark Arts", location="3C")
    transfiguration = Course(name="Transfiguration", location="Class 34")
    potions.put()
    dada.put()
    transfiguration.put()

    # create some teachers for those classes
    snape = Teacher(name="Severus Snape", years_experience=5, class_taught=potions.name)
    snape.put()
    moody = Teacher(name="Alastor Moody", years_experience=1, class_taught=dada.name)
    moody.put()
    mcgonagall = Teacher(name="Minerva McGonagall", years_experience=12, class_taught=transfiguration.name)
    mcgonagall.put()

    # initialize some students
    ron = Student(student_num=423491377, first_name ="Ron", last_name = "Weasley", house_name=gryff.name)
    harry = Student (student_num=423491782, first_name ="Harry", last_name = "Potter", house_name=gryff.name)
    hermione = Student(student_num=423491249, first_name="Hermione", last_name="Granger", house_name=gryff.name)
    malfoy = Student(student_num=42391043, first_name="Draco", last_name="Malfoy", house_name=snakes.name)
    crabbe = Student(student_num=42391122, first_name="Vincent", last_name="Crabbe", house_name=snakes.name)
    goyle = Student(student_num=42391063, first_name="Gregory", last_name="Goyle", house_name=snakes.name)
    ron.put()
    harry.put()
    hermione.put()
    malfoy.put()
    crabbe.put()
    goyle.put()

    # create wands for the students
    ron_wand=Wand(length = 14.0, material = "willow", core="unicorn", owner_num=ron.student_num).put()
    harry_wand=Wand(length = 11.0, material = "holly", core="phoenix feather", owner_num=harry.student_num).put()
    hermione_wand = Wand(length=10.75, material="vinewood", core="dragon heartstring", owner_num=hermione.student_num).put()

    # enroll some students in defense against the dark arts
    Enrollment(student_num=ron.student_num, course_name=dada.name).put()
    Enrollment(student_num=harry.student_num, course_name=dada.name).put()
    Enrollment(student_num=hermione.student_num, course_name=dada.name).put()

    # enroll some students in potions
    Enrollment(student_num=hermione.student_num, course_name=potions.name).put()
    Enrollment(student_num=ron.student_num, course_name=potions.name).put()
    Enrollment(student_num=malfoy.student_num, course_name=potions.name).put()
    Enrollment(student_num=crabbe.student_num, course_name=potions.name).put()
    Enrollment(student_num=goyle.student_num, course_name=potions.name).put()

    # enroll some students in tranfirguration
    Enrollment(student_num=harry.student_num, course_name=transfiguration.name).put()
    Enrollment(student_num=hermione.student_num, course_name=transfiguration.name).put()
    Enrollment(student_num=crabbe.student_num, course_name=transfiguration.name).put()
    Enrollment(student_num=goyle.student_num, course_name=transfiguration.name).put()