Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -236,6 +236,19 @@ Now, generate the {document_type}:
|
|
236 |
State('specific-document-name', 'children'),
|
237 |
prevent_initial_call=True
|
238 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
def generate_document_preview(*args):
|
240 |
global current_document, document_type, shredded_document, generated_documents
|
241 |
ctx = dash.callback_context
|
@@ -245,12 +258,12 @@ def generate_document_preview(*args):
|
|
245 |
triggered_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
246 |
|
247 |
if triggered_id.startswith('btn-'):
|
248 |
-
document_type = triggered_id.replace('btn-', '').replace('-', '
|
249 |
if document_type == "Shred":
|
250 |
return html.Div("Ready to shred. Click 'Generate Document' to proceed."), "", "Ready to shred.", {'display': 'none'}, {'display': 'none'}, {'display': 'block'}
|
251 |
elif document_type in ["Pink", "Red", "Gold"]:
|
252 |
return html.Div(f"Ready to generate {document_type} document."), "", f"Ready to generate {document_type} document.", {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
|
253 |
-
elif document_type in ["
|
254 |
return html.Div(f"Ready to generate {document_type}."), "", f"Ready to generate {document_type}.", {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
|
255 |
|
256 |
if triggered_id == 'btn-generate-document':
|
@@ -279,28 +292,28 @@ def generate_document_preview(*args):
|
|
279 |
else:
|
280 |
current_document = generate_document(document_type, [shredded_document])
|
281 |
elif document_type == "Red":
|
282 |
-
if '
|
283 |
return html.Div("Please complete Pink Review first."), "", "Please complete Pink Review first.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
284 |
if document_source == 'uploaded' and specific_document:
|
285 |
-
current_document = generate_document(document_type, [specific_document, generated_documents['
|
286 |
else:
|
287 |
-
current_document = generate_document(document_type, [generated_documents['
|
288 |
elif document_type == "Gold":
|
289 |
-
if '
|
290 |
return html.Div("Please complete Red Review first."), "", "Please complete Red Review first.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
291 |
if document_source == 'uploaded' and specific_document:
|
292 |
-
current_document = generate_document(document_type, [specific_document, generated_documents['
|
293 |
else:
|
294 |
-
current_document = generate_document(document_type, [generated_documents['
|
295 |
-
elif document_type in ["
|
296 |
-
previous_document = generated_documents.get(document_type.split('
|
297 |
if not previous_document:
|
298 |
-
return html.Div(f"Please generate {document_type.split('
|
299 |
if document_source == 'uploaded' and specific_document:
|
300 |
current_document = generate_document(document_type, [specific_document, previous_document, shredded_document])
|
301 |
else:
|
302 |
current_document = generate_document(document_type, [previous_document, shredded_document])
|
303 |
-
elif document_type in ["
|
304 |
if 'Gold' not in generated_documents:
|
305 |
return html.Div("Please complete Gold document first."), "", "Please complete Gold document first.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
306 |
if document_source == 'uploaded' and specific_document:
|
@@ -318,7 +331,6 @@ def generate_document_preview(*args):
|
|
318 |
return html.Div(f"Error generating document: {str(e)}"), "Error", "An error occurred while generating the document.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
319 |
|
320 |
raise dash.exceptions.PreventUpdate
|
321 |
-
|
322 |
@app.callback(
|
323 |
Output('specific-document-name', 'children'),
|
324 |
Input('upload-specific-document', 'contents'),
|
|
|
236 |
State('specific-document-name', 'children'),
|
237 |
prevent_initial_call=True
|
238 |
)
|
239 |
+
@app.callback(
|
240 |
+
Output('document-preview', 'children'),
|
241 |
+
Output('loading-output', 'children'),
|
242 |
+
Output('status-bar', 'children', allow_duplicate=True),
|
243 |
+
Output('document-upload', 'style'),
|
244 |
+
Output('document-choice', 'style'),
|
245 |
+
Output('btn-generate-document', 'style'),
|
246 |
+
[Input(f'btn-{doc_type.lower().replace(" ", "-")}', 'n_clicks') for doc_type in document_types.keys()],
|
247 |
+
Input('btn-generate-document', 'n_clicks'),
|
248 |
+
State('document-source', 'value'),
|
249 |
+
State('specific-document-name', 'children'),
|
250 |
+
prevent_initial_call=True
|
251 |
+
)
|
252 |
def generate_document_preview(*args):
|
253 |
global current_document, document_type, shredded_document, generated_documents
|
254 |
ctx = dash.callback_context
|
|
|
258 |
triggered_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
259 |
|
260 |
if triggered_id.startswith('btn-'):
|
261 |
+
document_type = triggered_id.replace('btn-', '').replace('-', ' ').title()
|
262 |
if document_type == "Shred":
|
263 |
return html.Div("Ready to shred. Click 'Generate Document' to proceed."), "", "Ready to shred.", {'display': 'none'}, {'display': 'none'}, {'display': 'block'}
|
264 |
elif document_type in ["Pink", "Red", "Gold"]:
|
265 |
return html.Div(f"Ready to generate {document_type} document."), "", f"Ready to generate {document_type} document.", {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
|
266 |
+
elif document_type in ["Pink Review", "Red Review", "Gold Review", "Virtual Board", "Loe"]:
|
267 |
return html.Div(f"Ready to generate {document_type}."), "", f"Ready to generate {document_type}.", {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
|
268 |
|
269 |
if triggered_id == 'btn-generate-document':
|
|
|
292 |
else:
|
293 |
current_document = generate_document(document_type, [shredded_document])
|
294 |
elif document_type == "Red":
|
295 |
+
if 'Pink Review' not in generated_documents:
|
296 |
return html.Div("Please complete Pink Review first."), "", "Please complete Pink Review first.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
297 |
if document_source == 'uploaded' and specific_document:
|
298 |
+
current_document = generate_document(document_type, [specific_document, generated_documents['Pink Review'], shredded_document])
|
299 |
else:
|
300 |
+
current_document = generate_document(document_type, [generated_documents['Pink Review'], shredded_document])
|
301 |
elif document_type == "Gold":
|
302 |
+
if 'Red Review' not in generated_documents:
|
303 |
return html.Div("Please complete Red Review first."), "", "Please complete Red Review first.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
304 |
if document_source == 'uploaded' and specific_document:
|
305 |
+
current_document = generate_document(document_type, [specific_document, generated_documents['Red Review'], shredded_document])
|
306 |
else:
|
307 |
+
current_document = generate_document(document_type, [generated_documents['Red Review'], shredded_document])
|
308 |
+
elif document_type in ["Pink Review", "Red Review", "Gold Review"]:
|
309 |
+
previous_document = generated_documents.get(document_type.split(' ')[0], None)
|
310 |
if not previous_document:
|
311 |
+
return html.Div(f"Please generate {document_type.split(' ')[0]} document first."), "", f"Please generate {document_type.split(' ')[0]} document first.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
312 |
if document_source == 'uploaded' and specific_document:
|
313 |
current_document = generate_document(document_type, [specific_document, previous_document, shredded_document])
|
314 |
else:
|
315 |
current_document = generate_document(document_type, [previous_document, shredded_document])
|
316 |
+
elif document_type in ["Virtual Board", "Loe"]:
|
317 |
if 'Gold' not in generated_documents:
|
318 |
return html.Div("Please complete Gold document first."), "", "Please complete Gold document first.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
319 |
if document_source == 'uploaded' and specific_document:
|
|
|
331 |
return html.Div(f"Error generating document: {str(e)}"), "Error", "An error occurred while generating the document.", {'display': 'none'}, {'display': 'none'}, {'display': 'none'}
|
332 |
|
333 |
raise dash.exceptions.PreventUpdate
|
|
|
334 |
@app.callback(
|
335 |
Output('specific-document-name', 'children'),
|
336 |
Input('upload-specific-document', 'contents'),
|