示例#1
0
def index(request):
	if request.method == "GET":		
		albums = Album.objects.values('name')
		
		# generate thumbnail pic from each of the albums. if album is empty, no pic urls are stored.
		thumbnail = generate_album_thumbnail(albums)

		context_instance=RequestContext(request,
										{'albums':albums, 'thumb_nail':thumbnail})
		return render_to_response('index.html', context_instance)
	return render('index.html')
示例#2
0
def profile_view(request):
	"""Setup and get the profile view of users."""
	if request.user.is_authenticated():
		# get user instance
		user = User.objects.get(username=request.user)
		
		# put user usage stats into dictionary
		stats = {}
		stats['album_count'] = get_user_albums_count(user)
		stats['picture_count'] = get_user_picture_count(user)
		
		# get all albums by users
		albums = Album.objects.get_user_posted_albums(user)
		# store album names in a dict
		album_names = dictionary_store(albums)

		# generate thumbnail
		thumbnail = generate_album_thumbnail(album_names)
		
		context_instance = RequestContext(request, {'user': user, 'stats':stats, 'thumb_nail':thumbnail})
		return render_to_response('reg/account.html', context_instance)
	else:
		HttpResponseRedirect(reverse('login'))