Пример #1
0
def search(request):
	#Get the information from the page
	if request.GET['search'] == '':
		context = {'error' : "No search tags submitted"}
		return render_to_response('Picr/search.html', context)
	else:
		tags = request.GET['search']
		tags = tags.split(" ")
		search_results = []
		#Get the individual tag in the list of tags that the user submitted
		for tag in tags:
			#Check to see if any image contains that tags
			list = Image.objects.filter(image_tags__contains=tag)
			for item in list:
				#Check to see if that image is already in the list
				x = image_obj(item.image_filename, item.image_tags, item.image_upload_date)
				#If it is in the list tlthen leave it out
				if search_results.count(x) >= 1:
					break
				#Otherwise add it to the search_results list
				else:
					search_results.append(x)
		
		
		
#Get the data for the page
		context = {'tags' : tags, 'search_results' : search_results}
		return render_to_response('Picr/search.html', context)
Пример #2
0
def gallery(request):
	
	#Create a dictionary to hold the gallery images
	gallery_dict = []
	#List all of the images
	list = Image.objects.all()

	#Iterate through the list, get the image information, make an object with it and then append it to a dictionary.
	for x in list:
		item = image_obj(x.image_filename, x.image_tags, x.image_upload_date)
		gallery_dict.append(item)

#Get the data for the page
	context = {'gallery_dict' : gallery_dict}
	return render_to_response('Picr/gallery.html', context)