def show_checklist(plane, checklist_name, cli_cont_style: CliStyle): """Display a prompt with a list of possible checklists from a plane. Args: plane (Plane): The Plane object that contains the checklist to be displayed. checklist_name (str): The string name of the checklist to be displayed. cli_cont_style (CliStyle): A CliStyle object to use as styling. Returns: str: The value returned by the prompt operation. """ page_results = None page_json = [List] flag = False selected_items = list('') results = None checklist_obj = Checklist('none', 'none') for checklist in plane.checklists: if checklist.name == checklist_name: checklist_obj = checklist while not flag: checklist_json_obj = ChecklistJSONObject(checklist_obj, selected_items) page_json = checklist_json_obj.return_json_instructions() page_results = prompt(page_json, style=cli_cont_style.style) selected_items = page_results[checklist_obj.name] nav_results = page_results['nav_controls'] if nav_results in (['EXIT', 'RETURN TO LIST SELECT']): results = nav_results flag = True return results
def create_checklist(template_id, who_for, time_frame, preparer_id, reviewer_id): checklist_id = db.session.query(db.func.max( Checklist.checklist_id)).first() if checklist_id: checklist_id = checklist_id[0] + 1 else: checklist_id = 1 checklist = Checklist(checklist_id=checklist_id, template_id=template_id, who_for=who_for, time_frame=time_frame, preparer_id=preparer_id, reviewer_id=reviewer_id) db.session.add(checklist) db.session.commit() return checklist
def choose_recipient(checklist_id, recipient_id): recipient = Checklist(checklist_id=checklist_id, recipient_id=recipient_id) recipient = db.session.query(Checklist.checklist_id).filter( Checklist.checklist_id == checklist_id).update( {Checklist.recipient_id: recipient_id}) db.session.commit() return recipient
def mark_complete(checklist_id, date_complete): complete = Checklist(checklist_id=checklist_id, date_complete=date_complete) date_complete = db.session.query(Checklist.checklist_id).filter( Checklist.checklist_id == checklist_id).update( {Checklist.date_complete: date_complete}) db.session.commit() return complete
def mark_datereviewcompleted(checklist_id, date_review_completed): reviewcomplete = Checklist(checklist_id=checklist_id, date_review_completed=date_review_completed) date_review_completed = db.session.query(Checklist.checklist_id).filter( Checklist.checklist_id == checklist_id).update( {Checklist.date_review_completed: date_review_completed}) # print(date_review_completed) db.session.commit() return reviewcomplete
def mark_datesenttoreview(checklist_id, date_sent_to_review): readyforreview = Checklist(checklist_id=checklist_id, date_sent_to_review=date_sent_to_review) date_sent_to_review = db.session.query(Checklist.checklist_id).filter( Checklist.checklist_id == checklist_id).update( {Checklist.date_sent_to_review: date_sent_to_review}) # print(date_sent_to_review) db.session.commit() return readyforreview
def create_checklist_seed(template_id, who_for, time_frame, preparer_id, reviewer_id): checklist = Checklist(template_id=template_id, who_for=who_for, time_frame=time_frame, preparer_id=preparer_id, reviewer_id=reviewer_id) db.session.add(checklist) db.session.commit() return checklist
def load_plane_file(filename: str): """Handle the loading of a plane data file. Args: filename: the name of the file. It will be validated to make sure it is a JSON file """ checklists = [] new_plane = Plane('blank') if validate_plane_file(filename): with open(filename) as plane_data_file: try: plane_data = json.load(plane_data_file) # All other data in the file is not handled yet. # Currently only concerned about the checklists. for individual_checklist in plane_data['checklists']: steps = [] for checklist_step in individual_checklist[ 'checklist_steps']: temp_checklist_step = ChecklistStep( int(checklist_step['step_number']), checklist_step['step_title'], checklist_step['step_text']) steps.append(temp_checklist_step) checklists.append( Checklist(individual_checklist['checklist_name'], individual_checklist['checklist_message'], steps)) checklists[-1].sort_checklist() new_plane.plane_name = plane_data['plane_name'] new_plane.checklists = checklists except json.JSONDecodeError: new_plane = Plane( "Plane with filename: " + str(filename) + " Failed to load correctly.", None, None) else: raise Exception('Parameter filename Passed to load_plane_file method \ was not a JSON file.') return new_plane