def setUp(self): self.instructor = Instructor("Emily", 21)
def setUp(self): self.instructor1 = Instructor("Schmidt", "07912 123456") self.yogaclass = YogaClass( "Aerial Yoga", 45, "Yoga whle being supported by a hammock to help with deeper stretches and greater flexibility.", self.instructor1, "2021-03-23", "18:00", 5)
def setUp(self): self.workout = Workout("Fuego", "HIIT", "45 minutes", "5th December 2020", 3) self.instructor = Instructor("Emily", 21) self.member = Member("Cameron", 25, "Gold")
def fetch_rows(table, criteria, connection): objs = [] try: cur = connection.cursor() #--- SPLIT NULLS FROM NOT NULLS + COMMON WORK---# null_criteria = {} deleters = [] for key in criteria: if (criteria[key] is None): null_criteria[key] = None deleters.append(key) for key in deleters: criteria.pop(key, None) null_phrase = ('IS NULL AND '.join(null_criteria.keys())) + " IS NULL " not_null_phrase = '= %s AND '.join(criteria.keys()) + "= %s" if (null_criteria and not criteria): crit_phrase = " WHERE " + null_phrase elif (criteria and not null_criteria): crit_phrase = " WHERE " + not_null_phrase elif (criteria and null_criteria): crit_phrase = " WHERE " + null_phrase + "AND " + not_null_phrase else: crit_phrase = "" #--------------------------------# if (table == "in"): select_phrase = "SELECT * FROM instructors" sql = select_phrase + crit_phrase cur.execute(sql, (list(criteria.values()))) row = cur.fetchone() while row is not None: instructor = Instructor(row[0], row[1], row[2], row[3], row[4], row[5], row[6]) objs.append(instructor) row = cur.fetchone() if (table == "co"): select_phrase = "SELECT * FROM courses" sql = select_phrase + crit_phrase cur.execute(sql, (list(criteria.values()))) row = cur.fetchone() while row is not None: course = Course(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]) objs.append(course) row = cur.fetchone() if (table == "st"): select_phrase = "SELECT * FROM students" sql = select_phrase + crit_phrase #print(cur.mogrify(sql, (list(criteria.values())))) cur.execute(sql, (list(criteria.values()))) row = cur.fetchone() while row is not None: student = Student(row[0], row[1], row[2], row[3], row[4], row[5]) objs.append(student) row = cur.fetchone() if (table == "cs"): select_phrase = "SELECT * FROM coursestudents" sql = select_phrase + crit_phrase cur.execute(sql, (list(criteria.values()))) row = cur.fetchone() while row is not None: coursestudent = Coursestudent(row[0], row[1]) objs.append(coursestudent) row = cur.fetchone() if (table == "as"): select_phrase = "SELECT * FROM assignments" sql = select_phrase + crit_phrase cur.execute(sql, (list(criteria.values()))) row = cur.fetchone() while row is not None: assignment = Assignment(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9]) objs.append(assignment) row = cur.fetchone() if (table == "su"): select_phrase = "SELECT * FROM submissions" sql = select_phrase + crit_phrase cur.execute(sql, (list(criteria.values()))) row = cur.fetchone() while row is not None: submission = Submission(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7]) objs.append(submission) row = cur.fetchone() if (table == "com"): select_phrase = "SELECT * FROM comments" sql = select_phrase + crit_phrase cur.execute(sql, (list(criteria.values()))) row = cur.fetchone() while row is not None: comment = Comment(row[0], row[1], row[2], row[3]) objs.append(comment) row = cur.fetchone() connection.commit() cur.close() except Exception as error: print(error) return objs
def get_Instructor(self): # This is not at the top to prevent circular imports. from models.instructor import Instructor return Instructor.all().ancestor(self)
def setUp(self): self.instructor = Instructor('john', 'smith', '*****@*****.**', 123) self.course1 = Course(1, 'test_course1') self.course2 = Course(2, 'test_course2') self.course3 = Course(3, 'test_course3')
define('database_host', default='localhost', help='rethink database host', type=str) define('database_port', default=28015, help='rethink database port', type=int) define('digest', group='digestor', default='', help='define explicitly to digest that csv. ALL will digest every .csv', type=str) define('associate', group='digestor', default=False, help='this will build all has-many associations between models', type=bool) define('overtime', group='digestor', default=False, help='this will make all overtime associations', type=bool) define('cleanup', group='digestor', default=False, help='define explicitly to finalize and clean the database', type=bool) settings = { 'cookie_secret': '8goWPH9uTyO+9e2NzuaW6pbR6WKH1EbmrXIfxttXq00=', 'autoreload': True, 'template_path': 'templates/', 'static_path': 'static/', 'login_url': '/login', 'fcq': Fcq(), 'course': Course(), 'instructor': Instructor(), 'department': Department(), } def initialize(): settings['debug'] = options.debug settings['site_port'] = options.port database_name = options.database_name database_port = options.database_port database_host = options.database_host if options.debug: database_name += '_debug' if options.test: database_name += '_test' settings['database_name'] = database_name
class InstructorModelCase(unittest.TestCase): def setUp(self): self.instructor = Instructor('john', 'smith', '*****@*****.**', 123) self.course1 = Course(1, 'test_course1') self.course2 = Course(2, 'test_course2') self.course3 = Course(3, 'test_course3') def test_add_courses(self): # Add a single course self.instructor.add_courses(self.course1) self.assertEqual(len(self.instructor.courses), 1) # Add multiple courses self.instructor.add_courses([self.course2, self.course3]) self.assertEqual(len(self.instructor.courses), 3) def test_remove_courses(self): # Add a single course self.instructor.add_courses(self.course1) self.assertEqual(len(self.instructor.courses), 1) # Add multiple courses self.instructor.add_courses([self.course2, self.course3]) self.assertEqual(len(self.instructor.courses), 3) # Remove a single course self.instructor.remove_courses(self.course1, unique_attr='lms_id') self.assertEqual(len(self.instructor.courses), 2) # Remove multiple courses self.instructor.remove_courses([self.course2, self.course3], unique_attr='lms_id') self.assertEqual(len(self.instructor.courses), 0) def test_render_email(self): pass def test_send_email(self): pass
def update_instructor(id): instructor = Instructor(request.form["new_name"], id) instructor_repository.update(instructor) return redirect(f'/instructors/{id}')
def create_instructor(): instructor = Instructor(request.form['full_name']) instructor_repository.save(instructor) return redirect('/instructors')
instructors = db.run_query(INSTRUCTORS_QUERY, cursor, params) logger.info( f'{len(instructors)} instructors found in db with active course instance' ) for i in instructors: logger.info( f"Processing instructor {i['first_name']} {i['last_name']}") # Connect to the instructors LMS using their API token lms_token = i['lms_token'] lms_obj = LmsClass(lms_token, school_config.API_BASE_URL) # Create the instructor object from db info and grab all their courses from db instructor = Instructor(first_name=i['first_name'], last_name=i['last_name'], email=i['email'], lms_id=i['lms_id'], color_blind_mode=i['color_blind_mode']) INSTRUCTOR_COURSES = f'''SELECT DISTINCT lms_id, short_name, alias FROM courses WHERE instructor_id = %s AND is_monitored=TRUE''' params = (i['id'], ) instructor_courses_dict = db.run_query(INSTRUCTOR_COURSES, cursor, params) instructor.add_courses([ Course(lms_id=c['lms_id'], short_name=c['short_name'], alias=c['alias']) for c in instructor_courses_dict ]) for course in instructor.courses:
member_repository.save(member_5) member_repository.save(member_6) member_repository.save(member_7) member_repository.save(member_8) member_repository.save(member_9) member_repository.save(member_10) member_repository.save(member_11) member_repository.save(member_12) member_repository.save(member_13) member_repository.save(member_14) member_repository.save(member_15) member_repository.save(member_16) member_repository.save(member_17) member_repository.save(member_18) instructor_1 = Instructor("Big Jayne") instructor_2 = Instructor("Bendy Jo") instructor_3 = Instructor("Timmy Muscles") instructor_4 = Instructor("Quads Etherington") instructor_5 = Instructor("Old man Johnson") instructor_6 = Instructor("Mickey the Fist") instructor_repository.save(instructor_1) instructor_repository.save(instructor_2) instructor_repository.save(instructor_3) instructor_repository.save(instructor_4) instructor_repository.save(instructor_5) instructor_repository.save(instructor_6) location_1 = Location("Free Weights Gym", 15) location_2 = Location("Yoga Studio", 10)