コード例 #1
0
def add_post_index():
	posts = Post.objects.all()
	for post in posts:
		try:
			si = SearchIndex.objects.get(object_id=post.id,object_type='post')
			si.title = post.title
			si.content = post.body
		except:
			si = SearchIndex(
				title = post.title,
				content = post.body,
				object_id = post.id,
				object_type = 'post'
			)
		si.object_image_url = post.author.get_api_profile_image_url()
		si.save()
	print "Indexed ",posts.count()," posts."
コード例 #2
0
def add_course_index():
	courses = Courses.objects.all()
	for course in courses:
		try:
			si = SearchIndex.objects.get(object_id=course.id,object_type='course')
			si.title = course.name
			si.content = course.address1+' , '+course.city+' , '+str(course.zip_code)
			si.object_image_url = mysettings.SITE_URL+"/static/themes/img/default_profile_image_old.jpg"
		except:
			si = SearchIndex(
				title = course.name,
				content = course.address1+' , '+course.city+' , '+str(course.zip_code),
				object_id = course.id,
				object_type = 'course',
				object_image_url = mysettings.SITE_URL+"/static/themes/img/default_profile_image_old.jpg"
			)
		si.save()
	print "Indexed ",courses.count()," courses."
コード例 #3
0
def add_profile_index():
	users = GolfUser.objects.all()
	for user in users:
		try:
			si = SearchIndex.objects.get(object_id=user.id,object_type='profile')
			si.title = user.get_full_name()
			si.content = user.email
			si.private = user.is_private
		except:
			si = SearchIndex(
				title = user.get_full_name(),
				content = user.email,
				object_id = user.id,
				object_type = 'profile',
				private = user.is_private,
			)
		si.object_image_url = user.get_api_profile_image_url() 
		si.save()
	print "Indexed ",users.count()," users."
コード例 #4
0
def add_group_index():
	groups = Groups.objects.all()
	for group in groups:
		try:
			si = SearchIndex.objects.get(object_id=group.id,object_type='group')
			si.title = group.name
			si.content = group.description
			si.private = group.is_private
			si.object_image_url = group.get_api_crop_cover_image_url()
		except:
			si = SearchIndex(
				title = group.name,
				content = group.description,
				object_id = group.id,
				object_type = 'group',
				private = group.is_private,
				object_image_url = group.get_api_crop_cover_image_url()
			)
		si.save()
	print "Indexed ",groups.count()," groups."
コード例 #5
0
def add_event_index():
	events = Events.objects.all()
	for event in events:
		try:
			si = SearchIndex.objects.get(object_id=event.id,object_type='event')
			si.title = event.name
			si.content = event.venue+' , '+event.address1+' , '+event.city+' , '+str(event.zip_code)
			si.private = event.is_private
			si.object_image_url = event.get_api_crop_cover_image_url()
		except:
			si = SearchIndex(
				title = event.name,
				content = event.venue+' , '+event.address1+' , '+event.city+' , '+str(event.zip_code),
				object_id = event.id,
				object_type = 'event',
				private = event.is_private,
				object_image_url = event.get_api_crop_cover_image_url()
			)
		si.save()
	print "Indexed ",events.count()," events."