Skip to content

Commit

Permalink
make add-media route
Browse files Browse the repository at this point in the history
  • Loading branch information
amir-kedis committed Sep 4, 2022
1 parent 6786944 commit 0945d83
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
41 changes: 41 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from tempfile import mkdtemp
from werkzeug.security import check_password_hash, generate_password_hash
from functools import wraps
import datetime

# ----------------------------------
# ------: configurations
Expand Down Expand Up @@ -175,6 +176,46 @@ def addMedia():
if request.method == "GET":
return render_template("add_media.html")

# User reached route via POST (as by submitting a form via POST)
else:
user_id = session["user_id"]
mediaName = request.form.get("media_name")
status = request.form.get("status")
type = request.form.get("type")
img = request.form.get("img")

# ensure user provide Media Name
if not mediaName:
return apology("Must Provide Media Name")

# ensure user provide Media Name
if not status:
return apology("Must Provide Status")

# ensure user provide Media Name
if not type:
return apology("Must Provide Type")

# if user provided no media put it to NULL
if not img:
return apology("Must Provide Image")

# get date
date = date = datetime.datetime.now()

# insert into database
db.execute("INSERT INTO media (user_id, name, type, status, img, date) VALUES (?,?,?,?,?,?)",
user_id,
mediaName,
type,
status,
img,
date)

# redirect the user to add again
return redirect("/add_media")


# edit_list route
@app.route("/edit_list")
@login_required
Expand Down
Binary file added flask_session/7576e729405c88cddc152f8f80900e39
Binary file not shown.
Binary file removed flask_session/b7b4e18ceb42c0c65186641fc5b873ff
Binary file not shown.
Binary file modified media.db
Binary file not shown.
2 changes: 1 addition & 1 deletion static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ template {

:root {
--bgc: #111116;
--navbgc: #505050;
--navbgc: #211372;
--txtc: #FFFFFF;
--form-bgc: #242631;
--btn-bgc: #3D24D6;
Expand Down
2 changes: 1 addition & 1 deletion static/sass/global/_colors.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:root {
--bgc: #111116;
--navbgc: #505050;
--navbgc: #211372;
--txtc: #FFFFFF;
--form-bgc: #242631;
--btn-bgc: #3D24D6;
Expand Down

0 comments on commit 0945d83

Please sign in to comment.