roundabout,
created on Thursday, 5 September 2024, 13:20:19 (1725542419),
received on Thursday, 5 September 2024, 13:52:29 (1725544349)
Author identity: vlad <vlad.muntoiu@gmail.com>
4e1698759a27f908161182a5af5f443a700e110c
app.py
@@ -300,7 +300,10 @@ def upload():
return flask.redirect("/accounts")
licences = Licence.query.order_by(Licence.free.desc(), Licence.pinned.desc(), Licence.title).all()
return flask.render_template("upload.html", licences=licences)
types = PictureNature.query.all()
return flask.render_template("upload.html", licences=licences, types=types)
@app.route("/upload", methods=["POST"])
@@ -310,6 +313,7 @@ def upload_post():
origin_url = flask.request.form["origin_url"]
author = db.session.get(User, flask.session.get("username"))
licence_ids = flask.request.form.getlist("licence")
nature_id = flask.request.form["nature"]
if author is None:
flask.abort(401)
@@ -329,10 +333,11 @@ def upload_post():
return flask.redirect(flask.request.url)
if not description:
flask.flash("Enter a description")
return flask.redirect(flask.request.url)
description = ""
print(licence_ids)
if not nature_id:
flask.flash("Select a picture type")
return flask.redirect(flask.request.url)
if not licence_ids:
flask.flash("Select licences")
@@ -343,7 +348,8 @@ def upload_post():
flask.flash("Select at least one free licence")
return flask.redirect(flask.request.url)
resource = PictureResource(title, author, description, origin_url, ["CC0-1.0"], file.mimetype)
resource = PictureResource(title, author, description, origin_url, ["CC0-1.0"], file.mimetype,
db.session.get(PictureNature, nature_id))
db.session.add(resource)
db.session.commit()
file.save(path.join(config.DATA_PATH, "pictures", str(resource.id)))
basic_rows.py
@@ -1,4 +1,4 @@
from app import Licence, PictureObject, db
from app import Licence, PictureObject, PictureNature, db
# Prefix non-SPDX licences with "X-"
# Order of licences is:
@@ -546,12 +546,12 @@ def add_licences():
def add_objects():
objects = [
PictureObject(
"Cat (Felis catus)",
"Domestic cat",
"Cat (Felis catus)",
"Domestic cat",
),
PictureObject(
"Dandelion (Taraxacum officinale)",
"Common dandelion",
"Dandelion (Taraxacum officinale)",
"Common dandelion",
),
]
@@ -559,3 +559,44 @@ def add_objects():
db.session.add(object)
db.session.commit()
def add_natures():
natures = [
PictureNature("photo", "Photograph taken with a camera, but not a photograph of "
"a painting or another photograph. Should be substantially "
"unaltered, except for cropping, rotation, perspective correction, "
"colour changes, sharpness-related changes, and other minor "
"retouching that keeps the content unchanged"),
PictureNature("document-scan", "Scan of a document, drawing, chart, map, or other "
"non-photographic, non-visually artistic work"),
PictureNature("2d-art", "Photograph or scan of a 2D visual artwork, such as a painting, "
"which only reproduces the work itself without spatial elements"),
PictureNature("screen-capture", "Screenshot of a computer graphical user interface, generated "
"by the same device or another device such as a capture card "
"but not photographed"),
PictureNature("screen-photo", "Photograph of a computer screen or other digital display"),
PictureNature("computer-2d-art", "2D digital artwork created on a computer or other device "
"using a drawing or painting program"),
PictureNature("computer-3d-art", "Render of a digital 3D model"),
PictureNature("computer-graph", "A basic digital graphic such as a chart, diagram, flowchart, "
"or other simple visual representation"),
PictureNature("text", "Computer-generated image of simple text"),
PictureNature("logo", "An icon, pictogram or logo which isn't just text"),
PictureNature("map", "A digital map"),
PictureNature("wordmark", "Stylised text, wordmark or monogram"),
PictureNature("video-game", "Screenshot of a video game"),
PictureNature("photo-composite", "Composite photograph made from multiple photographs or "
"a heavily altered photograph"),
PictureNature("photo-panorama", "Panoramic or spherical photograph stitched from multiple"
" photographs"),
PictureNature("pattern", "Very basic repeating pattern or texture"),
PictureNature("ai", "Artificial intelligence-generated image, regardless of style"),
PictureNature("other", "Other type of image — please specify in the description and ask "
"for your type to be added to the list"),
]
for nature in natures:
db.session.add(nature)
db.session.commit()
static/style.css
@@ -218,7 +218,7 @@ iconify-icon {
}
*/
.multi-select {
.multi-select, .single-select {
display: flex;
flex-flow: column nowrap;
overflow-y: scroll;
@@ -227,17 +227,17 @@ iconify-icon {
gap: 8px;
}
.licence-selection {
.licence-selection, .image-type-selection {
display: flex;
flex-flow: column nowrap;
}
.licence-selection-info {
.licence-selection-info, .image-type-selection-info {
margin-left: calc(var(--size-checkbox) + var(--gap-label-checkbox));
/* Align with the checkbox above */
}
.licence-selection-info > p {
.licence-selection-info > p, .image-type-selection-info > p {
font-weight: 300;
}
@@ -247,13 +247,13 @@ iconify-icon {
margin-left: 1ch;
}
.licence-title {
.licence-title, .image-type-title {
display: flex;
justify-content: space-between;
width: 100%;
}
.licence-title > .licence-name {
.licence-title > .licence-name, .image-type-title > .image-type-name {
font: var(--h5-font);
font-weight: 400;
}
templates/upload.html
@@ -9,9 +9,29 @@
<input type="text" name="title" required>
</label>
<label>
<span class="required-asterisk">Description</span>
<textarea name="description" required></textarea>
Description
<textarea name="description"></textarea>
</label>
<x-vbox>
<span class="required-asterisk">Picture type</span>
<div class="single-select" style="height: clamp(320px, 25vh, 640px)">
{% for type in types %}
<div class="image-type-selection">
<label>
<input name="nature" type="radio" value="{{ type.id }}" required>
<span class="image-type-title">
<span class="image-type-name">
{{ type.id }}
</span>
</span>
</label>
<div class="image-type-selection-info">
<p>{{ type.description | safe }}</p>
</div>
</div>
{% endfor %}
</div>
</x-vbox>
<label>
Origin URL
<input type="url" name="origin_url">
@@ -32,6 +52,7 @@
{% endif %}
<span class="licence-title">
<span class="licence-name">
[{{ licence.id }}]
{{ licence.title }}
</span>