diff --git a/scipaperloader/blueprints/upload.py b/scipaperloader/blueprints/upload.py index a6d9a9a..56173ad 100644 --- a/scipaperloader/blueprints/upload.py +++ b/scipaperloader/blueprints/upload.py @@ -22,6 +22,7 @@ from flask import ( from ..db import db from ..models import PaperMetadata, ActivityLog from ..celery import celery # Import the celery instance directly +from ..defaults import DUPLICATE_STRATEGIES bp = Blueprint("upload", __name__) @@ -55,10 +56,10 @@ def upload(): return jsonify({"task_id": task.id}) - return render_template("upload.html.jinja") + return render_template("upload.html.jinja", duplicate_strategies=DUPLICATE_STRATEGIES) @celery.task(bind=True) -def process_csv(self, file_content, delimiter, duplicate_strategy): +def process_csv(self, file_content, delimiter, duplicate_strategy="skip"): """Process CSV file and import paper metadata.""" # With the ContextTask in place, we're already inside an app context diff --git a/scipaperloader/defaults.py b/scipaperloader/defaults.py index b0c12d1..d1955d7 100644 --- a/scipaperloader/defaults.py +++ b/scipaperloader/defaults.py @@ -1 +1,22 @@ DEBUG = False # make sure DEBUG is off unless enabled explicitly otherwise + +# Define duplicate handling strategies with descriptions for the UI +DUPLICATE_STRATEGIES = { + "skip": { + "name": "Skip duplicates", + "description": "Skip papers that already exist in the database", + "is_default": True + }, + "update": { + "name": "Update duplicates", + "description": "Update existing papers with new metadata", + "is_default": False + }, + # Add new strategies here, they will automatically appear in the UI + # Example: + # "merge": { + # "name": "Merge duplicates", + # "description": "Merge new data with existing data, keeping both values", + # "is_default": False + # } +} diff --git a/scipaperloader/templates/upload.html.jinja b/scipaperloader/templates/upload.html.jinja index 48d2ed9..cec9178 100644 --- a/scipaperloader/templates/upload.html.jinja +++ b/scipaperloader/templates/upload.html.jinja @@ -58,6 +58,16 @@ +
+ + +