From 70785e340b3a8b0d3011873280d809be5e899ea3 Mon Sep 17 00:00:00 2001 From: Anthony Becerra Date: Fri, 1 Sep 2017 13:37:08 -0400 Subject: [PATCH 1/4] Added students page --- main.py | 14 +++++++------- templates/students.html | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 51b7d71..aaa0c47 100644 --- a/main.py +++ b/main.py @@ -24,13 +24,13 @@ def logout(): def attendance_list(): return render_template('attendance_list.html') -# TODO -# Student List -# @app.route('/student_list', methods=["POST", "GET"]) -# def student_list(): -# return render_template('student_list.html') -# else: -# return render_template('teacher_login.html', title = 'Signup', signup='active') +#TODO +@app.route('/students', methods=["POST", "GET"]) +def students(): + students = Student.query.all() + return render_template('students.html', students=students) + # else: + # return render_template('teacher_login.html', title = 'Signup', signup='active') @app.route("/teacher_signup", methods=['POST']) def teacher_signup(): diff --git a/templates/students.html b/templates/students.html index 35d9ae9..52f5e21 100644 --- a/templates/students.html +++ b/templates/students.html @@ -1,4 +1,18 @@ {% extends 'base.html' %} {% block content %}

Students table + add and edit buttons go here

+ + + +{% for student in students %} + + + + + + +{% endfor %} +
{{student.first_name}}{{student.last_name}}
+ + {% endblock %} \ No newline at end of file From 5b910df0d09731aaffdf6c94aac42bc2641d42c8 Mon Sep 17 00:00:00 2001 From: Anthony Becerra Date: Fri, 1 Sep 2017 14:14:58 -0400 Subject: [PATCH 2/4] Added students.html table header --- templates/students.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/students.html b/templates/students.html index 52f5e21..b44f977 100644 --- a/templates/students.html +++ b/templates/students.html @@ -4,6 +4,10 @@

Students table + add and edit buttons go here

+ + + + {% for student in students %} From 905170a03ba6b8c9c93e3eb7e6dd8a23b8dbc3a8 Mon Sep 17 00:00:00 2001 From: Kitiara Rivera Date: Fri, 1 Sep 2017 21:08:14 -0400 Subject: [PATCH 3/4] update edit student and add student --- main.py | 39 ++++++++++++++++++++++++++++++++ templates/add_student.html | 25 +++++++++++++++++++-- templates/edit_student.html | 45 +++++++++++++++++++++++++++++++++++-- 3 files changed, 105 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 51b7d71..98637cf 100644 --- a/main.py +++ b/main.py @@ -174,6 +174,45 @@ def attendance(): return render_template("attendance.html", dates=dates) +@app.route("/edit_student", methods=['GET', 'POST']) +def editStudent(): + if request.method == 'POST': + id = request.form['student_id'] + student = Student.query.filter_by(id=id).first() + + first_name = request.form['first_name'] + last_name = request.form['last_name'] + pin = request.form['pin'] + cohort = request.form['cohort'] + city = request.form['city'] + + student.first_name = first_name + student.last_name= last_name + student.pin = pin + student.cohort = cohort + student.city = city + + db.session.commit() + return redirect('/students') + else: + id = request.args.get('id') + student = Student.query.filter_by(id=id).first() + return render_template("edit_student.html", student=student) + +@app.route("/add_student", methods=['GET', 'POST']) +def addStudent(): + if request.method == 'POST': + first_name = request.form['first_name'] + last_name = request.form['last_name'] + + student = Student(first_name, last_name) + db.session.add(student) + db.session.commit() + return redirect('/students') + else: + return render_template("add_student.html") + + if __name__ == "__main__": app.run() \ No newline at end of file diff --git a/templates/add_student.html b/templates/add_student.html index 906f268..263632f 100644 --- a/templates/add_student.html +++ b/templates/add_student.html @@ -1,4 +1,25 @@ {% extends 'base.html' %} {% block content %} -

Student add form goes here (import google sheets?)

-{% endblock %} \ No newline at end of file +

Add Student

+ + +
+
First NameLast Name
{{student.first_name}}
+ + + + + + + + + +
+ +
+ +
+ + + +{% endblock %} diff --git a/templates/edit_student.html b/templates/edit_student.html index ddad0d7..bf04cfa 100644 --- a/templates/edit_student.html +++ b/templates/edit_student.html @@ -1,4 +1,45 @@ {% extends 'base.html' %} {% block content %} -

Student edit form goes here

-{% endblock %} \ No newline at end of file +

Edit Student

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +{% endblock %} + From 74fe4bc6de85389c956e85babc19628794fd61c9 Mon Sep 17 00:00:00 2001 From: Anthony Becerra Date: Fri, 1 Sep 2017 21:21:13 -0400 Subject: [PATCH 4/4] Added edit_student & add_student functionality --- main.py | 23 +++++++++-------------- templates/add_student.html | 25 ------------------------- templates/students.html | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 40 deletions(-) delete mode 100644 templates/add_student.html diff --git a/main.py b/main.py index 73ecd5d..5d54710 100644 --- a/main.py +++ b/main.py @@ -27,6 +27,15 @@ def attendance_list(): #TODO @app.route('/students', methods=["POST", "GET"]) def students(): + if request.method == 'POST': + first_name = request.form['first_name'] + last_name = request.form['last_name'] + + student = Student(first_name, last_name) + db.session.add(student) + db.session.commit() + return redirect('/students') + students = Student.query.all() return render_template('students.html', students=students) # else: @@ -199,20 +208,6 @@ def editStudent(): student = Student.query.filter_by(id=id).first() return render_template("edit_student.html", student=student) -@app.route("/add_student", methods=['GET', 'POST']) -def addStudent(): - if request.method == 'POST': - first_name = request.form['first_name'] - last_name = request.form['last_name'] - - student = Student(first_name, last_name) - db.session.add(student) - db.session.commit() - return redirect('/students') - else: - return render_template("add_student.html") - - if __name__ == "__main__": app.run() \ No newline at end of file diff --git a/templates/add_student.html b/templates/add_student.html deleted file mode 100644 index 263632f..0000000 --- a/templates/add_student.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends 'base.html' %} -{% block content %} -

Add Student

- - -
- - - - - - - - - - -
- -
- -
- -
- -{% endblock %} diff --git a/templates/students.html b/templates/students.html index b44f977..6761a98 100644 --- a/templates/students.html +++ b/templates/students.html @@ -18,5 +18,25 @@

Students table + add and edit buttons go here

{% endfor %} - +

Add Student

+ + +
+ + + + + + + + + + +
+ +
+ +
+ +
{% endblock %} \ No newline at end of file