Fixed browser profile bug, line breaks and exceptions in news_check
This commit is contained in:
@@ -34,12 +34,14 @@
|
||||
{#each status_items as item}
|
||||
<tr>
|
||||
<td>{ item.name }</td>
|
||||
{#if (item.value != "" || status_items.valze == false) }
|
||||
{#if item.name == "Url"}
|
||||
<td class='bg-emerald-200'><a href="{ item.value }" target="_blank">{ item.value }</a></td>
|
||||
{:else}
|
||||
<td class='bg-emerald-200' style="white-space: normal; width:70%">{ item.value }</td>
|
||||
{/if}
|
||||
{#if (item.value != "" || status_items.value == false) }
|
||||
<td class='bg-emerald-200' style="white-space: normal; width:70%">
|
||||
{#if item.name == "Url"}
|
||||
<a href="{ item.value }" target="_blank">{ item.value }</a>
|
||||
{:else}
|
||||
{ item.value }
|
||||
{/if}
|
||||
</td>
|
||||
{:else}
|
||||
<td class='bg-red-200'>not set</td>
|
||||
{/if}
|
||||
|
||||
@@ -53,11 +53,14 @@ def get_article_next(id):
|
||||
|
||||
@app.route("/api/article/<int:id>/set", methods=['POST'])
|
||||
def set_article(id):
|
||||
try:
|
||||
action = request.json.get('action', None)
|
||||
except Exception as e:
|
||||
print(f"Exception in set_article {e}")
|
||||
json = request.get_json(silent=True) # do not raise 400 if there is no json!
|
||||
# no json usually means a file was uploaded
|
||||
if json is None:
|
||||
print("Detected likely file upload.")
|
||||
action = None
|
||||
else:
|
||||
action = request.json.get('action', None) # action inside the json might still be empty
|
||||
|
||||
with db:
|
||||
article = models.ArticleDownload.get_by_id(id)
|
||||
if action:
|
||||
@@ -66,7 +69,7 @@ def set_article(id):
|
||||
elif action == "b":
|
||||
article.verified = -1
|
||||
else: # implicitly action == "r":
|
||||
print(request.files)
|
||||
# request.files is an immutable dict
|
||||
file = request.files.get("file", None)
|
||||
if file is None: # upload tends to crash
|
||||
return "No file uploaded", 400
|
||||
@@ -74,7 +77,7 @@ def set_article(id):
|
||||
artname, _ = os.path.splitext(article.file_name)
|
||||
fname = f"{artname} -- related_{article.related.count() + 1}.{file.filename.split('.')[-1]}"
|
||||
fpath = os.path.join(article.save_path, fname)
|
||||
print(fpath)
|
||||
print(f"Saving file to {fpath}")
|
||||
file.save(fpath)
|
||||
article.set_related([fname])
|
||||
return {"file_path": fpath}
|
||||
|
||||
Reference in New Issue
Block a user