Exemple #1
0
	def add_ed_position(self,user,ed,data):
		pos = Position()
		pos.entity = ed
		pos.person = user
		pos.type = 'education'
		pos.degree = data['degree']
		pos.field = data['fieldOfStudy']
		
		# check for start date
		if 'startDate' in data:
			# check for month value
			if 'month' in data['startDate']:
				start_date = datetime.strptime(str(data['startDate']['month'])+"/"+str(data['startDate']['year']),"%m/%Y")
			else:
				start_date = datetime.strptime(str(data['startDate']['year']),"%Y")
			pos.start_date = start_date
		# check for end date
		if 'endDate' in data:
			# check for month value
			if 'month' in data['endDate']:
				end_date = datetime.strptime(str(data['endDate']['month'])+"/"+str(data['endDate']['year']),"%m/%Y")
			else:
				end_date = datetime.strptime(str(data['endDate']['year']),"%Y")
			pos.end_date = end_date
		pos.save()
Exemple #2
0
	def add_position(self,user,co,data):
		# dectionary of values to test for and then add if present
		positionValues = {'title':'title','description':'summary','current':'isCurrent'}
		
		pos = Position()
		pos.entity = co
		pos.person = user

		for k,v in positionValues.iteritems():
			if v in data:
				setattr(pos,k,data[v])
		
			# pos.title = data['title']
			# pos.summary = data['headline']
			# pos.description = data['summary']
			# pos.start_date = data['start-date']
			# pos.end_date = data['end-date']
			# pos.current = data['is-current']
		
		# check for start date
		if 'startDate' in data:
			# check for month value
			if 'month' in data['startDate']:
				start_date = datetime.strptime(str(data['startDate']['month'])+"/"+str(data['startDate']['year']),"%m/%Y")
			elif 'year' in data['startDate']:
				start_date = datetime.strptime(str(data['startDate']['year']),"%Y")
			else:
				start_date = datetime.strptime(data['startDate'],"%Y-%m-%d")
			pos.start_date = start_date
		# check for end date
		if 'endDate' in data:
			# check for month value
			if 'month' in data['endDate']:
				end_date = datetime.strptime(str(data['endDate']['month'])+"/"+str(data['endDate']['year']),"%m/%Y")
			elif 'year' in data['endDate']:
				end_date = datetime.strptime(str(data['endDate']['year']),"%Y")
			else:
				end_date = datetime.strptime(data['endDate'],"%Y-%m-%d")
			pos.end_date = end_date
		pos.save()