Пример #1
0
def teacher_upload_process_controller():
	file = request.files['file']
	rows = get_row_values(file)
	rows=rows[1:]
	for column in rows:
		new_teacher = Teacher(
					id=generate_key(),
					name=column[0],
					email=column[1])
		new_teacher.put()
	return render_template('all_done.html')
Пример #2
0
 def post(self):
     if GetTeacher(users.get_current_user()) == None:
         new_teacher = Teacher(parent=root_parent())
         new_teacher.user = users.get_current_user()
         new_teacher.email = (users.get_current_user()).email()
         new_teacher.code = randint(100,999)
         new_teacher.put()
         self.redirect('/teacherSession')
     else:
         newCode = randint(100,999)
         currentTeacher = GetTeacher(users.get_current_user())
         currentTeacher.code = newCode
         currentTeacher.put()
         self.redirect('/teacherSession')
Пример #3
0
def register():
    error = None
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        teacher = Teacher(
            first_name=form.first_name.data,
            last_name=form.last_name.data,
            email=form.email.data,
            password=form.password.data,
        )
        try:
            teacher.put()
            teacher_id = teacher.key.id()
            flash(u'Teacher %s successfully saved.' % teacher_id, 'success')
            return redirect(url_for('login'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('register'))
    return render_template('register.html', form=form)
Пример #4
0
def register():
    error = None
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        teacher = Teacher(
            first_name=form.first_name.data,
            last_name=form.last_name.data,
            email=form.email.data,
            password=form.password.data,
        )
        try:
            teacher.put()
            teacher_id = teacher.key.id()
            flash(u'Teacher %s successfully saved.' % teacher_id, 'success')
            return redirect(url_for('login'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.',
                  'info')
            return redirect(url_for('register'))
    return render_template('register.html', form=form)
Пример #5
0
def teacher_controller(id):
	name = request.values.get('name')
	email = request.values.get('email')

	if id:
		teacher = Teacher.query(Teacher.id==id).get()
		if teacher:
			if request.method == 'GET':
				if request.values.get('json'):
					return json.dumps(dict(teacher=teacher.json))
				return render_template('teacher_view.html',teacher = teacher, title = "Teacher List")
			elif request.method == 'PUT':
				teacher = edit_parser(teacher,request)
				teacher.put()
				return 'Value Updated', 204
			elif request.method == 'DELETE':
				teacher.key.delete()
				return 'Item deleted', 204
			else:
				return 'Method Not Allowed'
	else:
		if request.method == 'GET':
			teacher_list = Teacher.query().fetch(1000)
			entries=None
			if teacher_list:
				entries = [teacher.dto() for teacher in teacher_list]
			if request.values.get('json'):
				return json.dumps(dict(teacher=entries))
			return render_template('teacher.html',teacher_entries = entries, title = "Teacher List")
		elif request.method == 'POST':
			teacher = Teacher()
			teacher = new_parser(teacher,request)
			teacher.put()
			url = '/teacher/'
			if request.values.get('json'):
				url = '/teacher/json=true'
			return redirect(url)
		else:
			return abort(405)
Пример #6
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="Granger").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()