Spaces:
Running
Running
check if the URL or dataset name already exists to avoid duplication
Browse files
app.py
CHANGED
@@ -98,6 +98,14 @@ def submit_entry(
|
|
98 |
errors.append("Approximate size must be a non-negative number.")
|
99 |
if not field.strip():
|
100 |
errors.append("Please provide a field.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
if errors:
|
103 |
return gr.update(value=f"Submission failed:\n- " + "\n- ".join(errors), visible=True), gr.update(visible=False)
|
|
|
98 |
errors.append("Approximate size must be a non-negative number.")
|
99 |
if not field.strip():
|
100 |
errors.append("Please provide a field.")
|
101 |
+
|
102 |
+
# Check for existing dataset URL and name
|
103 |
+
existing_records = read_all_records()
|
104 |
+
for record in existing_records:
|
105 |
+
if record.get("dataset_url", "").strip().lower() == dataset_url.strip().lower():
|
106 |
+
errors.append(f"Dataset URL already exists: {record.get('dataset_url')}")
|
107 |
+
if record.get("dataset_name", "").strip().lower() == dataset_name.strip().lower():
|
108 |
+
errors.append(f"Dataset name already exists: {record.get('dataset_name')}")
|
109 |
|
110 |
if errors:
|
111 |
return gr.update(value=f"Submission failed:\n- " + "\n- ".join(errors), visible=True), gr.update(visible=False)
|