예제 #1
0
	def get_batch_by_id(self, batchid):

		collection = self.batch_coll
		item = collection.find_one({'_id':batchid})

		if(item != None):
			single_batch = Batch()
			
			single_batch.set_id(item['_id'])
			single_batch.set_desc(item['desc'])
			single_batch.set_current_sem(item['current_sem'])
			single_batch.set_subject_array(self.construct_subject_master(item))
			single_batch.set_status(item['status'])

			return single_batch
		
		return None
예제 #2
0
	def get_all_batches(self):

		collection = self.batch_coll
		result = collection.find()

		batches = []
		for item in result:
			
			single_batch = Batch()
			
			single_batch.set_id(item['_id'])
			single_batch.set_desc(item['desc'])
			single_batch.set_current_sem(item['current_sem'])
			single_batch.set_subject_array(self.construct_subject_master(item))
			single_batch.set_status(item['status'])

			batches.append(single_batch)

		# print json.dumps(batches, default=Batch.__str__)
		return batches