basma-b commited on
Commit
91da203
·
verified ·
1 Parent(s): 3a63089

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -11,7 +11,7 @@ DATASET_FILE = "data.json"
11
  # Authenticate HF user via Gradio
12
 
13
 
14
- def submit_form(submit_submission, email, team, affiliation, student, hf_username, hf_token):
15
  if oauth_token is None or oauth_token.token is None:
16
  raise gr.Error("You must be logged in to submit your code!")
17
 
@@ -20,7 +20,7 @@ def submit_form(submit_submission, email, team, affiliation, student, hf_usernam
20
 
21
  # Validate required fields
22
  if not email or not team or not student:
23
- return "Please fill all required fields."
24
 
25
  # Prepare new record
26
  new_record = {
@@ -48,7 +48,7 @@ def submit_form(submit_submission, email, team, affiliation, student, hf_usernam
48
 
49
  # Check if user already registered (by hf_id)
50
  if any(entry["hf_id"] == hf_username for entry in data):
51
- return "You have already registered."
52
 
53
  # Append new record
54
  data.append(new_record)
@@ -69,9 +69,9 @@ with gr.Blocks() as demo:
69
  hf_username = gr.Textbox(label="HF Username", visible=False)
70
  hf_token = gr.Textbox(label="HF Token", visible=False)
71
 
72
- with gr.Row():
73
- email = gr.Textbox(label="E-mail", placeholder="[email protected]", lines=1)
74
- team = gr.Textbox(label="Team name", lines=1)
75
 
76
  affiliation = gr.Textbox(label="Affiliation (optional)", lines=1)
77
 
 
11
  # Authenticate HF user via Gradio
12
 
13
 
14
+ def submit_form(submit_submission, email, team, affiliation, student, hf_username, hf_token, oauth_token: gr.OAuthToken = None):
15
  if oauth_token is None or oauth_token.token is None:
16
  raise gr.Error("You must be logged in to submit your code!")
17
 
 
20
 
21
  # Validate required fields
22
  if not email or not team or not student:
23
+ raise gr.Error("Please fill all required fields.")
24
 
25
  # Prepare new record
26
  new_record = {
 
48
 
49
  # Check if user already registered (by hf_id)
50
  if any(entry["hf_id"] == hf_username for entry in data):
51
+ raise gr.Error("You have already registered.")
52
 
53
  # Append new record
54
  data.append(new_record)
 
69
  hf_username = gr.Textbox(label="HF Username", visible=False)
70
  hf_token = gr.Textbox(label="HF Token", visible=False)
71
 
72
+ #with gr.Row():
73
+ email = gr.Textbox(label="E-mail", placeholder="[email protected]", lines=1)
74
+ team = gr.Textbox(label="Team name", lines=1)
75
 
76
  affiliation = gr.Textbox(label="Affiliation (optional)", lines=1)
77