def upload_handler(request): view_url = reverse('upload.views.upload_handler') if request.method == 'POST': form = UploadForm(request.POST, request.FILE) form.save() return HttpResponseRedirect(view_url) upload_url, upload_data = prepare_upload(request, view_url, private=True) form = UploadForm() return direct_to_template(request, 'upload.html', {'form':form, 'upload_url':upload_url, 'upload_data':upload_data, 'uploads':UploadMOdel.objects.all(), 'names':names})
def home(request): print "in uploader" if request.method=="POST": img = UploadForm(request.POST, request.FILES) if img.is_valid(): img.save() return HttpResponseRedirect(reverse('imageupload')) else: img=UploadForm() images=Upload.objects.all() print "img: ", img print "images: ", images return render(request,'uploader/home.html',{'form':img,'images':images})
def create_design(request): if request.method == "POST": form = UploadForm(request.POST, request.FILES) if form.is_valid(): slug = form.cleaned_data["slug"] form.save() design = Design.objects.get(slug__iexact=slug) design.owner = request.user design.save() return HttpResponseRedirect(WIKI_PREFIX_URL + "accounts/") else: return render_to_response("wiki/create_design.html", {"form": form}) else: form = UploadForm() return render_to_response("wiki/create_design.html", {"form": form})
def upload_handler(request): extra_data = request.user.social_auth.get() print(extra_data.extra_data) view_url = reverse('upload.views.upload_handler') names = request.user.social_auth.values_list('provider', flat=True) if request.method == 'POST': form = UploadForm(request.POST, request.FILES) form.save() return HttpResponseRedirect(view_url) upload_url, upload_data = prepare_upload(request, view_url, private=True) form = UploadForm() return direct_to_template(request, 'upload.html', {'form': form, 'upload_url':upload_url, 'upload_data':upload_data, 'uploads':UploadModel.objects.all(), 'names':names})
def home(request): print "in uploader" if request.method == "POST": img = UploadForm(request.POST, request.FILES) if img.is_valid(): img.save() return HttpResponseRedirect(reverse('imageupload')) else: img = UploadForm() images = Upload.objects.all() print "img: ", img print "images: ", images return render(request, 'uploader/home.html', { 'form': img, 'images': images })
def create_design(request): if request.method == 'POST': form = UploadForm(request.POST, request.FILES) if form.is_valid(): slug = form.cleaned_data['slug'] form.save() design = Design.objects.get(slug__iexact=slug) design.owner = request.user design.save() return HttpResponseRedirect(WIKI_PREFIX_URL + 'accounts/') else: return render_to_response('wiki/create_design.html', {'form': form}) else: form = UploadForm() return render_to_response('wiki/create_design.html', {'form': form})
def upload_handler(request): view_url = reverse('upload.views.upload_handler') if request.method == 'POST': form = UploadForm(request.POST, request.FILES) form.save() return HttpResponseRedirect(view_url) upload_url, upload_data = prepare_upload(request, view_url) form = UploadForm() return direct_to_template(request, 'upload/upload.html', {'form': form, 'upload_url': upload_url, 'upload_data': upload_data, 'uploaded' : UploadModel.objects.all(), 'test_string' : test_basic_addition(), })
def upload_handler(request): view_url = reverse('upload.views.upload_handler') if request.method == 'POST': form = UploadForm(request.POST, request.FILE) form.save() return HttpResponseRedirect(view_url) upload_url, upload_data = prepare_upload(request, view_url, private=True) form = UploadForm() return direct_to_template( request, 'upload.html', { 'form': form, 'upload_url': upload_url, 'upload_data': upload_data, 'uploads': UploadMOdel.objects.all(), 'names': names })
def upload_handler(request): extra_data = request.user.social_auth.get() print(extra_data.extra_data) view_url = reverse('upload.views.upload_handler') names = request.user.social_auth.values_list('provider', flat=True) if request.method == 'POST': form = UploadForm(request.POST, request.FILES) form.save() return HttpResponseRedirect(view_url) upload_url, upload_data = prepare_upload(request, view_url, private=True) form = UploadForm() return direct_to_template( request, 'upload.html', { 'form': form, 'upload_url': upload_url, 'upload_data': upload_data, 'uploads': UploadModel.objects.all(), 'names': names })
def UploadImg(request): if request.method == "POST": images = Upload.objects.all() event = UploadForm(request.POST, request.FILES) poll = UpPolls(request.POST, instance=Poll()) cforms = [ UpChoice(request.POST, prefix=str(x), instance=Choice()) for x in range(0, 4) ] # choice1 = UpChoice1(request.POST, prefix='ch1') # choice2 = UpChoice2(request.POST, prefix='ch2') # choice3 = UpChoice3(request.POST, prefix='ch3') # choice4 = UpChoice4(request.POST, prefix='ch4') # # print "this is event",event # choices = FormVoteChoices(request.POST, request.FILES) for cf in cforms: print cf if event.is_valid() and poll.is_valid() and all( [cf.is_valid() for cf in cforms]): event.save() a = poll.save() for cf in cforms: new_choice = cf.save(commit=False) new_choice.poll = a new_choice.save() print "5555555555555555" # if a: # poll_list = Poll.objects.all() # print "poll: ",poll_list # print "Hello a: ",a # print "choice", choice.data['choice_text'] # if choice.is_valid: # c1 = Choice.objects.create(poll=a,choice_text=choice1.data['choice_text'],votes=0) # c1.save() # else: # print"not valid" # if choice2.is_valid: # c2 = Choice.objects.create(poll=a,choice_text=choice2.data['choice_text'],votes=0) # c2.save() # else: # print"not valid" # if choice3.is_valid: # c3 = Choice.objects.create(poll=a,choice_text=choice3.data['choice_text'],votes=0) # c3.save() # else: # print"not valid" # if choice4.is_valid: # c4 = Choice.objects.create(poll=a,choice_text=choice4.data['choice_text'],votes=0) # c4.save() # else: # print"not valid" print "success" print request.user.username return HttpResponseRedirect('/') else: print "fail" event = UploadForm() poll = UpPolls(instance=Poll()) cforms = [ UpChoice(prefix=str(x), instance=Choice()) for x in range(0, 4) ] # choice2 = UpChoice2() # choice3 = UpChoice3() # choice4 = UpChoice4() # choices = FormVoteChoices() images = Upload.objects.all() return render( request, 'addEvent.html', { 'form': event, 'images': images, 'username': request.user.username, 'poll': poll, 'choices': cforms })