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'} # Toss out "student" positions in experience (v3 edit, 7/12) if data["title"] == "Student" or data["title"] == "student": return pos = Position() pos.entity = co pos.person = user for k,v in positionValues.iteritems(): if v in data: setattr(pos,k,data[v]) # check for start date if 'startDate' in data: pos.start_date = self.format_dates(data['startDate']) # check for end date if 'endDate' in data: pos.end_date = self.format_dates(data['endDate']) pos.save() # if pos.title: careers = careerlib.match_careers_to_position(pos) # match position to ideal position careerlib.match_position_to_ideals(pos) # print careers for c_id in careers: c = Career.objects.get(pk=c_id) # print c pos.careers.add(c) pos.save()
def add_unverified_position(self,user,co,data): """ Special case in which entity has no li_uniq_id, try and add "unverified" position TODO: merge this with add_position, only a single line difference Return: None """ positionValues = {'title':'title','description':'summary','current':'isCurrent'} pos = Position() pos.entity = co pos.person = user pos.status = "unverified" for k,v in positionValues.iteritems(): if v in data: setattr(pos,k,data[v]) # check for start date if 'startDate' in data: pos.start_date = self.format_dates(data['startDate']) # check for end date if 'endDate' in data: pos.end_date = self.format_dates(data['endDate']) pos.save() careers = careerlib.match_careers_to_position(pos) # match position to ideal position careerlib.match_position_to_ideals(pos) # print careers for c_id in careers: c = Career.objects.get(pk=c_id) # print c pos.careers.add(c) pos.save()
def add_ed_position(self,user,ed,data): """ Adds position with type='education', attempts to add 'degree' and 'field' if found Return: None """ pos = Position() pos.entity = ed pos.person = user pos.type = 'education' pos.title = 'Student' # not necessary, but convenient if 'degree' in data: pos.degree = data['degree'] if 'fieldOfStudy' in data: pos.field = data['fieldOfStudy'] # check for start date if 'start_date' in data: pos.start_date = self.format_dates(data['start_date']) # check for end date if 'end_date' in data: pos.end_date = self.format_dates(data['end_date']) pos.save()