Juggling commited on
Commit
f081fc3
·
verified ·
1 Parent(s): dc8c07b

Updates in how passwords are entered. Also, dfs don't appear if they're blank

Browse files
Files changed (1) hide show
  1. main.py +14 -10
main.py CHANGED
@@ -318,12 +318,14 @@ def get_all_responses(schedule_name:str, password:str):
318
  df[col] = [elem.replace(DELIMITER, f"{DELIMITER} ") for elem in df[col].to_list()]
319
 
320
  directory = os.path.abspath(os.getcwd())
321
- path = directory + "all responses.csv"
322
  df.to_csv(path, index=False)
323
 
324
  if len(df) == 0:
325
  gr.Warning('', ALERT_TIME, title='No one has filled out the form yet.')
326
- return gr.DataFrame(df, visible=True), gr.File(path, visible=True)
 
 
327
 
328
 
329
 
@@ -332,15 +334,16 @@ Calls private function to randomly generate 10 of the best schedules.
332
  Returns: DataFrame, filepath
333
  '''
334
  def random_schedules_wrapper(schedule_name: str, password: str):
335
- gr.Info('', ALERT_TIME, title='Working on generating schedules! Please DO NOT click anything on this page.')
336
  res = generator(schedule_name, password, api_name='generate_random_schedules')
337
  df = res[0]['value']
338
  file = res[1]['value']
339
  if len(df['data'][0]) == 0:
340
  gr.Warning('', ALERT_TIME, title='No one has filled out the form yet.')
 
341
  else:
342
  gr.Info('', ALERT_TIME, title='Good news! I was able to make at least one schedule.')
343
- return gr.DataFrame(df, visible=True), gr.File(file, visible=True)
344
 
345
 
346
 
@@ -351,15 +354,16 @@ Gradio requires these to be two separate functions.
351
  Returns: DataFrame, filepath
352
  '''
353
  def all_schedules_wrapper(schedule_name: str, password: str):
354
- gr.Info('', ALERT_TIME, title='Working on generating schedules! Please DO NOT click anything on this page.')
355
  res = generator(schedule_name, password, api_name='generate_all_schedules')
356
  df = res[0]['value']
357
  file = res[1]['value']
358
  if len(df['data'][0]) == 0:
359
  gr.Warning('', ALERT_TIME, title='No one has filled out the form yet.')
 
360
  else:
361
  gr.Info('', ALERT_TIME, title='Good news! I was able to make at least one schedule.')
362
- return gr.DataFrame(df, visible=True), gr.File(file, visible=True)
363
 
364
 
365
 
@@ -467,10 +471,10 @@ with gr.Blocks() as demo:
467
 
468
  ### MAKE FORM ###
469
  with gr.Tab('Make Form'):
470
- email = gr.Textbox(label="Email Adress")
471
  schedule_name = gr.Textbox(label="Form Name", info='Keep it simple! Each person will have to type the form name to fill it out.')
472
- password_1 = gr.Textbox(label='Password', info='You MUST remember your password to access the schedule results. There is currently no way to reset your password.')
473
- password_2 = gr.Textbox(label='Password Again', info='Enter your password again')
474
  capacity = gr.Number(label="Capacity", info="Enter the maximum number of people who can teach per timeslot.")
475
 
476
  # Dynamically render timeslots
@@ -507,7 +511,7 @@ with gr.Blocks() as demo:
507
  with gr.Tab('View Form Results'):
508
  with gr.Column() as btn_group:
509
  schedule_name = gr.Textbox(label="Form Name")
510
- password = gr.Textbox(label="Password")
511
  find_form_btn = gr.Button('Find Form', variant='primary')
512
 
513
  # 1. Get all responses
 
318
  df[col] = [elem.replace(DELIMITER, f"{DELIMITER} ") for elem in df[col].to_list()]
319
 
320
  directory = os.path.abspath(os.getcwd())
321
+ path = directory + "/all responses.csv"
322
  df.to_csv(path, index=False)
323
 
324
  if len(df) == 0:
325
  gr.Warning('', ALERT_TIME, title='No one has filled out the form yet.')
326
+ return gr.DataFrame(df, visible=False), gr.File(path, visible=False)
327
+ else:
328
+ return gr.DataFrame(df, visible=True), gr.File(path, visible=True)
329
 
330
 
331
 
 
334
  Returns: DataFrame, filepath
335
  '''
336
  def random_schedules_wrapper(schedule_name: str, password: str):
337
+ gr.Info('', ALERT_TIME, title='Working on generating schedules! Please do NOT click anything on this page.')
338
  res = generator(schedule_name, password, api_name='generate_random_schedules')
339
  df = res[0]['value']
340
  file = res[1]['value']
341
  if len(df['data'][0]) == 0:
342
  gr.Warning('', ALERT_TIME, title='No one has filled out the form yet.')
343
+ return gr.DataFrame(df, visible=False), gr.File(file, visible=False)
344
  else:
345
  gr.Info('', ALERT_TIME, title='Good news! I was able to make at least one schedule.')
346
+ return gr.DataFrame(df, visible=True), gr.File(file, visible=True)
347
 
348
 
349
 
 
354
  Returns: DataFrame, filepath
355
  '''
356
  def all_schedules_wrapper(schedule_name: str, password: str):
357
+ gr.Info('', ALERT_TIME, title='Working on generating schedules! Please do NOT click anything on this page.')
358
  res = generator(schedule_name, password, api_name='generate_all_schedules')
359
  df = res[0]['value']
360
  file = res[1]['value']
361
  if len(df['data'][0]) == 0:
362
  gr.Warning('', ALERT_TIME, title='No one has filled out the form yet.')
363
+ return gr.DataFrame(df, visible=False), gr.File(file, visible=False)
364
  else:
365
  gr.Info('', ALERT_TIME, title='Good news! I was able to make at least one schedule.')
366
+ return gr.DataFrame(df, visible=True), gr.File(file, visible=True)
367
 
368
 
369
 
 
471
 
472
  ### MAKE FORM ###
473
  with gr.Tab('Make Form'):
474
+ email = gr.Textbox(label="Email Adress", type='email')
475
  schedule_name = gr.Textbox(label="Form Name", info='Keep it simple! Each person will have to type the form name to fill it out.')
476
+ password_1 = gr.Textbox(label='Password', info='You MUST remember your password to access the schedule results. There is currently no way to reset your password.', type='password')
477
+ password_2 = gr.Textbox(label='Password Again', info='Enter your password again', type='password')
478
  capacity = gr.Number(label="Capacity", info="Enter the maximum number of people who can teach per timeslot.")
479
 
480
  # Dynamically render timeslots
 
511
  with gr.Tab('View Form Results'):
512
  with gr.Column() as btn_group:
513
  schedule_name = gr.Textbox(label="Form Name")
514
+ password = gr.Textbox(label="Password", type='password')
515
  find_form_btn = gr.Button('Find Form', variant='primary')
516
 
517
  # 1. Get all responses