Beispiel #1
0
def add(request):
	from brandpic.brands.functions import input_to_words, add_brands_to_user

	if request.method == 'POST':
		brands = request.POST['brands']
		words = input_to_words(brands)
		add_brands_to_user(words, request.user)
		return HttpResponseRedirect('/brands/my_brands')

	return render_to_response('brands/add.html', 
		{},
		context_instance=RequestContext(request))
Beispiel #2
0
def post(request):
	if request.method == 'POST':
		form = PictureForm(request.POST, request.FILES)
		if form.is_valid():
			picture = form.save(commit=False)
			picture.owner = request.user
			picture.save()

			#Adding brands to picture
			words = input_to_words(request.POST['brands'])
			add_brands(words, picture)

			fb = get_persistent_graph(request)
			picture_to_upload = picture.get_url()
			fb.set('me/photos', url=picture_to_upload, message=picture.description)
			messages.info(request, 'Imagen subida correctamente')

			return HttpResponseRedirect('/pictures/view/%s' % (picture.pk))
	else:
		form = PictureForm()
	return render_to_response('pictures/post.html', 
			{'form' : form}, 
			context_instance=RequestContext(request))
Beispiel #3
0
def post(request):
    if request.method == 'POST':
        form = PictureForm(request.POST, request.FILES)
        if form.is_valid():
            picture = form.save(commit=False)
            picture.owner = request.user
            picture.save()

            #Adding brands to picture
            words = input_to_words(request.POST['brands'])
            add_brands(words, picture)

            fb = get_persistent_graph(request)
            picture_to_upload = picture.get_url()
            fb.set('me/photos',
                   url=picture_to_upload,
                   message=picture.description)
            messages.info(request, 'Imagen subida correctamente')

            return HttpResponseRedirect('/pictures/view/%s' % (picture.pk))
    else:
        form = PictureForm()
    return render_to_response('pictures/post.html', {'form': form},
                              context_instance=RequestContext(request))