Spaces:
Build error
Build error
Put checkboxes in order
Browse files
main.py
CHANGED
|
@@ -156,7 +156,7 @@ def get_timeslots(schedule_name: str):
|
|
| 156 |
Submits the form that the person filled out to Supabase.
|
| 157 |
Returns: None
|
| 158 |
'''
|
| 159 |
-
def submit_preferences(schedule_name: str, curr_juggler_name: str, curr_email: str, curr_num_workshops: int, curr_availability:
|
| 160 |
# Error handling
|
| 161 |
if len(curr_juggler_name) == 0:
|
| 162 |
return gr.Warning('', ALERT_TIME, title="Please enter your name.")
|
|
@@ -179,11 +179,12 @@ def submit_preferences(schedule_name: str, curr_juggler_name: str, curr_email: s
|
|
| 179 |
if len(curr_descriptions) == 0:
|
| 180 |
return gr.Warning('', ALERT_TIME, title=f"Please describe at least one workshop that you want to teach. You must hit \"Enter\" after each one!")
|
| 181 |
|
| 182 |
-
response = client.table('Forms').select('responses').eq('form_name', standardize(schedule_name)).execute()
|
| 183 |
data = response.data
|
| 184 |
|
| 185 |
if len(data) > 0:
|
| 186 |
form = json.loads(data[0]['responses'])
|
|
|
|
| 187 |
|
| 188 |
# Add current preferences to dictionary lists
|
| 189 |
curr_juggler_name = curr_juggler_name.strip()
|
|
@@ -199,7 +200,13 @@ def submit_preferences(schedule_name: str, curr_juggler_name: str, curr_email: s
|
|
| 199 |
bandwidths.extend([curr_num_workshops])
|
| 200 |
|
| 201 |
availabilities = form[AVAIL_COL]
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
availabilities.extend([curr_availability])
|
| 204 |
|
| 205 |
curr_descriptions = [elem['name'] for elem in curr_descriptions]
|
|
|
|
| 156 |
Submits the form that the person filled out to Supabase.
|
| 157 |
Returns: None
|
| 158 |
'''
|
| 159 |
+
def submit_preferences(schedule_name: str, curr_juggler_name: str, curr_email: str, curr_num_workshops: int, curr_availability: list, curr_descriptions: list):
|
| 160 |
# Error handling
|
| 161 |
if len(curr_juggler_name) == 0:
|
| 162 |
return gr.Warning('', ALERT_TIME, title="Please enter your name.")
|
|
|
|
| 179 |
if len(curr_descriptions) == 0:
|
| 180 |
return gr.Warning('', ALERT_TIME, title=f"Please describe at least one workshop that you want to teach. You must hit \"Enter\" after each one!")
|
| 181 |
|
| 182 |
+
response = client.table('Forms').select('responses', 'slots').eq('form_name', standardize(schedule_name)).execute()
|
| 183 |
data = response.data
|
| 184 |
|
| 185 |
if len(data) > 0:
|
| 186 |
form = json.loads(data[0]['responses'])
|
| 187 |
+
og_slots = data[0]['slots']
|
| 188 |
|
| 189 |
# Add current preferences to dictionary lists
|
| 190 |
curr_juggler_name = curr_juggler_name.strip()
|
|
|
|
| 200 |
bandwidths.extend([curr_num_workshops])
|
| 201 |
|
| 202 |
availabilities = form[AVAIL_COL]
|
| 203 |
+
# Put the checkboxes in order (rather than the order people click them!)
|
| 204 |
+
final_checkboxes = []
|
| 205 |
+
for elem in og_slots:
|
| 206 |
+
if elem in curr_availability:
|
| 207 |
+
final_checkboxes.append(elem)
|
| 208 |
+
|
| 209 |
+
curr_availability = f"{DELIMITER}".join(final_checkboxes)
|
| 210 |
availabilities.extend([curr_availability])
|
| 211 |
|
| 212 |
curr_descriptions = [elem['name'] for elem in curr_descriptions]
|