Skip to content

Commit

Permalink
merge conflict with templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jonager committed Sep 2, 2017
2 parents a24fcc9 + 07d809e commit d463bfa
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 42 deletions.
49 changes: 42 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ 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():
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:
# return render_template('teacher_login.html', title = 'Signup', signup='active')

@app.route("/teacher_signup", methods=['POST'])
def teacher_signup():
Expand Down Expand Up @@ -230,5 +239,31 @@ 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)


if __name__ == "__main__":
app.run()
4 changes: 0 additions & 4 deletions templates/add_student.html

This file was deleted.

4 changes: 2 additions & 2 deletions templates/attendance.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{% block content %}
<div class="container">
{% if attendance|length == 0 %}
<div class="card small hoverable m6">
<div class="card small hoverable m6 lc-blue-text" id="att-date-card">
<div class="card-content">
<span class="card-title" >Attendance Dates</span>
<span class="card-title">Attendance Dates</span>
<form action="/attendance" method="post">
<div class="row">
<div class="input-field col s12">
Expand Down
84 changes: 64 additions & 20 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
main {
flex: 1 0 auto;
background-image: url('https://www.launchcode.org/assets/cover_banner_blue-8152795f6794e4bbb9fae2a63ad5bb01.jpg');
background-position: 0px -140px;
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: rgba(092,147,206,1) !important;
}
.tabs .tab a:hover, .tabs .tab a.active{
color: rgba(092,147,206,1) !important;
Expand All @@ -36,21 +39,27 @@
nav .brand-logo{
font-size: 1.75rem;
}
.dropdown-content li>a, .dropdown-content li>span{
color: rgba(050,050,050,1);
.dropdown-content li>span{
color: #344A5F !important;
}
.dropdown-content li>a{
color: rgba(255,255,255,.9);
}
.dropdown-content{
min-width: 165px;
}
.page-footer .footer-copyright{
background-color: rgba(51,51,51,0.1) !important;
}
#teacher-card{
margin: 3rem 0 3rem 0;
margin: 3rem -1.5rem 3rem -1.5rem;
height: 550px;
}
#teacher{
width: 50%;
}
#student-card{
margin: 6rem 0 6rem 0;
margin: 8rem 0 8rem 0;
height: 325px;
}
#student{
Expand All @@ -63,6 +72,10 @@
#change{
width: 30%;
}
#att-date-card{
margin: 6rem 0 6rem 0;
height: 425px;
}
#index{
margin: 12rem 0 12rem 0;
}
Expand All @@ -75,17 +88,26 @@
font-size: 1.25rem;
letter-spacing: 1px;
}
.btn{
background-color: #F47753 !important;
}
.btn:hover{
background-color: #F0400F !important;
}
.lc-blue-text{
color: #344A5F !important;
}
.lc-blue{
background-color: #344A5F !important;
background-color: #344A5F;
}
.lc-light-blue{
background-color: #5C93CE !important;
background-color: #5C93CE;
}
.lc-orange{
background-color: #F0400F !important;
background-color: #F0400F;
}
.lc-light-orange{
background-color: #F47753 !important;
background-color: #F47753;
}
</style>
<script>
Expand All @@ -98,24 +120,24 @@
$(".dropdown-button").dropdown();
// Initialize options
$('select').material_select();
// Flash Messages Toasts
{% with messages = get_flashed_messages() %}
{% for message in messages %}
Materialize.toast('{{ message }}', 4000);
{% endfor %}
{% endwith %}
});
// { flash }
</script>
</head>
<body>
<header>
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper lc-blue">
<a href="/" class="brand-logo center">LaunchCode Attendance</a>
<div class="nav-wrapper white">
<a href="/" class="brand-logo center lc-blue-text">LaunchCode <img src="https://www.launchcode.org/assets/launchcode-7e70c69adb4c3c1aa6d5aa15eba45fac.ico" alt="LC"> Attendance</a>
{% if session['email'] %}
<ul class="left">
<li><a class="dropdown-button" href="#!" data-activates="dropdown"><i class="material-icons">menu</i></a></li>
<li><a class="dropdown-button waves-effect waves-light lc-blue-text" href="#!" data-activates="dropdown"><i class="material-icons">menu</i></a></li>
</ul>
<a href="#" data-activates="mobile-demo" class="button"></a>
<ul class="dropdown-content lc-light-orange" id="dropdown">
Expand All @@ -124,26 +146,48 @@
<li><a class="nav-dropwdown" href="/students" class="waves-effect waves-light"><i class="material-icons left">people</i>Students</a></li>
</ul>
<ul class="right">
<li><a class="waves-effect waves-light" href="/logout">Logout</a></li>
<li><a class="waves-effect waves-light lc-blue-text" href="/logout">Logout</a></li>
</ul>
{% else %}
{% endif %}
</div>
</nav>
</div>
</header>
<main>
<main id>
{% block content %}
{% endblock %}
</main>
<footer class="page-footer lc-blue">
<div class="footer-copyright">
<div class="container">
© 2017 Copyright
<a class="white-text right" href='https://github.com/anthony-becerra/launchcode-attendance' target='_blank'>Fork us on Github! <i class='ion-social-github'></i></a>
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">LaunchCode Attendance</h5>
<p class="grey-text text-lighten-4">Tracks Attendance for LC101 Cohorts.</p>
</div>
<div class="col l4 offset-l1 s12">
<h5 class="white-text">Contributors</h5>
<div class="col">
<div class="row">
<a class="chip lc-light-blue-text" href="https://github.com/anthony-becerra" target='_blank'><img src="https://avatars2.githubusercontent.com/u/27900121?v=4&s=400" alt="Anthony Img">Anthony</a>
<a class="chip lc-light-blue-text" href="https://github.com/dannyneira" target='_blank'><img src="https://avatars2.githubusercontent.com/u/16809145?v=4&s=460" alt="Danny Img">Danny</a>
</div>
</div>
<div class="col">
<div class="row">
<a class="chip lc-light-blue-text" href="https://github.com/kitiarasr" target='_blank'><img src="https://avatars3.githubusercontent.com/u/14181911?v=4&s=400" alt="Kitiara Img">Kitiara</a>
<a class="chip lc-light-blue-text" href="https://github.com/jonager" target='_blank'><img src="https://avatars0.githubusercontent.com/u/17533132?v=4&s=400" alt="Jonathan Img">Jonathan</a>
</div>
</div>
</div>
</div>
</div>
<div class="footer-copyright">
<div class="container">
© 2017 Copyright
<a class="grey-text text-lighten-3 right" href='https://github.com/anthony-becerra/launchcode-attendance' target='_blank'>Fork us on Github! <i class='ion-social-github'></i></a>
</div>
</div>
</footer>
</footer>
</body>
</html>
2 changes: 1 addition & 1 deletion templates/change_pin.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% block content %}
<div class="container" id="change">
<div class="card medium hoverable m6" id="change-card">
<div class="card medium hoverable m6 lc-blue-text" id="change-card">
<div class="card-content">
<span class="card-title" >Change Pin</span>
<form action="/change_pin" method="post">
Expand Down
45 changes: 43 additions & 2 deletions templates/edit_student.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
{% extends 'base.html' %}
{% block content %}
<h2>Student edit form goes here</h2>
{% endblock %}
<h2>Edit Student</h2>
<!-- input form of first and last name, and pin, cohort, city -->

<form method="post">
<table>
<tr>
<input type="hidden" name="student_id" value="{{student.id}}" />

<td><label for="first_name">First Name</label></td>
<td>
<input name="first_name" type="text" value="{{student.first_name}}">
</td>
</tr>
<tr>
<td><label for="last_name">Last Name</label></td>
<td>
<input name="last_name" type="text" value="{{student.last_name}}">
</td>
</tr>
<tr>
<td><label for="pin">Pin</label></td>
<td>
<input name="pin" type="text" value="{{student.pin}}">
</td>
</tr>
<tr>
<td><label for="cohort">Cohort</label></td>
<td>
<input name="cohort" type="text" value="{{student.cohort}}">
</td>
</tr>
<tr>
<td><label for="city">City</label></td>
<td>
<input name="city" type="text" value="{{student.city}}">
</td>
</tr>
</table>
<input type="submit" value="Save Changes">
</form>

{% endblock %}

4 changes: 2 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div class="container">
<div class="col center" id="index">
<div class="row">
<a class="btn waves-effect waves-light lc-orange hoverable" id="index-btn" href="/start_day">Start Day</a>
<a class="btn waves-effect waves-light lc-light-orange hoverable" id="index-btn" href="/start_day"><b>Start Day</b></a>
<br><br>
<a class="btn waves-effect waves-light lc-orange hoverable" id="index-btn" href="/student_login">Student Login</a>
<a class="btn waves-effect waves-light lc-light-orange hoverable" id="index-btn" href="/student_login"><b>Student Login</b></a>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions templates/student_login.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% extends 'base.html' %}
{% block content %}
<div class="container" id="student">
<div class="card medium hoverable m6" id="student-card">
<div class="card medium hoverable m6 lc-blue-text" id="student-card">
<div class="card-content">
<span class="card-title" >Student Login</span>
<span class="card-title" >Student Sign-In</span>
<form action="/student_login" method="post">
<div class="row">
<div class="input-field col s12">
Expand All @@ -20,7 +20,7 @@
</div>
</div>
<div class="row">
<button class="btn waves-effect waves-light lc-light-blue right" type="submit" name="action">Sign-In</button>
<button class="btn waves-effect waves-light lc-light-orange right" type="submit" name="action">Sign-In</button>
</div>
</form>
</div>
Expand Down
38 changes: 38 additions & 0 deletions templates/students.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
{% extends 'base.html' %}
{% block content %}
<h2>Students table + add and edit buttons go here</h2>

<!-- table -->
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>
{% for student in students %}
<tr>
<td>{{student.first_name}}</td>
<td>{{student.last_name}}</td>
<!-- each individual edit button -->
<td><button><a href="/edit_student?id={{student.id}}">Edit</a></button></td>
</tr>
{% endfor %}
</table>

<h4>Add Student</h4>
<!-- input form of first and last name, and pin, cohort, city -->

<form method="post">
<table>
<tr>

<td><label for="first_name">First Name</label></td>
<td>
<input name="first_name" type="text">
</td>
</tr>
<tr>
<td><label for="last_name">Last Name</label></td>
<td>
<input name="last_name" type="text" >
</td>
</tr>
</table>
<input type="submit" value="Add Student">
</form>
{% endblock %}
2 changes: 1 addition & 1 deletion templates/teacher_login.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% block content %}
<div class="container" id="teacher">
<div class="card large hoverable m6" id="teacher-card">
<div class="card large hoverable m6 lc-blue-text" id="teacher-card">
<div class="card-tabs text">
<ul class="tabs tabs-fixed-width">
<li class="tab"><a class="{{ login }}" href="#login">Login</a></li>
Expand Down

0 comments on commit d463bfa

Please sign in to comment.