예제 #1
0
	def post(self):
		myClass = json.loads(request.data)
		print(myClass)
		#initiate object to get details of specific classs
		query = CourseQuery()
		query.connect()
		info = query.get_course_JSON(myClass['sub'], myClass['subId'])
		del info['_id']
		info['class_title'] = info['title']
		del info['title']
		query.disconnect()
		subjectIds = ast.literal_eval(json.dumps(info))
		print(subjectIds)
		#create object to query the times of the specific course
		section = SectionQuery()
		sectionList = []
		section.connect()
		for crn in info['crns']:
			cursor = section.get_section_cursor_crn(crn)
			courseSect = cursor[0]
			del courseSect['_id']
			courseSect['class_start'] = courseSect['start']
			del courseSect['start']
			# courseSection = ast.literal_eval(json.dumps(courseSect))
			sectionList.append(courseSect)
		section.disconnect()
		print(sectionList)
		return jsonify({'success':True, 'classInfo': info, 'times':sectionList})
예제 #2
0
Created on Apr 6, 2014

@author: Sam Gegg
'''

from mongoquery import MongoQuery, SectionQuery, CourseQuery, ProfQuery
from coursetablequery import CourseTableQuery
from pprint import PrettyPrinter

if __name__ == '__main__':

    pp = PrettyPrinter()

    client_courses = CourseQuery()
    client_courses.connect()
    pp.pprint(client_courses.get_course_JSON('CS', '125'))
    #client_courses.set_database_name('professors')
    #client_courses.set_collection('professors')
    #print(client_courses.get_cursor({})[1])
    client_courses.disconnect()
    
    
    section_query = SectionQuery()
    section_query.connect()
    print(section_query.get_cursor({})[0])
    print(section_query.client[section_query.db_name][section_query.collection_name].distinct('days_of_week'))
    print('HERE')
    section_query.disconnect()
    
    prof_query = ProfQuery()
    prof_query.connect()