def eval_organizations(elem):
	"""
	Parses data from "<Organization />" tags
	Stores in Django model
	Saves model to mysql database
	"""
	for o in elem :
		assert o.get('ID') != None
		assert o.get('Name') != None
		org = Organization(name = o.get('Name'), wcdb_id = o.get('ID'))
		people = o.find('People')
		org.save()
		list_people = Person.objects.all()
		if (people != None):
			for p in people:
				for person in list_people:
					if (p.get('ID') == person.wcdb_id):
						org.people.add(person)
						break
		kind = o.find('Kind')
		location = o.find('Location')
		hist = o.find('History')
		contact = o.find('ContactInfo')
		common = o.find('Common')
		if(kind != None):
			org.kind = kind.text
		if(location != None):
			org.location =  location.text
		if(hist != None):
				org.history += listings(hist)
		if(contact != None):
				org.contact += listings(contact)
		if(common != None):
			make_common(common, org)
		org.save()
def merge_organizations(elem):
	"""
	Parses data from "<Organization />" tags
	Stores in Django model
	Saves model to mysql database
	"""
	for o in elem :
		org_filter_obj = Organization.objects.filter(wcdb_id = o.get('ID'))
		if (len(org_filter_obj) != 0):
			org = org_filter_obj[0]	#if org exists, use it
			org.name = o.get('Name')
		else:				#else make a new one
			org = Organization(name = o.get('Name'), wcdb_id = o.get('ID'))
		people = o.find('People')
		org.save()
		list_people = Person.objects.all()
		if (people != None):
			for p in people:
				for person in list_people:
					if (p.get('ID') == person.wcdb_id):
						if(len(org_filter_obj.filter(people__wcdb_id__exact = p.get('ID'))) == 0):
							org.people.add(person)
							break
		kind = o.find('Kind')
		location = o.find('Location')
		hist = o.find('History')
		contact = o.find('ContactInfo')
		common = o.find('Common')
		if (kind != None):
			org.kind = kind.text
		if (location != None):
			org.location =  location.text
		if (hist != None):
			str_hist = org.history.split('\n')
			list_hist = listings(hist).split('\n')
			listunion(str_hist, list_hist)
			org.history = '\n'.join(str_hist)
		if (contact != None):
			str_contact = org.contact.split('\n')
			list_contact = listings(contact).split('\n')
			listunion(str_contact, list_contact)
			org.contact = '\n'.join(str_contact)
		if (common != None):
			merge_common(common, org)
		org.save()