def findfile(request): if ( request.method == 'POST' ): form = FileForm(request.POST) if form.is_valid(): cd = form.cleaned_data new_name = cd['name'] return HttpResponseRedirect(reverse('testsite_detailfile', kwargs = {'new_name':new_name})) else: form = FileForm() return render(request, 'harddrives/findfile.html',{ 'form':form, 'error_message':"File not found"}) else: form = FileForm() return render(request, 'harddrives/findfile.html', {'form':form})
def addfile( request): if ( request.method == 'POST' ): form = FileForm(request.POST) if form.is_valid(): new_name = form.cleaned_data['name'] try: f = File.objects.get(name=new_name) except ObjectDoesNotExist: f = File(name=new_name) f.save() return HttpResponseRedirect(reverse('testsite_addharddrive', kwargs = {'file_name' : new_name})) else: return HttpResponseRedirect(reverse('testsite_homepage')) else: form = FileForm() return render(request, 'harddrives/addfile.html', {'form':form})
def addfile(request): if (request.method == 'POST'): form = FileForm(request.POST) if form.is_valid(): new_name = form.cleaned_data['name'] try: f = File.objects.get(name=new_name) except ObjectDoesNotExist: f = File(name=new_name) f.save() return HttpResponseRedirect( reverse('testsite_addharddrive', kwargs={'file_name': new_name})) else: return HttpResponseRedirect(reverse('testsite_homepage')) else: form = FileForm() return render(request, 'harddrives/addfile.html', {'form': form})
def findfile(request): if (request.method == 'POST'): form = FileForm(request.POST) if form.is_valid(): cd = form.cleaned_data new_name = cd['name'] return HttpResponseRedirect( reverse('testsite_detailfile', kwargs={'new_name': new_name})) else: form = FileForm() return render(request, 'harddrives/findfile.html', { 'form': form, 'error_message': "File not found" }) else: form = FileForm() return render(request, 'harddrives/findfile.html', {'form': form})