mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-01-23 09:16:25 +01:00
Option redirect=true pour une recherche en ligne
Modification du schéma sqlite: `ALTER TABLE search_results ADD url TEXT;;`
This commit is contained in:
parent
cd2789e4fc
commit
234e0f784f
@ -3,7 +3,7 @@
|
||||
Partition module
|
||||
"""
|
||||
import os
|
||||
from flask import Blueprint, abort, send_file, render_template
|
||||
from flask import Blueprint, abort, send_file, render_template, request, redirect
|
||||
|
||||
from .db import get_db
|
||||
from .auth import login_required, admin_required
|
||||
@ -38,7 +38,7 @@ def partition_search(uuid):
|
||||
db = get_db()
|
||||
partition = db.execute(
|
||||
"""
|
||||
SELECT * FROM search_results
|
||||
SELECT uuid, url FROM search_results
|
||||
WHERE uuid = ?
|
||||
""",
|
||||
(uuid,)
|
||||
@ -46,6 +46,8 @@ def partition_search(uuid):
|
||||
|
||||
if partition is None:
|
||||
abort(404)
|
||||
if request.args.get("redirect") == "true" and partition["url"] is not None:
|
||||
return redirect(partition["url"])
|
||||
return send_file(os.path.join("search-partitions", f"{uuid}.pdf"))
|
||||
|
||||
|
||||
|
@ -59,10 +59,10 @@ def online_search(query, num_queries):
|
||||
uuid = str(uuid4())
|
||||
db.execute(
|
||||
"""
|
||||
INSERT INTO search_results (uuid)
|
||||
VALUES (?)
|
||||
INSERT INTO search_results (uuid, url)
|
||||
VALUES (?, ?)
|
||||
""",
|
||||
(uuid,)
|
||||
(uuid, element,)
|
||||
)
|
||||
db.commit()
|
||||
urllib.request.urlretrieve(element, f"partitioncloud/search-partitions/{uuid}.pdf")
|
||||
|
@ -39,5 +39,6 @@ CREATE TABLE contient_user (
|
||||
|
||||
CREATE TABLE search_results (
|
||||
uuid TEXT(36) PRIMARY KEY,
|
||||
url TEXT,
|
||||
creation_time TEXT NULL DEFAULT (datetime('now', 'localtime'))
|
||||
);
|
Loading…
Reference in New Issue
Block a user