File size: 1,803 Bytes
e1ce262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""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,
    )