adds option to set paper status when adding dummy papers

This commit is contained in:
Michael Beck 2025-05-23 21:36:41 +02:00
parent 4f0539f4b0
commit 74e713e8a6
3 changed files with 23 additions and 2 deletions

View File

@ -278,6 +278,16 @@ def generate_test_papers():
except (ValueError, TypeError):
paper_count = 100
# Get the status settings
try:
dummy_paper_status = request.form.get("dummy_paper_status")
if dummy_paper_status == "new":
dummy_paper_status = "New"
else:
dummy_paper_status = random.choice(["New","Pending", "Done", "Failed"])
except (ValueError, TypeError):
dummy_paper_status = random.choice(["New","Pending", "Done", "Failed"])
# Get the download path for file paths
download_path = DownloadPathConfig.get_path()
@ -320,7 +330,7 @@ def generate_test_papers():
type=random.choice(paper_types),
language=random.choice(languages),
published_online=pub_date.date(),
status=random.choice(["Pending", "Done", "Failed"]),
status=dummy_paper_status,
file_path=f"{download_path}/test_paper_{i+1}.pdf" if random.random() > 0.3 else None,
error_msg="Download failed: connection timeout" if random.random() < 0.1 else None,
created_at=datetime.now() - timedelta(days=random.randint(0, 30))

View File

@ -33,6 +33,17 @@
<small class="form-text text-muted">Enter a number between 1 and
1000</small>
</div>
</div>
<div class="form-group row">
<label for="dummy_paper_status" class="col-sm-3 col-form-label">Paper
Status:</label>
<div class="col-sm-4">
<select id="dummy_paper_status" class="form-control"
name="dummy_paper_status">
<option value="new">New Only</option>
<option value="mixed-random">Randomly Mixed</option>
</select>
</div>
<div class="col-sm-5">
<button type="submit" class="btn btn-primary">
<i class="fas fa-plus-circle"></i> Generate Test Papers

View File

@ -28,7 +28,7 @@
<div class="container mt-4">
<h1>Configuration</h1>
<ul class="nav nav-pills mb-4">
<ul class="nav nav-pills nav-fill mb-4">
<li class="nav-item">
<a class="nav-link {% if active_tab == 'general' %}active{% endif %}"
href="{{ url_for('config.general') }}">General</a>