Skip to content

Commit 8124354

Browse files
committed
Process CD Covers seperatly
1 parent 81ef406 commit 8124354

File tree

17 files changed

+96
-70
lines changed

17 files changed

+96
-70
lines changed

library_db/library.db

0 Bytes
Binary file not shown.

library_db/routes/auth/auth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def ret_error(error: str):
5353
return redirect(request.args.get("next", "/"))
5454

5555

56-
@auth_bluep.route("/signin", methods=["GET", "POST"])
57-
def signin():
56+
@auth_bluep.route("/signup", methods=["GET", "POST"])
57+
def signup():
5858
template_vars = get_template_vars(session)
5959
if request.method == "GET":
60-
return render_template("auth/signin.html", **template_vars)
60+
return render_template("auth/signup.html", **template_vars)
6161

6262
def ret_error(error: str):
63-
return render_template("auth/signin.html", error=error, **template_vars)
63+
return render_template("auth/signup.html", error=error, **template_vars)
6464

6565
try:
6666
email = request.form["email"]

library_db/routes/auth/templates/auth/login.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
value="Submit"
5959
class="form-control"
6060
/>
61+
<span class="mt-1">No Account? Signup <a href="{{url_for('auth_bluep.signup')}}">here</a></span>
6162
</form>
6263
</div>
6364
{% endblock %}

library_db/routes/auth/templates/auth/signin.html renamed to library_db/routes/auth/templates/auth/signup.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "base.html"%} {% block title %} Signin {% endblock %} {% block head
1+
{% extends "base.html"%} {% block title %} SignUp {% endblock %} {% block head
22
%} {{ super() }}
33
<style>
44
{% if darkmode %}
@@ -29,7 +29,7 @@
2929
class="position-absolute top-50 start-50 translate-middle sign-in-container"
3030
>
3131
<form
32-
action="/signin"
32+
action="{{url_for('auth_bluep.signup')}}"
3333
method="post"
3434
id="form"
3535
class="rounded bg-light p-3 d-flex flex-column {%if darkmode%} bg-dark text-white {% else %} shadow-lg border {% endif%}"

library_db/routes/general/templates/general/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<div class="d-flex flex-column">
7474
<div class="d-flex flex-column align-self-center">
7575
<span class="display-4"
76-
><img src="/static/images/books.png" alt="books emoticon" /> SQL
76+
><img src="{{url_for('static', filename='images/books.png')}}" alt="books emoticon" /> SQL
7777
Library</span
7878
>
7979
<span class="text-muted sub-title"
@@ -88,7 +88,7 @@
8888
>
8989
<button
9090
class="btn btn-primary mt-3"
91-
onclick="window.location.pathname = '/medialist'"
91+
onclick="window.location.pathname = '{{url_for('media_bluep.show_medialist')}}'"
9292
>
9393
Medialist
9494
</button>
@@ -118,15 +118,15 @@
118118
{%else%}
119119
<button
120120
class="btn btn-outline-primary mt-3"
121-
onclick="window.location.pathname = '/login'"
121+
onclick="window.location.pathname = '{{url_for('auth_bluep.login')}}'"
122122
>
123123
Login
124124
</button>
125125
<button
126126
class="btn btn-outline-primary mt-3"
127-
onclick="window.location.pathname = '/signin'"
127+
onclick="window.location.pathname = '{{url_for('auth_bluep.signup')}}'"
128128
>
129-
Signin
129+
SignUp
130130
</button>
131131
{%endif%}
132132
</div>
@@ -138,7 +138,7 @@
138138
<img
139139
id="header-image"
140140
class="rounded img-fluid shadow-lg"
141-
src="/static/images/library.webp"
141+
src="{{url_for('static', filename='images/library.webp')}}"
142142
alt="picture of library"
143143
/>
144144
</div>

library_db/routes/panel/admin/templates/admin/user_mng.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ <h5 for="mediaSearch" class="{%if darkmode %} text-white {%endif%}">
131131
>
132132
Create new Admin/Staff Account
133133
</h5>
134-
<a href="{{url_for('auth_bluep.signin')}}">
134+
<a href="{{url_for('auth_bluep.signup')}}">
135135
<div class="d-flex flex-column">
136136
<button class="btn btn-primary">Create</button>
137137
</div></a

library_db/routes/panel/staff/staff.py

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
is_admin,
1818
is_staff,
1919
process_cover_image,
20+
process_cd_cover,
2021
download_image
2122
)
2223
from library_db.utils.db_utils import (
@@ -38,7 +39,7 @@
3839

3940

4041

41-
ALLOWED_EXTENSIONS = {'.png', '.jpg', '.jpeg'}
42+
ALLOWED_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.webp'}
4243

4344
def allowed_file(filename):
4445
return Path(filename).suffix in ALLOWED_EXTENSIONS
@@ -115,17 +116,17 @@ def ret_error(error: str):
115116
return ret_error("Bad Form Data")
116117

117118
media = get_media(id)
118-
119+
119120
if not media:
120121
return ret_error("Bad Form Data")
121-
122+
122123
if not media.title == title:
123124
media_title_id = get_media_id(title)
124125
if media_title_id:
125126
return ret_error("Media With this Title already exsists")
126-
127-
if not age_limit:
128-
return ret_error("Bad Form Data")
127+
128+
if age_limit is None:
129+
age_limit = 0
129130

130131
if not media_type in get_media_types():
131132
return ret_error("Media Type doesnt exsist")
@@ -226,26 +227,6 @@ def ret_error(error: str):
226227
except KeyError:
227228
return ret_error("Bad Form Data")
228229

229-
filename = None
230-
if "image" in request.files or "url" in request.form:
231-
file = request.files["image"]
232-
url = request.form["url"]
233-
filename = uuid.uuid1().hex + ".jpg"
234-
save_path = Path(current_app.config['UPLOAD_FOLDER']).joinpath(filename).__str__()
235-
236-
if file.filename != '' and url != '':
237-
return ret_error("Can't upload Image and use Scraper Image")
238-
elif not file.filename == '' and allowed_file(file.filename):
239-
file.save(save_path)
240-
process_cover_image(save_path)
241-
elif not url == '':
242-
if download_image(url, save_path) != 1:
243-
filename = None
244-
else:
245-
process_cover_image(save_path)
246-
else:
247-
filename = None
248-
249230
if isbn:
250231
try:
251232
isbn = int(isbn)
@@ -261,18 +242,44 @@ def ret_error(error: str):
261242
if not media_type in get_media_types():
262243
return ret_error("Media Type doesnt exsist")
263244

264-
media_type = get_media_type_id(media_type)
245+
media_type_id = get_media_type_id(media_type)
265246

266247
if not author_exsists(author):
267248
return ret_error("Author does not exsist")
268249

269-
author = get_author_id(author)
250+
author_id = get_author_id(author)
251+
252+
filename = None
253+
if "image" in request.files or "url" in request.form:
254+
file = request.files["image"]
255+
url = request.form["url"]
256+
filename = uuid.uuid1().hex + ".jpg"
257+
save_path = Path(current_app.config['UPLOAD_FOLDER']).joinpath(filename).__str__()
258+
259+
if file.filename != '' and url != '':
260+
return ret_error("Can't upload Image and use Scraper Image")
261+
elif not file.filename == '' and allowed_file(file.filename):
262+
file.save(save_path)
263+
if media_type == "CD":
264+
process_cd_cover(save_path)
265+
else:
266+
process_cover_image(save_path)
267+
elif not url == '':
268+
if download_image(url, save_path) != 1:
269+
filename = None
270+
else:
271+
if media_type == "CD":
272+
process_cd_cover(save_path)
273+
else:
274+
process_cover_image(save_path)
275+
else:
276+
filename = None
270277

271278
new_id = add_media_item(
272279
title=title,
273-
author_id=author,
280+
author_id=author_id,
274281
age_limit=age_limit,
275-
media_type_id=media_type,
282+
media_type_id=media_type_id,
276283
isbn=isbn,
277284
image=filename
278285
)

library_db/routes/panel/staff/templates/staff/alter.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ <h5 class="underlined {%if darkmode %} text-white {%endif%}">
155155
id="mediaAuthorSearch"
156156
autocomplete="off"
157157
name="author"
158-
value="{{media_item.author if media_item.author}}"
158+
value="{{media_item.author}}"
159159
/>
160160
<ul
161161
class="list-group d-none"
@@ -176,7 +176,7 @@ <h5 class="underlined {%if darkmode %} text-white {%endif%}">
176176
name="age_limit"
177177
placeholder="0"
178178
autocomplete="off"
179-
value="{{media_item.age_limit if media_item.age_limit}}"
179+
value="{{media_item.age_limit}}"
180180
/>
181181
</div>
182182
<div class="d-flex flex-column flex-fill ms-1">
@@ -204,7 +204,7 @@ <h5 class="underlined {%if darkmode %} text-white {%endif%}">
204204
name="isbn"
205205
placeholder="Optional"
206206
autocomplete="off"
207-
value="{{media_item.isbn if media_item.isbn}}"
207+
value="{{media_item.isbn}}"
208208
/>
209209
<div class="d-flex flex-fill">
210210
<div>

library_db/static/css/skeleton.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.
Loading

0 commit comments

Comments
 (0)