roundabout,
created on Sunday, 8 September 2024, 06:17:04 (1725776224),
received on Sunday, 8 September 2024, 10:58:33 (1725793113)
Author identity: vlad <vlad.muntoiu@gmail.com>
6ed0b4d01389a79f122b1c32b023c50991ab539b
app.py
@@ -13,6 +13,7 @@ from jinja2_fragments.flask import render_block
from sqlalchemy.orm import backref import sqlalchemy.dialects.postgresql from os import path import osfrom urllib.parse import urlencode import mimetypes import ruamel.yaml as yaml
@@ -627,6 +628,33 @@ def edit_picture_post(id):
return flask.redirect("/picture/" + str(resource.id)) @app.route("/picture/<int:id>/copy") def copy_picture(id): resource = db.session.get(PictureResource, id) if resource is None: flask.abort(404) current_user = db.session.get(User, flask.session.get("username")) if current_user is None: flask.abort(401) new_resource = PictureResource(resource.title, current_user, resource.description, resource.origin_url, [licence.licence_id for licence in resource.licences], resource.file_format, resource.nature) for region in resource.regions: db.session.add(PictureRegion(region.json, new_resource, region.object)) db.session.commit() # Create a hard link for the new picture old_path = path.join(config.DATA_PATH, "pictures", str(resource.id)) new_path = path.join(config.DATA_PATH, "pictures", str(new_resource.id)) os.link(old_path, new_path) return flask.redirect("/picture/" + str(new_resource.id)) @app.route("/query-pictures", methods=["POST"]) # sadly GET can't have a body def query_pictures(): offset = int(flask.request.args.get("offset", 0))
templates/upload.html
@@ -3,7 +3,7 @@
{% block content %} <x-frame style="--width: 768px"> <form method="POST" class="vbox" enctype="multipart/form-data"> <h2>Upload</h2><h1>Upload a picture</h1><label> <span class="required-asterisk">Title</span> <input type="text" name="title" required>