From 9d9d68e8d4d0b8749446c11f47220c6de59d3b7d Mon Sep 17 00:00:00 2001 From: Alex Danamir Date: Fri, 11 Nov 2022 18:48:50 +0300 Subject: [PATCH] add requirements.txt --- app.py | 75 +++++++++++++++++++++++++++++++++++++- requirements.txt | Bin 0 -> 664 bytes static/css/style.css | 4 ++ templates/cardupdate.html | 40 ++++++++++++++++++++ templates/editcard.html | 48 ++++++++++++++++++++++++ 5 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 requirements.txt create mode 100644 templates/cardupdate.html create mode 100644 templates/editcard.html diff --git a/app.py b/app.py index c1f3308..d0c90ec 100644 --- a/app.py +++ b/app.py @@ -87,14 +87,87 @@ def upload_file(): stl=stl_file.filename, src=src_file.filename, isprinted=isprinered, - dateadd=datetime.now().strftime('%d.%m.%Y')) + datead=datetime.now().strftime('%d.%m.%Y')) db.session.add(detal) db.session.commit() return redirect(url_for('admipage')) +@app.route('/editcard') +def editcadrd(): + allDetals = {} + detalsQuery = PrintedDetal.query.all() + + for detal in detalsQuery: + detals = {} + detals['id'] = detal.id + detals['img'] = detal.img + detals['stl'] = detal.stl + detals['src'] = detal.src + detals['isprinted'] = detal.isprinted + detals['date'] = detal.dateadd + + allDetals[detal.id] = detals + return render_template('editcard.html', detals=allDetals) + + +@app.route('/editcard/') +def editcard2(id): + data = PrintedDetal.query.get(id) + print(data.id) + return render_template('cardupdate.html', data=data.id) + + +@app.route('/updater', methods=['POST']) +def updater(): + + if request.method == 'POST': + id = request.form.get('dataid') + detal = PrintedDetal.query.get(id) + + image_file = request.files['img'] + stl_file = request.files['stl'] + src_file = request.files['src'] + + print(detal.id) + + if len(image_file.filename) > 0: + filename = image_file.filename.split('.') + image_file.filename = secrets.token_hex(15) + '.' + filename[-1] + image_file.save(os.path.join( + app.config['UPLOAD_IMG_FOLDER'], image_file.filename)) + detal.img = image_file.filename + + if len(stl_file.filename) > 0: + filename = stl_file.filename.split('.') + stl_file.filename = secrets.token_hex(15) + '.' + filename[-1] + stl_file.save(os.path.join( + app.config['UPLOAD_STL_FOLDER'], stl_file.filename)) + detal.stl = stl_file.filename + + if len(src_file.filename) > 0: + filename = src_file.filename.split('.') + src_file.filename = secrets.token_hex(15) + '.' + filename[-1] + src_file.save(os.path.join( + app.config['UPLOAD_SRC_FOLDER'], src_file.filename)) + detal.src = src_file.filename + + if request.form.get('isprinted') == 'on': + isprinered = True + else: + isprinered = False + + detal.isprinted = isprinered + db.session.commit() + + return redirect(url_for('editcadrd')) + + + + + return "123" if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..7da6c08ef289c78fa4b6d8a3dd2bbd265747dd50 GIT binary patch literal 664 zcmZ{iOHTqp5QOV&;!lCd%izI-7Y{}c1{2OJtbn*I;cr6{DS31SS0JJyvFSd3x)f=0v%({)~1!jTj zl4k=~Nd_5_+;vH#M)!dUYgn<#Cp%7@$GbY5c&^Z#^4kofW=Ebnz~TM|cO}y`dG7=1 z9K0(jehTlOAp6m^pSJtL`Hl>aXqfQ-11@jN9Ldp^EM{z&)3x$bILo-ZV6>P2GW0&* w+_2H)@1hE~nWIf_8gAA)^FHD&Bih?dxjV6{ah&fcsXgO(%j3!9*6b;_U&7yCJOBUy literal 0 HcmV?d00001 diff --git a/static/css/style.css b/static/css/style.css index b60fbb9..b2b7cc3 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -33,6 +33,10 @@ header { height: 450px; } +.card-edit { + height: 400px; +} + .card-img-top{ height: 250px; diff --git a/templates/cardupdate.html b/templates/cardupdate.html new file mode 100644 index 0000000..714ce33 --- /dev/null +++ b/templates/cardupdate.html @@ -0,0 +1,40 @@ + + + + + + + + + + 3d Detals adminka + + + +
+

Обновление карточки {{data['id']}}

+
+
+ +
+
+ + + + + + + + + + +
+
+ + + + + \ No newline at end of file diff --git a/templates/editcard.html b/templates/editcard.html new file mode 100644 index 0000000..06e8819 --- /dev/null +++ b/templates/editcard.html @@ -0,0 +1,48 @@ + + + + + + + + + + 3d Detals + + +
+

Каталог печатных 3д деталей

+
+
+
+ + {% for key, value in detals.items() %} + +
+
+ + +
+ + +
+
+
+
+
+ + {%endfor%} + + + +
+
+ + + + \ No newline at end of file