Update app.py
Browse files
app.py
CHANGED
|
@@ -25,14 +25,23 @@ def has_certificate_entry(username):
|
|
| 25 |
|
| 26 |
# Function to add certificate entry
|
| 27 |
def add_certificate_entry(username, name):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
new_entry = {
|
| 29 |
"username": username,
|
| 30 |
"name": name,
|
| 31 |
-
"timestamp": datetime.now().
|
| 32 |
}
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Function to generate certificate PDF
|
| 38 |
def generate_certificate(name, score):
|
|
|
|
| 25 |
|
| 26 |
# Function to add certificate entry
|
| 27 |
def add_certificate_entry(username, name):
|
| 28 |
+
# Load current dataset
|
| 29 |
+
ds = load_dataset(CERTIFICATES_DATASET, split="train", download_mode="force_redownload")
|
| 30 |
+
|
| 31 |
+
# Remove any existing entry with the same username
|
| 32 |
+
filtered_rows = [row for row in ds if row["username"] != username]
|
| 33 |
+
|
| 34 |
+
# Append the updated/new entry
|
| 35 |
new_entry = {
|
| 36 |
"username": username,
|
| 37 |
"name": name,
|
| 38 |
+
"timestamp": datetime.now().isoformat()
|
| 39 |
}
|
| 40 |
+
filtered_rows.append(new_entry)
|
| 41 |
+
|
| 42 |
+
# Rebuild dataset and push
|
| 43 |
+
updated_ds = Dataset.from_list(filtered_rows)
|
| 44 |
+
updated_ds.push_to_hub(CERTIFICATES_DATASET)
|
| 45 |
|
| 46 |
# Function to generate certificate PDF
|
| 47 |
def generate_certificate(name, score):
|