def remove_curriculum_callback(self): self.app.client_model.remove_curriculum_goals(self.curriculum) self.app.client_model.remove_curriculum_topics(self.curriculum) self.app.client_model.remove_curriculum_courses(self.curriculum) self.app.client_model.remove_curriculum(self.curriculum) self.app.client_model._curriculum_to_edit = classes.Curriculum() self.app.screen_manager.transition.direction = 'down' self.app.screen_manager.current = 'curriculum_dashboard' dialogue = MessageDialogue( title="success", message="We removed the curriculum from the db") dialogue.open()
def back_callback(self): self.app.client_model._curriculum_to_edit = classes.Curriculum() self.app.screen_manager.transition.direction = 'down' self.app.screen_manager.current = 'curriculum_dashboard'
def __init__(self): Widget.__init__(self) self.curriculum = classes.Curriculum() self.req_courses = set() self.opt_courses = set() self.cur_topics = []
def submit_callback(self): new_curriculum = classes.Curriculum() # getting input from ui new_curriculum.name = self.curriculum.name if len( self.ids.curriculum_name.text ) == 0 else self.ids.curriculum_name.text new_curriculum.min_credit_hours = self.curriculum.min_credit_hours if len( self.ids.min_credit_hours.text ) == 0 else self.ids.min_credit_hours.text new_curriculum.id_in_charge = self.curriculum.id_in_charge if len( self.ids.id_in_charge.text) == 0 else int( self.ids.id_in_charge.text) new_curriculum.req_course_names = self.req_courses new_curriculum.opt_course_names = self.opt_courses new_curriculum.cur_topics = self.cur_topics # to validate input # need to make sure min_credit_hours and id_in_charge are numbers # need to make sure id_in_charge in person table # need to make sure topics are in topics table # need to make sure courses are in courses table if self.app.client_model.get_curriculum(new_curriculum.name) is None: logging.info( "EditCurriculumScreenRoot: Curriculum Does not exist to edit") dialogue = MessageDialogue( title="Curriculum error", message= f"A Curriculum with name \"{new_curriculum.name}\"\ndoes not exist in the db." ) dialogue.open() return if new_curriculum.name is None: logging.info( "NewCurriculumScreenRoot: some text fields lack input") dialogue = MessageDialogue( title="Format error", message="A curriculum Name is required to edit the curriculum." ) dialogue.open() return if new_curriculum.cur_topics is not []: for ct in new_curriculum.cur_topics: tp = self.app.client_model.get_topic(ct.topic_id) if tp is None: logging.info("NewCurriculumScreenRoot: Invalid topic") dialogue = MessageDialogue( title="Database error", message= "One of the topics does not exist in the\n database.") dialogue.open() return for c in new_curriculum.opt_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return for c in new_curriculum.req_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return p = self.app.client_model.get_person(new_curriculum.id_in_charge) if not p: logging.info("NewCurriculumScreenRoot: Invalid person") dialogue = MessageDialogue( title="Database error", message="The person id does not exist in the db") dialogue.open() return for t in new_curriculum.cur_topics: tp = self.app.client_model.get_topic(t.topic_id) tp.curriculum_name = new_curriculum.name self.app.client_model.set_curriculum(new_curriculum, updating=True) self.ids.curriculum_name.text = '' self.ids.min_credit_hours.text = '' self.ids.id_in_charge.text = '' self.app.screen_manager.transition.direction = 'down' self.app.screen_manager.current = 'curriculum_dashboard' dialogue = MessageDialogue( title="success", message="successfully created the curriculum") dialogue.open() self.app.client_model._curriculum_to_edit = classes.Curriculum() print("submit")
def __init__(self): Widget.__init__(self) self.curriculum = classes.Curriculum()
def submit_callback(self): new_curriculum = classes.Curriculum() # getting input from ui new_curriculum.name = None if len( self.ids.curriculum_name.text ) == 0 else self.ids.curriculum_name.text new_curriculum.min_credit_hours = None if len( self.ids.min_credit_hours.text ) == 0 else self.ids.min_credit_hours.text new_curriculum.id_in_charge = None if len( self.ids.id_in_charge.text) == 0 else int( self.ids.id_in_charge.text) new_curriculum.req_course_names = self.req_courses new_curriculum.opt_course_names = self.opt_courses new_curriculum.cur_topics = self.cur_topics.values() # to validate input # need to make sure min_credit_hours and id_in_charge are numbers # need to make sure id_in_charge in person table # need to make sure topics are in topics table # need to make sure courses are in courses table if self.app.client_model.get_curriculum( new_curriculum.name) is not None: logging.info("NewCurriculumScreenRoot: curriculum already exists") dialogue = MessageDialogue( title="Curriculum error", message= f"A Curriculum with name \"{new_curriculum.name}\"\nalready exists." ) dialogue.open() return if new_curriculum.name is None or new_curriculum.id_in_charge is None \ or new_curriculum.min_credit_hours is None or new_curriculum.cur_topics is None\ or new_curriculum.req_course_names is None: logging.info( "NewCurriculumScreenRoot: some text fields lack input") dialogue = MessageDialogue( title="Format error", message= "A curriculum Name, id in charge,\nand minimum credit hours are required." ) dialogue.open() return if new_curriculum.cur_topics is not []: for ct in new_curriculum.cur_topics: tp = self.app.client_model.get_topic(ct.topic_id) if tp is None: logging.info("NewCurriculumScreenRoot: Invalid topic") dialogue = MessageDialogue( title="Database error", message= "One of the topics does not exist in the\n database.") dialogue.open() return for c in new_curriculum.opt_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return for c in new_curriculum.req_course_names: cs = self.app.client_model.get_course(c) if cs.name is None: logging.info("NewCurriculumScreenRoot: Invalid course: " + str(c)) dialogue = MessageDialogue( title="Database error", message= "One of the courses does not exist\nin the database.") dialogue.open() return p = self.app.client_model.get_person(new_curriculum.id_in_charge) if not p: logging.info("NewCurriculumScreenRoot: Invalid person") dialogue = MessageDialogue( title="Database error", message="The person id does not exist in the db") dialogue.open() return for t in new_curriculum.cur_topics: t.curriculum_name = new_curriculum.name # finally, need to check duplicate submisson...right? already_in_db = self.app.client_model.get_curriculum( new_curriculum.name) if already_in_db: logging.info("NewCurriculumScreenRoot: Duplicate Sumbission") dialogue = MessageDialogue( title="Database error", message="A curriculum with this name already exists in the db") dialogue.open() return self.app.client_model.set_curriculum(new_curriculum) self.ids.curriculum_name.text = '' self.ids.min_credit_hours.text = '' self.ids.id_in_charge.text = '' self.app.screen_manager.transition.direction = 'right' self.app.screen_manager.current = 'add_new_screen' dialogue = MessageDialogue( title="success", message="successfully created the curriculum") dialogue.open() print("submit")