Skip to content
Merged
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
57 changes: 38 additions & 19 deletions fcwebapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
client_metadata=ClientMetadata(
app.config["GGL_OIDC_CLIENT_ID"], app.config["GGL_OIDC_CLIENT_SECRET"]
),
auth_request_params={'scope': ['openid', 'profile', 'email']}
auth_request_params={"scope": ["openid", "profile", "email"]},
)

auth = OIDCAuthentication({"csh": CSH_AUTH_CONFIG, "google": GOOGLE_AUTH_CONFIG}, app)
Expand All @@ -43,7 +43,14 @@ def index():


from fcwebapp.utils import needs_auth
from fcwebapp.db import init_db, add_hammock, update_user, join_tent, leave_tent, add_tent
from fcwebapp.db import (
init_db,
add_hammock,
update_user,
join_tent,
leave_tent,
add_tent,
)


@app.route("/home")
Expand All @@ -70,45 +77,54 @@ def sleeping_board(user: UserInfo):
@app.route("/sleeping_board", methods=["POST"])
@needs_auth
def sleeping_board_post(user: UserInfo):
read_value = next(iter(request.form.keys())).split('-')
read_value = next(iter(request.form.keys())).split("-")
sleeptype = read_value[1]
if read_value[0] == 'join':
tent_id = uuid.UUID(request.form.get('join-tent-id'))
if read_value[0] == "join":
tent_id = uuid.UUID(request.form.get("join-tent-id"))
join_tent(tents[tent_id], user)
return redirect('/sleeping_board', code=302)
if read_value[0] == 'leave':
tent_id = uuid.UUID(request.form.get('leave-tent-id'))
return redirect("/sleeping_board", code=302)
if read_value[0] == "leave":
tent_id = uuid.UUID(request.form.get("leave-tent-id"))
leave_tent(tents[tent_id], user)
return redirect('/sleeping_board', code=302)
return redirect("/sleeping_board", code=302)
new_uuid = uuid.uuid4()
match sleeptype:
case "hammock":
if user.occupying_uuid is not None:
return redirect('/sleeping_board', code=302)
return redirect("/sleeping_board", code=302)
while new_uuid in hammocks.keys():
new_uuid = uuid.uuid4()
add_hammock(Hammock(uuid=new_uuid, name=request.form.get('new-hammock-name'), occupant=user))
add_hammock(
Hammock(
uuid=new_uuid,
name=request.form.get("new-hammock-name"),
occupant=user,
)
)
user.occupying_uuid = new_uuid
update_user(user)
case "tent":
while new_uuid in tents.keys():
new_uuid = uuid.uuid4()
add_tent(Tent(
uuid=new_uuid,
name=request.form.get("new-tent-name"),
capacity=int(request.form.get("new-tent-cap")),
))
add_tent(
Tent(
uuid=new_uuid,
name=request.form.get("new-tent-name"),
capacity=int(request.form.get("new-tent-cap")),
)
)
case _:
print("SOMEONE FUCKED UP AND IT'S NOT A TENT OR HAMMOCK")
return redirect('/sleeping_board', code=302)
return redirect('/sleeping_board', code=302)
return redirect("/sleeping_board", code=302)
return redirect("/sleeping_board", code=302)


@app.route("/profile")
@needs_auth
def profiles(user: UserInfo):
return render_template("profiles.html", title="Profile", user=user)


@app.route("/profile/edit", methods=["POST"])
@needs_auth
def profile_edit(user: UserInfo):
Expand All @@ -124,9 +140,12 @@ def profile_edit(user: UserInfo):
user.diet = v
case "health":
user.health = v
case "in_ride_toggle":
user.in_ride = not user.in_ride
case _:
return redirect("/profile", code=302)
update_user(user)
return redirect('/profile', code=302)
return redirect("/profile", code=302)


init_db()
16 changes: 12 additions & 4 deletions fcwebapp/templates/profiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@
<form class="form-inline" action="/profile/edit" method="POST">
<label for="phone_number">Update/Add Number</label>
<input class="form-control" type="text" id="phone_number" name="phone_number"
placeholder="123-456-7890">
placeholder="123-456-7890">
<button class="text-primary form-control material-icons-outlined" type="submit">assignment
</button>
</form>
<div class="user-data"><span>Email: </span>{{ user.email }}</div>
<div class="user-data"><span>In Sleeping Board? </span>{{ user.occupying_uuid != None }}</div>
<div class="user-data"><span>In Ride Board? </span>{{ user.in_ride }}</div>
<form action="/profile/edit" method="POST">
<input type="checkbox" name="in_ride_toggle" value={{"off" if user.in_ride else "on" }} <input
class="form-control" type="checkbox" id="in_ride_toggle" name="in_ride_toggle" value="on"
onchange="this.form.submit()">
</form>
</div>
</div>
</div>
Expand All @@ -40,11 +45,14 @@
<div class="card-body">
<form action="/profile/edit" method="POST">
<div class="user-data"><span>Dietary Restrictions? </span></div>
<input type="text" name="diet" placeholder="(comma seperated)" value="{{ user.diet if user.diet else '' }}">
<input type="text" name="diet" placeholder="(comma seperated)"
value="{{ user.diet if user.diet else '' }}">
<div class="user-data"><span>Allergies? </span></div>
<input type="text" id="allergies" name="allergies" placeholder="(comma seperated)" value="{{ user.allergies if user.allergies else '' }}">
<input type="text" id="allergies" name="allergies" placeholder="(comma seperated)"
value="{{ user.allergies if user.allergies else '' }}">
<div class="user-data"><span>Health? </span></div>
<input type="text" id="health" name="health" placeholder="(Diabetic, Asthma, etc)" value="{{ user.health if user.health else '' }}">
<input type="text" id="health" name="health" placeholder="(Diabetic, Asthma, etc)"
value="{{ user.health if user.health else '' }}">
<button type="submit">Submit Info</button>
</form>
</div>
Expand Down