コード例 #1
0
ファイル: student.py プロジェクト: hsw5138/bis
def student_controller(id):
    name = request.values.get('name')
    username = request.values.get('username')
    email = request.values.get('email')

    if id:
        student = Student.query(Student.id == id).get()
        if student:
            logging.error("student found")
            if request.method == 'GET':
                logging.error("In get")
                if request.values.get('json'):
                    return json.dumps(dict(student=student.json))
                return render_template('student_view.html',
                                       student=student,
                                       title="Student List")
            elif request.method == 'PUT':
                logging.error("In put")
                student = edit_parser(student, request)
                student.put()
                return 'Value Updated', 204
            elif request.method == 'DELETE':
                logging.error("In delete")
                student.key.delete()
                logging.error("after delete")
                return 'Item deleted', 204
            else:
                return 'Method Not Allowed'
    else:
        if request.method == 'GET':
            student_list = Student.query().fetch(1000)
            entries = None
            if student_list:
                entries = [student.dto() for student in student_list]
            if request.values.get('json'):
                return json.dumps(dict(student=entries))
            return render_template('student.html',
                                   student_entries=entries,
                                   title="Student List")
        elif request.method == 'POST':
            student = Student()
            student = new_parser(student, request)
            student.put()
            url = '/student/'
            if request.values.get('json'):
                url = '/student/json=true'
            return redirect(url)
        else:
            return abort(405)
コード例 #2
0
ファイル: homework.py プロジェクト: hsw5138/bis
def homework_controller(id):
    subject_id = request.values.get('subject_id')
    title = request.values.get('title')
    due_date = request.values.get('due_date')
    description = request.values.get('description')
    schedule_id = request.values.get('schedule_id')

    if id:
        homework = Homework.query(Homework.id == id).get()
        if homework:
            if request.method == 'GET':
                if request.values.get('json'):
                    return json.dumps(dict(homework=homework.json))
                return render_template('homework_view.html',
                                       homework=homework,
                                       title="Homework List")
            elif request.method == 'PUT':
                homework = edit_parser(homework, request)
                homework.put()
                return 'Value Updated', 204
            elif request.method == 'DELETE':
                homework.key.delete()
                return 'Item deleted', 204
            else:
                return 'Method Not Allowed'
    else:
        if request.method == 'GET':
            homework_list = Homework.query().fetch(1000)
            entries = None
            if homework_list:
                entries = [homework.json() for homework in homework_list]
            if request.values.get('json'):
                return json.dumps(dict(homework=entries))
            return render_template('homework.html',
                                   homework_entries=entries,
                                   title="Homework List")
        elif request.method == 'POST':
            homework = Homework()
            homework = new_parser(homework, request)
            homework.put()
            url = '/homework/'
            if request.values.get('json'):
                url = '/homework/json=true'
            return redirect(url)
        else:
            return abort(405)
コード例 #3
0
ファイル: schedule.py プロジェクト: hsw5138/bis
def schedule_controller(id):
    name = request.values.get('name')
    subject_id = request.values.get('subject_id')
    student_id = request.values.get('student_id')
    teacher_id = request.values.get('teacher_id')

    if id:
        schedule = Schedule.query(Schedule.id == id).get()
        if schedule:
            if request.method == 'GET':
                if request.values.get('json'):
                    return json.dumps(dict(schedule=schedule.json))
                return render_template('schedule_view.html',
                                       schedule=schedule,
                                       title="Schedule List")
            elif request.method == 'PUT':
                schedule = edit_parser(schedule, request)
                schedule.put()
                return 'Value Updated', 204
            elif request.method == 'DELETE':
                schedule.key.delete()
                return 'Item deleted', 204
            else:
                return 'Method Not Allowed'
    else:
        if request.method == 'GET':
            schedule_list = Schedule.query().fetch(1000)
            entries = None
            if schedule_list:
                entries = [schedule.json() for schedule in schedule_list]
            if request.values.get('json'):
                return json.dumps(dict(schedule=entries))
            return render_template('schedule.html',
                                   schedule_entries=entries,
                                   title="Schedule List")
        elif request.method == 'POST':
            schedule = Schedule()
            schedule = new_parser(schedule, request)
            schedule.put()
            url = '/schedule/'
            if request.values.get('json'):
                url = '/schedule/json=true'
            return redirect(url)
        else:
            return abort(405)
コード例 #4
0
ファイル: homework.py プロジェクト: hsw5138/bis
def homework_controller(id):
	subject_id = request.values.get('subject_id')
	title = request.values.get('title')
	due_date = request.values.get('due_date')
	description = request.values.get('description')
	schedule_id = request.values.get('schedule_id')

	if id:
		homework = Homework.query(Homework.id==id).get()
		if homework:
			if request.method == 'GET':
				if request.values.get('json'):
					return json.dumps(dict(homework=homework.json))
				return render_template('homework_view.html',homework = homework, title = "Homework List")
			elif request.method == 'PUT':
				homework = edit_parser(homework,request)
				homework.put()
				return 'Value Updated', 204
			elif request.method == 'DELETE':
				homework.key.delete()
				return 'Item deleted', 204
			else:
				return 'Method Not Allowed'
	else:
		if request.method == 'GET':
			homework_list = Homework.query().fetch(1000)
			entries=None
			if homework_list:
				entries = [homework.json() for homework in homework_list]
			if request.values.get('json'):
				return json.dumps(dict(homework=entries))
			return render_template('homework.html',homework_entries = entries, title = "Homework List")
		elif request.method == 'POST':
			homework = Homework()
			homework = new_parser(homework,request)
			homework.put()
			url = '/homework/'
			if request.values.get('json'):
				url = '/homework/json=true'
			return redirect(url)
		else:
			return abort(405)
コード例 #5
0
ファイル: schedule.py プロジェクト: hsw5138/bis
def schedule_controller(id):
	name = request.values.get('name')
	subject_id = request.values.get('subject_id')
	student_id = request.values.get('student_id')
	teacher_id = request.values.get('teacher_id')

	if id:
		schedule = Schedule.query(Schedule.id==id).get()
		if schedule:
			if request.method == 'GET':
				if request.values.get('json'):
					return json.dumps(dict(schedule=schedule.json))
				return render_template('schedule_view.html',schedule = schedule, title = "Schedule List")
			elif request.method == 'PUT':
				schedule = edit_parser(schedule,request)
				schedule.put()
				return 'Value Updated', 204
			elif request.method == 'DELETE':
				schedule.key.delete()
				return 'Item deleted', 204
			else:
				return 'Method Not Allowed'
	else:
		if request.method == 'GET':
			schedule_list = Schedule.query().fetch(1000)
			entries=None
			if schedule_list:
				entries = [schedule.json() for schedule in schedule_list]
			if request.values.get('json'):
				return json.dumps(dict(schedule=entries))
			return render_template('schedule.html',schedule_entries = entries, title = "Schedule List")
		elif request.method == 'POST':
			schedule = Schedule()
			schedule = new_parser(schedule,request)
			schedule.put()
			url = '/schedule/'
			if request.values.get('json'):
				url = '/schedule/json=true'
			return redirect(url)
		else:
			return abort(405)
コード例 #6
0
ファイル: teacher.py プロジェクト: hsw5138/bis
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)
コード例 #7
0
ファイル: subject.py プロジェクト: hsw5138/bis
def subject_controller(id):
	name = request.values.get('name')

	if id:
		subject = Subject.query(Subject.id==id).get()
		if subject:
			if request.method == 'GET':
				if request.values.get('json'):
					return json.dumps(dict(subject=subject.json))
				return render_template('subject_view.html',subject = subject, title = "Subject List")
			elif request.method == 'PUT':
				subject = edit_parser(subject,request)
				subject.put()
				return 'Value Updated', 204
			elif request.method == 'DELETE':
				subject.key.delete()
				return 'Item deleted', 204
			else:
				return 'Method Not Allowed'
	else:
		if request.method == 'GET':
			subject_list = Subject.query().fetch(1000)
			entries=None
			if subject_list:
				entries = [subject.dto() for subject in subject_list]
			if request.values.get('json'):
				return json.dumps(dict(subject=entries))
			return render_template('subject.html',subject_entries = entries, title = "Subject List")
		elif request.method == 'POST':
			subject = Subject()
			subject = new_parser(subject,request)
			subject.put()
			url = '/subject/'
			if request.values.get('json'):
				url = '/subject/json=true'
			return redirect(url)
		else:
			return abort(405)