Skip to content

Commit

Permalink
trying to work through errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtenberger committed Jun 3, 2024
1 parent 5bbb5a1 commit 75304b2
Show file tree
Hide file tree
Showing 5,671 changed files with 976,477 additions and 32 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added __pycache__/app.cpython-39.pyc
Binary file not shown.
53 changes: 36 additions & 17 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
from flask import Flask, render_template, redirect, request, url_for, g
from sqlalchemy import func
from flask_sqlalchemy import SQLALchemy
from flask import Flask, render_template, redirect, request, url_for, session, g
from sqlalchemy import func, create_engine, exc
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.automap import automap_base
import random
import os

# from forms import LoginForm, UserAddForm, CocktailForm
# from models import db, connect_db, User, Cocktails

# CURR_USER_KEY = 'curr_user'
CURR_USER_KEY = "curr_user"

app = Flask(__name__)
app.secret_key = os.environ.get('COCKTAILS_FLASK_KEY')
app.app_context().push()

ENV - 'prod'
app.config['SQLALCHEMY_DATABASE_URI'] = (
os.environ.get('DATABASE_URL', 'postgresql://cocktails.db'))

if ENV == 'dev':
password = os.environ.get('POSTGRE_PASS')
app.config["SQLALCHEMY_DATABASE_URI"] = f'postgresql:{password}@localhost:5432/cocktailpg'
else:
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get('DATABASE_URL')
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', "it's a secret")
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_ECHO'] = False
app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True

db = SQLAlchemy(app)
table_names = db.engine.table_names()
Base = automap_base()
Base.prepare(db.engine, replect=True)
Base.prepare(autoload_with=db.engine)

cocktails = Base.classes.cocktails
ingredients = Base.classes.ingredients
users = Base.classes.users

@app.before_request
def add_user_to_g():
"""If we're logged in, add curr user to Flask global."""

if CURR_USER_KEY in session:
g.user = User.query.get(session[CURR_USER_KEY])

else:
g.user = None

def do_login(user):
"""Log in user."""

session[CURR_USER_KEY] = user.id


def do_logout():
"""Logout user."""

if CURR_USER_KEY in session:
del session[CURR_USER_KEY]

def delete_user_cocktail(cocktail_name):
user = db.session.query(users).filter(user.username == g['username'])[0]
cocktail = db.session.query(cocktails).filter(cocktails.name == cocktail_name)[0]
Expand Down Expand Up @@ -159,7 +177,7 @@ def profile():
@app.route('/', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
if 'username' in request.form and 'password' in request.for,:
if 'username' in request.form and 'password' in request.form:
username = request.form['username']
password = request.form['password']
user_valid = check_input_valid(username, username=True)
Expand Down Expand Up @@ -216,4 +234,5 @@ def register():


if __name__ == '__main__':

app.run()
2 changes: 1 addition & 1 deletion generator/cocktail.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1441,4 +1441,4 @@ The Negroni Bianco,,,,"1.5 oz Luxardo Bitter Bianco, .75 oz Tempus Fugit Alessio
Match Grip Julep,Jarred Weigand,Death & Co.,New York,"1.5 oz H by HINE, .5 oz Jamaican Rum, 1 tsp Cacao, 1 tsp Branca Menta, 1 tsp Demerara, 1 dash Mole",,N/A,,
The Dry Cruise,Jacyara de Oliveira,"Rob Roy, The Hideout",Seattle,"1 oz Luxardo Bitter Bianco, 1 oz Lustau Oloroso Sherry, .25 oz St. Germain, .75 oz Lemon Juice, .5 oz Honey Syrup, top Sparkling Wine","Edible Flower, Straw",N/A,,
Red Hook,Patrick Halloran,Henrietta Red,Nashville,"2 oz Rye Whiskey, 5 oz Punt e Mes, .5 oz Luxardo Maraschino Liqueur",,N/A,,
Union Jack,Jason Patz,Union Lodge No.1,Denver,".75 oz Luxardo Maraschino Liqueur, .75 oz Green Chartreuse, .5 oz Grenadine 'Layered' Beer Back ",,N/A,,
Union Jack,Jason Patz,Union Lodge No.1,Denver,".75 oz Luxardo Maraschino Liqueur, .75 oz Green Chartreuse, .5 oz Grenadine 'Layered' Beer Back ",,N/A,,
5 changes: 3 additions & 2 deletions generator/cocktail_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
def double_apostrophe(string):
final = ''
for c in string:
if c == "'" * 2
if c == "'":
final += "'" * 2
else:
final += c
return final
Expand Down Expand Up @@ -144,7 +145,7 @@ def db_init():
initial_table_insert(dataset=normalize_rows(column=cocktails.Ingredients), table_name='ingredients')
insert_data_into_cocktails()
insert_cocktail_ingredients
add_user_tables()
add_user_table()
con.commit()
con.close()

Expand Down
1 change: 0 additions & 1 deletion generator/user.csv
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
username, email, password
15 changes: 7 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
blinker==1.8.1
click==7.1.2
click==8.1.7
Flask==3.0.3
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
greenlet==3.0.3
gunicorn==20.0.4
importlib_metadata==7.1.0
itsdangerous==2.2.0
Jinja2==3.1.3
MarkupSafe==2.1.5
numpy==1.19.5
pandas==1.1.5
psycopg2==2.8.6
numpy==1.26.4
pandas==2.2.2
psycopg2-binary==2.9.9
python-dateutil==2.8.1
pytz==2020.5
six==1.15.0
python-dateutil==2.9.0.post0
pytz==2024.1
six==1.16.0
SQLAlchemy==2.0.29
typing_extensions==4.11.0
tzdata==2024.1
Werkzeug==3.0.2
WTForms==3.1.2
zipp==3.18.1
4 changes: 1 addition & 3 deletions schema.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ Table 1 - User

Table 2 - Cocktails
name
image
instructions
ingredients
measurements
ingredients
81 changes: 81 additions & 0 deletions static/login.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
html, body {
height: 100%;
width: 100%;
font-size: 16px;
font-family: 'Libre Baskerville', serif;

}

header {
display: flex;
justify-content: center;
align-items: center;
color: white;
background: black;
width: 100%;
height: 5%;
text-align: center;

}

body {
margin: 0px;
background-size: cover;
}


#main-box {
color: white;
margin: auto;
width: 27%;
height: 45%;
margin-top: 0px;
background: #4F3328;
opacity: 0.82;
border-bottom-right-radius: 20%;
}

#error-box {
margin: auto;
text-align: center;
color: red;
border: 1px solid white;
background-color: white;
width: 15%;
border-radius: 15%;
opacity: 0.82;

font-size: 14px;
}

#main-box #login {
position: relative;
text-align: center;
top: 10%;
}

#main-box #login-button {
color: white;
font-size: 16px;
width: 20%;
background: #4F3328;
background: black;
border: 1px solid white;
text-shadow: 1px 1px 1px #000;
}

#main-box #register {
position: relative;
text-align: center;
top: 30%;
}

#main-box #reg-button {
color: white;
font-size: 16px;
width: 20%;
background: #4F3328;
background: black;
border: 1px solid white;
text-shadow: 1px 1px 1px #000;
}
Loading

0 comments on commit 75304b2

Please sign in to comment.