Spaces:
Sleeping
Sleeping
“pangjh3”
commited on
Commit
·
3d1e553
1
Parent(s):
ff9e75d
modified: app.py
Browse files
app.py
CHANGED
|
@@ -107,7 +107,7 @@ def check_user_submission_eligibility(profile: gr.OAuthProfile, org_name: str):
|
|
| 107 |
"""Check user submission eligibility"""
|
| 108 |
try:
|
| 109 |
# 1. Check account age limit (60 days)
|
| 110 |
-
user_data = requests.get(f"https://huggingface.co/api/users/{profile.
|
| 111 |
if user_data.status_code == 200:
|
| 112 |
creation_date = json.loads(user_data.content)["createdAt"]
|
| 113 |
account_age = datetime.datetime.now() - datetime.datetime.strptime(creation_date, '%Y-%m-%dT%H:%M:%S.%fZ')
|
|
@@ -119,7 +119,7 @@ def check_user_submission_eligibility(profile: gr.OAuthProfile, org_name: str):
|
|
| 119 |
|
| 120 |
# 2. Check daily submission limit
|
| 121 |
submission_history = load_submission_history()
|
| 122 |
-
user_submissions = submission_history.get(profile.
|
| 123 |
|
| 124 |
today = datetime.datetime.today().strftime('%Y-%m-%d')
|
| 125 |
today_submissions = [s for s in user_submissions if s.get("date", "") == today]
|
|
@@ -143,8 +143,8 @@ def record_user_submission(profile: gr.OAuthProfile, org_name: str, email: str):
|
|
| 143 |
try:
|
| 144 |
submission_history = load_submission_history()
|
| 145 |
|
| 146 |
-
if profile.
|
| 147 |
-
submission_history[profile.
|
| 148 |
|
| 149 |
# Record this submission
|
| 150 |
submission_record = {
|
|
@@ -152,10 +152,10 @@ def record_user_submission(profile: gr.OAuthProfile, org_name: str, email: str):
|
|
| 152 |
"time": datetime.datetime.now().strftime('%H:%M:%S'),
|
| 153 |
"organization": org_name,
|
| 154 |
"email": email,
|
| 155 |
-
"username": profile.
|
| 156 |
}
|
| 157 |
|
| 158 |
-
submission_history[profile.
|
| 159 |
|
| 160 |
# Save submission history
|
| 161 |
return save_submission_history(submission_history)
|
|
|
|
| 107 |
"""Check user submission eligibility"""
|
| 108 |
try:
|
| 109 |
# 1. Check account age limit (60 days)
|
| 110 |
+
user_data = requests.get(f"https://huggingface.co/api/users/{profile.username}/overview")
|
| 111 |
if user_data.status_code == 200:
|
| 112 |
creation_date = json.loads(user_data.content)["createdAt"]
|
| 113 |
account_age = datetime.datetime.now() - datetime.datetime.strptime(creation_date, '%Y-%m-%dT%H:%M:%S.%fZ')
|
|
|
|
| 119 |
|
| 120 |
# 2. Check daily submission limit
|
| 121 |
submission_history = load_submission_history()
|
| 122 |
+
user_submissions = submission_history.get(profile.username, [])
|
| 123 |
|
| 124 |
today = datetime.datetime.today().strftime('%Y-%m-%d')
|
| 125 |
today_submissions = [s for s in user_submissions if s.get("date", "") == today]
|
|
|
|
| 143 |
try:
|
| 144 |
submission_history = load_submission_history()
|
| 145 |
|
| 146 |
+
if profile.username not in submission_history:
|
| 147 |
+
submission_history[profile.username] = []
|
| 148 |
|
| 149 |
# Record this submission
|
| 150 |
submission_record = {
|
|
|
|
| 152 |
"time": datetime.datetime.now().strftime('%H:%M:%S'),
|
| 153 |
"organization": org_name,
|
| 154 |
"email": email,
|
| 155 |
+
"username": profile.username
|
| 156 |
}
|
| 157 |
|
| 158 |
+
submission_history[profile.username].append(submission_record)
|
| 159 |
|
| 160 |
# Save submission history
|
| 161 |
return save_submission_history(submission_history)
|