def setUp(self): # set up the test DB self.db = tested_db self.db.create_all() self.db.session.add(Professor(id=1, title="Teacher Assistant", student_id=1)) self.db.session.add(Professor(id=2, title="Professor", student_id=2)) self.db.session.commit() self.app = tested_app.test_client()
def admin(): form = ProfessorForm() form2 = CollegeForm() if form.add_professor.data and form.validate_on_submit(): professor = Professor(first_name=form.first_name.data, last_name=form.last_name.data, department=form.department.data, college=College.query.filter_by( college_acronym=form.college.data).first()) db.session.add(professor) db.session.commit() flash('Professor Added') return redirect(url_for('professor', profname=professor.first_name)) if form2.add_college.data and form2.validate_on_submit(): college = College(college_name=form2.college_name.data, college_acronym=form2.college_acronym.data, state=form2.state.data) db.session.add(college) db.session.commit() flash('College Added') return redirect(url_for('main')) return render_template("admin.html", form=form, form2=form2, title='Admin')
def init_db(): from models import Professor, SchoolClass # Base.metadata.drop_all(bind=engine) Base.metadata.create_all(bind=engine) # Check for any courses in database # TODO: Figure out the clean way to check if the database is empty count = 0 check = db_session.query(SchoolClass) for course in check: count += 1 if count != 0: return print("initializing database from 'data.json'") try: course_data = json.load(open('data.json')) except IOError: print("put the initial course data into data.json") courses = course_data['courses'] for course in courses: prof_names = course['faculty'] # Todo: Handle multiple teachers well prof_name = prof_names[0] prof = Professor.query.filter_by(name=prof_name).first() if prof is None: prof = Professor(name=prof_name) db_session.add(prof) if course['schedule'] != []: start_time = course['schedule'][0]['startTime'] end_time = course['schedule'][0]['endTime'] days = course['schedule'][0]['days'] if days == []: days = "" else: start_time = None end_time = None days = None course = SchoolClass(department=course['department'], number=course['courseNumber'], suffix=course['courseCodeSuffix'], school=course['school'], section=course['section'], name=course['courseName'], professor=prof, open_seats=course['openSeats'], total_seats=course['totalSeats'], course_status=course['courseStatus'], days=days, start_time=start_time, end_time=end_time, credits=course['quarterCredits'], start_date=course['startDate'], end_date=course['endDate']) db_session.add(course) db_session.commit()
def put_professor(): # get the name first, if no name then fail title = request.form.get("title") if not title: return make_response(jsonify({"code": 403, "msg": "Cannot put student. Missing mandatory fields."}), 403) professor_id = request.form.get("id") if not professor_id: p = Professor(title=title) else: p = Professor(id=professor_id, title=title, student_id=professor_id) db.session.add(p) try: db.session.commit() except sqlalchemy.exc.SQLAlchemyError as e: error = "Cannot put student. " print(app.config.get("DEBUG")) if app.config.get("DEBUG"): error += str(e) return make_response(jsonify({"code": 404, "msg": error}), 404) return jsonify({"code": 200, "msg": "success"})
def login(request): if request.session.get('professor', False): return render_to_response(DIR + 'professor.html', {'professor' : request.session['professor']}, context_instance=RequestContext(request)) if request.method == "POST": login = request.POST['login'] senha = request.POST['senha'] if login == "" or senha == "": return render_to_response(DIR + "erro.html", {}) else: try: p = Professor.objects.get(login=login,senha=senha) request.session['professor'] = p return render_to_response(DIR + 'professor.html', { 'professor' : request.session['professor'] }, context_instance=RequestContext(request)) except: return render_to_response(DIR + 'erro.html', {} ) else: form = Professor(); return render_to_response(DIR + "login.html", {'form': form}, context_instance=RequestContext(request))
# 40: Orientação de Estágio # 41: Projeto Integrado # 42: Sistemas Embarcados # 8o Período # 43: Administração de Comércio Eletrônico # 44: Empreendedorismo # 45: Infraestrutura de Tecnologia da Informação # 46: Inovação e Novas Tecnologias # 47: Optativa # 48: Perícia em Informática # 49: Processamento de Imagens # 50: TCC rc = Professor(id=1, sigla='RC', ch_max=10, disciplinas=[1], preferencias=[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) es = Professor(id=2, sigla='ES', ch_max=10, disciplinas=[2, 5], preferencias=[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) br = Professor(id=3, sigla='BR', ch_max=8, disciplinas=[3], preferencias=[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) cr = Professor(id=4, sigla='CR', ch_max=5, disciplinas=[4], preferencias=[[-1, 1, 1, -1, 1], [-1, -1, 1, -1, 1]]) ar = Professor(id=5, sigla='AR', ch_max=6, disciplinas=[6], preferencias=[[1, 1, 1, -1, -1], [1, 1, 1, -1, -1]]) dm = Professor(id=6, sigla='DM', ch_max=6, disciplinas=[7], preferencias=[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) professores = [ rc, es, br, cr, ar, dm ] class Bootstrap:
def setUp(self): sys.path.insert(0, "../../src") from models import Professor self.sohee = Professor("*****@*****.**", "sohee2017") self.bob = Professor("*****@*****.**", "please", "Bob the Builder")
def create_prof(): name = request.json["name"] new_prof = Professor(name=name) db.session.add(new_prof) db.session.commit() return jsonify("{} was created".format(new_prof))
"theme": { "Unit Total": '7 Units', 'Requirements': "Choose seven courses total from Social & Behavioral Sciences and Humanities. A maximum of five courses may be chosen from a single category." }, "honors": { 'Unit Total': 'Two or More Quarters of Independent Study', 'Requirements': 'Cumulative GPA of 3.50 or higher, At least three units of advanced study' } } professors_dictionary = { 'Alshurafa': Professor(['395'], 4.07), 'Argall': Professor(['301', '469'], 5.00), 'Birnbaum': Professor(['337', '338', '395'], 3.70), 'Bustamante': Professor(['343', '345', '395'], 5.07), 'Campanoni': Professor(['322', '395'], 5.40), 'Xin Chen': Professor(['340', '350', '354', '395'], 4.99), 'Yan Chen': Professor(['395'], 4.35), 'Cossairt': Professor(['395', '395'], 5.15), 'De': Professor(['335', '395'], 5.02), 'Dinda': Professor(['213', '339', '340', '395', '441'], 4.43), 'Downey': Professor(['349', '395', '474'], 4.75), 'Duggan': Professor(['339', '395'], 4.15), 'Findler': Professor(['321', '395', '395'], 5.21), 'Forbus': Professor(['344', '370', '371'], 4.69), 'G. Memik': Professor(['361'], 4.74), 'Gergle': Professor(['395'], 5.28),