bradley6597
commited on
Commit
•
2aba9a7
1
Parent(s):
6241c2b
Added do not use button
Browse files
app.py
CHANGED
@@ -87,7 +87,7 @@ def same_auth(username, password):
|
|
87 |
return(username == os.environ['username']) & (password == os.environ['password'])
|
88 |
|
89 |
|
90 |
-
def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_title, image_type, increase = None):
|
91 |
max_results_list = ['10', '25', '50', '75', '100', '250', '500', '1000', '5000', '10000', 'All']
|
92 |
if increase:
|
93 |
max_results = max_results_list[max_results_list.index(max_results) + 1]
|
@@ -112,6 +112,9 @@ def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_tit
|
|
112 |
.reset_index()
|
113 |
.drop_duplicates())
|
114 |
output_df['Date Created'] = pd.to_datetime(output_df['Date Created'], format = 'mixed')
|
|
|
|
|
|
|
115 |
map_df = output_df[output_df['title'].str.contains('map|Map', regex = True)]
|
116 |
if map_df.shape[0] > 0:
|
117 |
extra_info = '<div id="mapBorder"><strong>If real-world maps are needed please check they are from the folder: Illustrations Now > Maps - Using the New Guidance (2024)</strong></div><br>'
|
@@ -282,6 +285,8 @@ with gr.Blocks(css=style,
|
|
282 |
with gr.Column(min_width = 0):
|
283 |
search_prompt = gr.Textbox(placeholder = 'search for an illustration', label = 'Search', elem_id = 'search_term')
|
284 |
title_search = gr.Checkbox(label = 'Search title only')
|
|
|
|
|
285 |
with gr.Column(min_width = 0):
|
286 |
shared_drive = gr.Dropdown(choices = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now', 'Shutter Stock Images', 'Beyond - Illustrations', 'DO NOT USE IN GENERAL RESOURCES - South Africa', 'Australia - Rhino Readers Illustrations', 'Aus and Nz - Phonics Illustrations', 'Twinkl Art Gallery'], multiselect = True, label = 'Shared Drive', value = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'])
|
287 |
with gr.Column(min_width = 0):
|
@@ -297,11 +302,11 @@ with gr.Blocks(css=style,
|
|
297 |
output_df = gr.HTML()
|
298 |
back_top_btn = gr.HTML(back_to_top_btn_html)
|
299 |
load_more_results_btn = gr.Button(value = 'Load More Results', interactive = True, visible = False)
|
300 |
-
search_button.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type], outputs=[output_df, max_return, load_more_results_btn])
|
301 |
-
search_prompt.submit(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type], outputs=[output_df, max_return, load_more_results_btn])
|
302 |
search_button.click(search_logging, inputs=[search_prompt], outputs=None)
|
303 |
search_prompt.submit(search_logging, inputs=[search_prompt], outputs=None)
|
304 |
-
load_more_results_btn.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type, load_more_results_btn], outputs=[output_df, max_return, load_more_results_btn])
|
305 |
app.load()
|
306 |
|
307 |
app.auth = (same_auth)
|
|
|
87 |
return(username == os.environ['username']) & (password == os.environ['password'])
|
88 |
|
89 |
|
90 |
+
def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_title, image_type, do_not_use, increase = None):
|
91 |
max_results_list = ['10', '25', '50', '75', '100', '250', '500', '1000', '5000', '10000', 'All']
|
92 |
if increase:
|
93 |
max_results = max_results_list[max_results_list.index(max_results) + 1]
|
|
|
112 |
.reset_index()
|
113 |
.drop_duplicates())
|
114 |
output_df['Date Created'] = pd.to_datetime(output_df['Date Created'], format = 'mixed')
|
115 |
+
if do_not_use:
|
116 |
+
output_df = output_df[~output_df['filepath'].str.lower().str.contains("do.*not.*use|not.*general|don\\'t.*use|do.*no.*use", regex = True)]
|
117 |
+
|
118 |
map_df = output_df[output_df['title'].str.contains('map|Map', regex = True)]
|
119 |
if map_df.shape[0] > 0:
|
120 |
extra_info = '<div id="mapBorder"><strong>If real-world maps are needed please check they are from the folder: Illustrations Now > Maps - Using the New Guidance (2024)</strong></div><br>'
|
|
|
285 |
with gr.Column(min_width = 0):
|
286 |
search_prompt = gr.Textbox(placeholder = 'search for an illustration', label = 'Search', elem_id = 'search_term')
|
287 |
title_search = gr.Checkbox(label = 'Search title only')
|
288 |
+
do_not_use = gr.Checkbox(label = 'Remove Do Not Use Images', value = True)
|
289 |
+
|
290 |
with gr.Column(min_width = 0):
|
291 |
shared_drive = gr.Dropdown(choices = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now', 'Shutter Stock Images', 'Beyond - Illustrations', 'DO NOT USE IN GENERAL RESOURCES - South Africa', 'Australia - Rhino Readers Illustrations', 'Aus and Nz - Phonics Illustrations', 'Twinkl Art Gallery'], multiselect = True, label = 'Shared Drive', value = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'])
|
292 |
with gr.Column(min_width = 0):
|
|
|
302 |
output_df = gr.HTML()
|
303 |
back_top_btn = gr.HTML(back_to_top_btn_html)
|
304 |
load_more_results_btn = gr.Button(value = 'Load More Results', interactive = True, visible = False)
|
305 |
+
search_button.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type, do_not_use], outputs=[output_df, max_return, load_more_results_btn])
|
306 |
+
search_prompt.submit(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type, do_not_use], outputs=[output_df, max_return, load_more_results_btn])
|
307 |
search_button.click(search_logging, inputs=[search_prompt], outputs=None)
|
308 |
search_prompt.submit(search_logging, inputs=[search_prompt], outputs=None)
|
309 |
+
load_more_results_btn.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type, do_not_use load_more_results_btn], outputs=[output_df, max_return, load_more_results_btn])
|
310 |
app.load()
|
311 |
|
312 |
app.auth = (same_auth)
|