Exemple #1
0
def picture_detail(request, picture_id):
	if int(picture_id) > 0:
		picture_model=get_object_or_404(Picture, pk=picture_id)
	else:
		picture_model=Picture()
		picture_model.id = 0
	return render(request,
		'comp461app/picture_detail.html',
		{'picture_model':picture_model, 
		'error_message':request.GET.get('errormessage','')})
Exemple #2
0
def save_picture(request, picture_id):
	if not request.user.is_authenticated():
		return render(request,'comp461app/login.html',{})

	if not request.POST.get('Url') or not request.POST.get('ThumbUrl'):
		return HttpResponseRedirect('/picture/%s?errormessage=All field must be filled' % picture_id)
	if int(picture_id) > 0:
		picture_model=get_object_or_404(Picture, pk=picture_id)
	else:
		picture_model=Picture()
		picture_model.CreatedAt = datetime.now()
		picture_model.Likes=0
		picture_model.Dislikes=0

	picture_model.id=picture_id
	picture_model.Url=request.POST.get('Url')
	
	picture_model.CreatedBy_id = request.user.id
	#picture_model.save()
	save_picture_thumbnail(picture_model,request.POST.get('ThumbUrl'))
	return HttpResponseRedirect(request.GET.get('return_url','/picture/%s' % picture_model.id))