@@ -47,9 +47,7 @@ class ImageListForm(FlaskForm):
4747 name_pairs = []
4848
4949 # For this example, images have the format "landmark-name.type".
50- image_captions = [
51- x .split ("." )[0 ].replace ("-" , " " ).title () for x in image_filenames
52- ]
50+ image_captions = [x .split ("." )[0 ].replace ("-" , " " ).title () for x in image_filenames ]
5351
5452 # Add a checkbox for each image to the form, named by the image filename.
5553 for i in range (len (image_filenames )):
@@ -77,14 +75,11 @@ def construct_filename_caption_dictionary_list(form):
7775 A dictionary that maps image filenames to captions.
7876 """
7977 selected_images = [
80- key
81- for key , value in form .data .items ()
82- if value is True and key != "submit"
78+ key for key , value in form .data .items () if value is True and key != "submit"
8379 ]
8480
8581 filename_caption_pairs = {
86- form [image_id ].name : form [image_id ].label .text
87- for image_id in selected_images
82+ form [image_id ].name : form [image_id ].label .text for image_id in selected_images
8883 }
8984
9085 return filename_caption_pairs
@@ -178,9 +173,7 @@ def create_attachments(filename_caption_pairs):
178173 # Specifies the route for a teacher user when the attachment is
179174 # loaded in the Classroom grading view.
180175 "studentWorkReviewUri" : {
181- "uri" : flask .url_for (
182- "view_submission" , _scheme = "https" , _external = True
183- )
176+ "uri" : flask .url_for ("view_submission" , _scheme = "https" , _external = True )
184177 },
185178 # The title of the attachment.
186179 "title" : f"Attachment { attachment_count } " ,
@@ -272,9 +265,7 @@ def load_activity_attachment():
272265 # Redirect to the authorization page if we received login_hint but don't
273266 # have any stored credentials for this user. We need the refresh token
274267 # specifically.
275- credentials = ch ._credential_handler .get_credentials (
276- flask .session ["login_hint" ]
277- )
268+ credentials = ch ._credential_handler .get_credentials (flask .session ["login_hint" ])
278269
279270 if credentials is None :
280271 return ch .start_auth_flow ("attachment_callback" )
@@ -317,9 +308,9 @@ def load_activity_attachment():
317308 # If the user is a student, get their submission status for this attachment.
318309 # Note that the submissionId was returned in the addOnContext response.
319310 else :
320- flask .session ["submissionId" ] = addon_context_response .get (
321- "studentContext "
322- ). get ( "submissionId" )
311+ flask .session ["submissionId" ] = addon_context_response .get ("studentContext" ). get (
312+ "submissionId "
313+ )
323314
324315 submission_response = (
325316 classroom_service .courses ()
@@ -371,10 +362,8 @@ def load_activity_attachment():
371362
372363 return flask .render_template (
373364 "acknowledge-submission.html" ,
374- message = "Your response has been recorded. You can close the "
375- "iframe now." ,
376- instructions = "Please Turn In your assignment if you have "
377- "completed all tasks." ,
365+ message = "Your response has been recorded. You can close the iframe now." ,
366+ instructions = "Please Turn In your assignment if you have completed all tasks." ,
378367 )
379368
380369 # Show the activity. Disable the submission button if the user is a teacher.
@@ -407,9 +396,9 @@ def attachment_callback():
407396
408397 # Store credentials in the session.
409398 credentials = flow .credentials
410- flask .session [
411- " credentials"
412- ] = ch . _credential_handler . session_credentials_to_dict ( credentials )
399+ flask .session ["credentials" ] = ch . _credential_handler . session_credentials_to_dict (
400+ credentials
401+ )
413402
414403 # Add or update the user's record in the database.
415404 ch ._credential_handler .save_credentials_to_storage (credentials )
0 commit comments