Merge pull request #2 from partitioncloud/dev

This commit is contained in:
Augustin 2023-09-02 11:42:03 +02:00 committed by GitHub
commit 85c2740f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 4 deletions

View File

@ -232,6 +232,7 @@ def add_partition(album_uuid):
db = get_db() db = get_db()
user = User(user_id=session.get("user_id")) user = User(user_id=session.get("user_id"))
album = Album(uuid=album_uuid) album = Album(uuid=album_uuid)
source = "upload" # source type: upload, unknown or url
if (not user.is_participant(album.uuid)) and (user.access_level != 1): if (not user.is_participant(album.uuid)) and (user.access_level != 1):
flash("Vous ne participez pas à cet album.") flash("Vous ne participez pas à cet album.")
@ -256,6 +257,8 @@ def add_partition(album_uuid):
).fetchone() ).fetchone()
if data is None: if data is None:
error = "Les résultats de la recherche ont expiré." error = "Les résultats de la recherche ont expiré."
else:
source = data["url"]
else: else:
partition_type = "file" partition_type = "file"
@ -278,10 +281,10 @@ def add_partition(album_uuid):
db.execute( db.execute(
""" """
INSERT INTO partition (uuid, name, author, body, user_id) INSERT INTO partition (uuid, name, author, body, user_id, source)
VALUES (?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?)
""", """,
(partition_uuid, request.form["name"], author, body, user.id), (partition_uuid, request.form["name"], author, body, user.id, source),
) )
db.commit() db.commit()

View File

@ -314,6 +314,7 @@ class Partition():
self.author = data["author"] self.author = data["author"]
self.body = data["body"] self.body = data["body"]
self.user_id = data["user_id"] self.user_id = data["user_id"]
self.source = data["source"]
else: else:
raise LookupError raise LookupError

View File

@ -17,7 +17,8 @@ CREATE TABLE partition (
name TEXT NOT NULL, name TEXT NOT NULL,
author TEXT, author TEXT,
body TEXT, body TEXT,
user_id INTEGER user_id INTEGER,
source TEXT DEFAULT 'unknown'
); );
CREATE TABLE album ( CREATE TABLE album (

View File

@ -603,6 +603,7 @@ table {
} }
td { td {
height: 35px; /* will grow automatically */
min-width: 178px; min-width: 178px;
border: thin solid var(--color-surface0); border: thin solid var(--color-surface0);
text-align: center; text-align: center;

View File

@ -24,6 +24,18 @@
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
<tr>
<td>
Type d'ajout
</td>
<td>
{% if partition.source == "unknown" or partition.source == "upload" %}
{{ partition.source }}
{% else %}
<a href="{{ partition.source }}">search</a>
{% endif %}
</td>
</tr>
<tr> <tr>
<td> <td>
Albums Albums

View File

@ -13,6 +13,16 @@
<td>Fichier</td> <td>Fichier</td>
<td><a href="/partition/{{ partition.uuid }}"><img class="partition-thumbnail" src="/static/thumbnails/{{ partition.uuid }}.jpg"></a></td> <td><a href="/partition/{{ partition.uuid }}"><img class="partition-thumbnail" src="/static/thumbnails/{{ partition.uuid }}.jpg"></a></td>
</tr> </tr>
{% if partition.source != "unknown" and partition.source != "upload" %}
<tr>
<td>
Source
</td>
<td class="partition-source">
<a href="{{ partition.source }}">{{ partition.source.split("/")[2] }}</a>
</td>
</tr>
{% endif %}
<tr> <tr>
<td>Titre</td> <td>Titre</td>
<td><input name="name" type="text" value="{{ partition.name }}" placeholder="Titre" required /><br/></td> <td><input name="name" type="text" value="{{ partition.name }}" placeholder="Titre" required /><br/></td>