Spaces:
Sleeping
Sleeping
| """Registration tab – collects participant info and saves it to HF dataset.""" | |
| import gradio as gr | |
| from utils import add_registration, load_registrations | |
| def _register(name: str, email: str, affiliation: str, team_name: str): | |
| name, email, affiliation, team_name = ( | |
| name.strip(), email.strip(), affiliation.strip(), team_name.strip() | |
| ) | |
| if not all([name, email, team_name]): | |
| return gr.update(value="⚠️ Name, e-mail, and team name are required.", visible=True) | |
| # Simple duplicate check | |
| df = load_registrations() | |
| if not df.empty and (df["email"] == email).any(): | |
| return gr.update(value="⚠️ This e-mail is already registered.", visible=True) | |
| try: | |
| add_registration(name, email, affiliation, team_name) | |
| return gr.update( | |
| value=f"✅ **{team_name}** successfully registered!", visible=True | |
| ) | |
| except Exception as exc: | |
| return gr.update(value=f"❌ Registration failed: {exc}", visible=True) | |
| def build_registration_tab() -> None: | |
| gr.Markdown("## Register your team") | |
| gr.Markdown( | |
| "Fill in the form below. Each e-mail address can only be registered once." | |
| ) | |
| with gr.Row(): | |
| with gr.Column(): | |
| name = gr.Textbox(label="Full name", placeholder="Jane Doe") | |
| email = gr.Textbox(label="E-mail", placeholder="jane@example.com") | |
| affil = gr.Textbox(label="Affiliation", placeholder="University / Company") | |
| team_name = gr.Textbox(label="Team name", placeholder="Team Awesome") | |
| submit = gr.Button("Register", variant="primary") | |
| status = gr.Markdown(visible=False) | |
| submit.click( | |
| fn=_register, | |
| inputs=[name, email, affil, team_name], | |
| outputs=status, | |
| ) |