Omnibus commited on
Commit
107ad9f
·
verified ·
1 Parent(s): c6318ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -194,21 +194,26 @@ with gr.Blocks(css=css) as build:
194
  save_btn=gr.Button("Protect")
195
  rem_btn=gr.Button("Remove")
196
  with gr.Tab("Controls"):
197
- com_off = gr.Button("Turn OFF Commenting")
198
- com_on = gr.Button("Turn ON Commenting")
199
-
 
 
 
200
 
201
- def toggle_comments_off(space_list,token):
202
  api = HfApi(token=token)
203
-
204
- api.change_discussion_status(
205
- new_status='closed',
206
- token=token,
207
- repo_type='space',
208
- )
 
 
209
 
210
 
211
- com_off.click(toggle_comments_off, [])
212
 
213
  save_btn.click(add_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,space_list])
214
  rem_btn.click(rem_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,space_list])
 
194
  save_btn=gr.Button("Protect")
195
  rem_btn=gr.Button("Remove")
196
  with gr.Tab("Controls"):
197
+ with gr.Row():
198
+ with gr.Column():
199
+ check_list=gr.CheckboxGroup(choices=space_list)
200
+ com_off = gr.Button("Turn OFF Commenting")
201
+ com_on = gr.Button("Turn ON Commenting")
202
+
203
 
204
+ def toggle_comments_off(r_name,check_list,token):
205
  api = HfApi(token=token)
206
+ for ea in check_list:
207
+
208
+ api.change_discussion_status(
209
+ repo_id=f'{r_name}/{ea}'
210
+ new_status='closed',
211
+ token=token,
212
+ repo_type='space',
213
+ )
214
 
215
 
216
+ com_off.click(toggle_comments_off, [r_name,check_list,token])
217
 
218
  save_btn.click(add_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,space_list])
219
  rem_btn.click(rem_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,space_list])