Example #1
0
        if student_id == None:
            student = StudentModel()
            student_list = student.query.all()
            form = StudentForm()
            return render_template('student_test.html', student_list=student_list, form=form)
        else:
            student = StudentModel()
            student_list = student.query.get(student_id)
            form = StudentForm(obj=student_list)
            return render_template('student_test_update.html', student_id=student_id, student_list=[student_list], form=form)

student_test = StudentTest.as_view('student_test')
student_put = StudentTest.as_view('student_put')

app.add_url_rule('/student_test/',\
    view_func=student_test,\
    methods=['GET','POST'])

app.add_url_rule('/student_test/<int:student_id>',\
    view_func=student_put,\
    methods=['GET', 'PUT', 'DELETE'])



class StudentView(MethodView):

    def post(self):
        "create new student record, http://flask.pocoo.org/snippets/63/ for easy WTforms redirect"
        student = StudentModel()
        form = StudentForm()
        if form.validate_on_submit():
Example #2
0
# URLs
from internaljobmarket import app
from internaljobmarket.views import StudentView, SupervisorView, PositionView, ApplicationView, OfferView 

student_view = StudentView.as_view('student_view')
app.add_url_rule('/students/',\
	view_func=student_view,\
	methods=['GET',])
app.add_url_rule('/students/',\
	view_func=student_view,\
	methods=['POST'])
app.add_url_rule('/students/<int:student_id>',\
	view_func=student_view,\
	methods=['GET','PUT', 'DELETE'])


#app.add_url_rule('/students/<int:student_id>/delete',\
#	view_func=student_view,\
#	methods=['DELETE'])

supervisor_view = SupervisorView.as_view('supervisors')
app.add_url_rule('/supervisors/',\
	view_func=supervisor_view,\
	methods=['GET',])
app.add_url_rule('/supervisors/',\
	view_func=supervisor_view,
	methods=['POST',])

app.add_url_rule('/supervisors/<int:supervisor_id>',\
	view_func=SupervisorView.as_view('supervisors'),\
	methods=['GET', 'PUT', 'DELETE'])
Example #3
0
        pass

    def put(self, student_id):
        "edit student record"
        pass

    def delete(self, student_id):
        "delete student record"
        pass

    def get(self):
        "review student record"
        
        pass
#Move to urls
app.add_url_rule('/students/', view_func=Student.as_view('students'))

class SupervisorView(MethodView):
    def post(self):
        "create supervisor record"
        supervisors = SupervisorModel()
        form = SupervisorForm(request.form)
        if form.validate():
           supervisors.supervisor_id = form.supervisor_id.data
           supervisors.nameLast = form.nameLast.data
           supervisors.nameFirst = form.nameFirst.data
           supervisors.phone = form.phone.data
           supervisors.email = form.email.data
           supervisors.room = form.room.data
           supervisors.center =  form.center.data
           return supervisors