Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

#where the database file is stored
SQLALCHEMY_DATABASE_URI='sqlite:///' + os.path.join(pathName, 'app.db')

)
Usersdb = SQLAlchemy(obj)
db = SQLAlchemy(obj)

from app import routes
Binary file modified app/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified app/__pycache__/forms.cpython-312.pyc
Binary file not shown.
Binary file modified app/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file modified app/__pycache__/routes.cpython-312.pyc
Binary file not shown.
Binary file modified app/app.db
Binary file not shown.
6 changes: 5 additions & 1 deletion app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ class LoginForm(FlaskForm, Form):
username = StringField('Username',validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
remember_me = BooleanField('Remember Me')
submit = SubmitField('Sign In')
submit = SubmitField('Sign In')

class ViewForm(FlaskForm, Form):
fn = StringField('Flight Number:',validators=[DataRequired()])
submit = SubmitField('Search')
23 changes: 18 additions & 5 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from app import Usersdb
class User():
id = Usersdb.Column(Usersdb.Integer, primary_key=True)
name = Usersdb.Column(Usersdb.String(64), unique=True)
email = Usersdb.Column(Usersdb.String(64))
from app import db
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), unique=True)
email = db.Column(db.String(64))

posts = db.relationship('Post', backref='author',)

def __repr__(self):
return f'[User {self.username} / {self.email}]'

class Post(db.Model):
id = db.Column(db.Integer, primary_key=True)
body = db.Column(db.String(256))
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

def __repr__(self):
return f'[User {self.body} / {self.user_id}]'
68 changes: 65 additions & 3 deletions app/routes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from flask import Flask, render_template, flash, redirect
from app import obj
from app.forms import LoginForm
from app.forms import LoginForm, ViewForm

#these must be imported to manipulate the database

#different URL the app will implement
from app.models import User, Post
from app import db

@obj.route("/")
@obj.route("/index.html")
#called view function
Expand Down Expand Up @@ -32,13 +37,70 @@ def login():
if current_form.validate_on_submit():
flash(f'VALID USERNAME {current_form.username.data}')
flash(f'VALID PASSWORD {current_form.password.data}')
return redirect('/')

flash('ERROR INVALID USERNAME OR PASSWORD')
############Add a row to database (user table)####################
user = User(username=current_form.username.data, email = 'test@gmail.com')
db.session.add(user)
db.session.commit()

###############Get/search a row to the database (user table)################
#look up all users
#users = User.query.all()
#for user in users:
#shows on the terminal
#print(user.id, user.username, user.email)

#show on html
#flash()

##############Look up users by ID#########################
#print(User.query.get(2))

##############Look up users by attribute (returns a list)#############
#search = User.query.filter_by(username='steven')
#for s in search:
# print(s)

########delete a row in the database (user table)##############
#user_to_delete = User.query.get(1)
#db.session.delete(user_to_delete)
#db.session.commit()

##########################################################################
# Adding to User and Post
#Step 1: create user
#u = User(username=current_form.username.data, email='test@gmail.com')
#db.session.add(u)
#db.session.commit()

#Step 2: create post
#p = Post(body='hello this is a tweet', author=User.query.get(1))
#db.session.add(p)
#db.session.commit()

#Step 3: search for post
##search for user
#u = User.query.get(1)
#print(u.posts)

#return redirect('/')

#flash('ERROR INVALID USERNAME OR PASSWORD')
#print(f'This is the username {current_form.username.data}')
#flash(f'{current_form.username.data} is an invalid username')
return render_template("login.html", form=current_form)

@obj.route("/view", methods=["GET", "POST"])
#tells flask to execute login() when user goes to /login path of the webpage
def view():
current_form = ViewForm()
if current_form.validate_on_submit():
flash(f'VALID FLIGHT NUMBER {current_form.fn.data}')

############Database Procedure here####################
return render_template("view.html", form=current_form)


@obj.route("/guidelines")
def guidelines():
return render_template('guidelines.html')
5 changes: 4 additions & 1 deletion app/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<html lang="en">

<head>
<title>Login - Pet Jett</title>
<title>Pet Jett</title>
</head>

<body>
{% with messages = get_flashed_messages() %}
{% if messages %}
Expand All @@ -16,4 +18,5 @@
{% block content %}
{% endblock %}
</body>

</html>
85 changes: 80 additions & 5 deletions app/templates/guidelines.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
<ul>
<li>Pets must be spayed/neutered and fully vaccinated (must show medical records)</li>
<li>Dogs must be leashed, and cats must be in their carrier at the airport and accompanied by their human at all times</li>
<li>Please do not clap at the end of the flight as it will potentially scare other pets</li>
</ul>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FAQ - Pet Jett</title>
<style>
.accordion {
background-color: #8bc34a;
color: #fff;
cursor: pointer;
padding: 12px;
width: 100%;
border: none;
text-align: left;
outline: none;
transition: 0.4s;
}

.active, .accordion:hover {
background-color: #d3eba9;
}

.arrow:after {
content: '\02795';
font-size: 12px;
color: #666;
float: right;
}

.active .arrow:after {
content: "\2796";
}

.panel {
padding: 0 12px;
background-color: white;
display: none;
overflow: hidden;
}
</style>
</head>
<body>
<h1>FAQ - Pet Jett</h1>

<button class="accordion">Do all pets need shots? <span class="arrow"></span></button>
<div class="panel">
<p>Yes, all furry friends must be up-to-date with their shots to hop on board!</p>
</div>

<button class="accordion">Can my pet chill with me in the cabin? <span class="arrow"></span></button>
<div class="panel">
<p>Of course! If your buddy plays by the rules and behaves well, they can chill with you .</p>
</div>

<button class="accordion">Any breed restrictions? <span class="arrow"></span></button>
<div class="panel">
<p>Nope, we love all breeds! Just keep an eye on aggressive behavior.</p>
</div>

<!-- We'll add more FAQs later -->

<script>
var acc = document.getElementsByClassName("accordion");

for (var i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");

var panel = this.nextElementSibling;
if (panel.style.display === "block") {
panel.style.display = "none";
} else {
panel.style.display = "block";
}
});
}
</script>
</body>
</html>
15 changes: 12 additions & 3 deletions app/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
</head>
<body>
<h1>Welcome to PetJett!</h1>

<!-- guidelines page -->
<a href="/guidelines"><button>FAQs and Guidelines</button></a>

<table>
<tr>
<th>Company</th>
Expand All @@ -20,12 +24,17 @@ <h1>Welcome to PetJett!</h1>
<tr>
<td>{{company}}</td>
<td>Maria Anders</td>
<td>Germany</td>
<td>New York</td>
</tr>
<tr>
<td></td>
<td></td>
<td>Los Angeles</td>
</tr>
<tr>
<td></td>
<td></td>
<td>San Francisco</td>
<td>New York</td>
<td>Hawaii</td>
</tr>
</table>
<ul>
Expand Down
15 changes: 15 additions & 0 deletions app/templates/view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% extends "base.html" %}

{% block content %}
<h1> View your flight</h1>
<h2> Enter your Flight Number:</h2>
<form action=" " method="POST" novalidate>
<p>{{form.fn.label}}
{{form.fn(size=32)}}
</p>
<p>{{form.submit()}}
</p>
<p></p>
<p></p>
</form>
{% endblock %}