Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Clémentine
commited on
Commit
·
2ff76cf
1
Parent(s):
d38d1a2
anti spam measures
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import os
|
2 |
import json
|
3 |
import datetime
|
|
|
4 |
from email.utils import parseaddr
|
5 |
|
6 |
import gradio as gr
|
@@ -82,6 +83,13 @@ def add_new_eval(
|
|
82 |
mail: str,
|
83 |
profile: gr.OAuthProfile,
|
84 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
contact_infos = load_dataset(CONTACT_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
86 |
user_submission_dates = sorted(row["date"] for row in contact_infos[val_or_test] if row["username"] == profile.username)
|
87 |
if len(user_submission_dates) > 0 and user_submission_dates[-1] == datetime.datetime.today().strftime('%Y-%m-%d'):
|
|
|
1 |
import os
|
2 |
import json
|
3 |
import datetime
|
4 |
+
import requests
|
5 |
from email.utils import parseaddr
|
6 |
|
7 |
import gradio as gr
|
|
|
83 |
mail: str,
|
84 |
profile: gr.OAuthProfile,
|
85 |
):
|
86 |
+
# Was the profile created less than 2 month ago?
|
87 |
+
user_data = requests.get(f"https://huggingface.co/api/users/{profile.username}/overview")
|
88 |
+
creation_date = json.loads(user_data.content)["createdAt"]
|
89 |
+
if datetime.datetime.now() - datetime.datetime.strptime(creation_date, '%Y-%m-%dT%H:%M:%S.%fZ') < datetime.timedelta(days=60):
|
90 |
+
return format_error("This account is not authorized to submit on GAIA.")
|
91 |
+
|
92 |
+
|
93 |
contact_infos = load_dataset(CONTACT_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
94 |
user_submission_dates = sorted(row["date"] for row in contact_infos[val_or_test] if row["username"] == profile.username)
|
95 |
if len(user_submission_dates) > 0 and user_submission_dates[-1] == datetime.datetime.today().strftime('%Y-%m-%d'):
|