def questionthread(request): if request.method == "POST": if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) if 'submitQnComment' in request.POST: idx = request.POST.get('submitQnComment') upload.submitQnComment(request) context = search.qnthread(request, idx) return render(request, 'questions/thread.html', context) if 'submitAnsComment' in request.POST: qnansid = request.POST.get('submitAnsComment') ids = qnansid.split(',') print(ids) upload.submitAnsComment(request) context = search.qnthread(request, ids[0]) return render(request, 'questions/thread.html', context) if 'addAnswer' in request.POST: idx = request.POST.get('addAnswer') upload.submitAnswer(request) context = search.qnthread(request, idx) return render(request, 'questions/thread.html', context) if request.method == "GET": if 'id' in request.GET: idx = request.GET.get("id") context = search.qnthread(request, idx) return render(request, 'questions/thread.html', context)
def uploadquestion(request): if request.method == "POST": if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) if request.method == 'POST': if 'submitqn' in request.POST: upload.uploadQn(request) return render(request, "uploader/index.html") data = dict() pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files\Tesseract-OCR\\tesseract.exe' image_form = ImageFileForm(request.POST or None, request.FILES or None) print(image_form.is_valid()) if ImageFile.objects.count() > 0: ImageFile.objects.all().delete() if image_form.is_valid(): image = image_form.save() image.execute_and_save_ocr() redirect('uploadquestion') image_last = ImageFile.objects.last() image_list = ImageFile.objects.all().order_by('-id') data['image_form'] = image_form data['image_list'] = image_list data['image_last'] = image_last return render(request, "uploader/index.html", data)
def notelist(request): if request.method == "POST": if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) context = search.allnotes(request) return render(request, 'notes/notelist.html', context)
def questionlist(request): if request.method == "POST": if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) context = search.allqns(request) return render(request, 'questions/questionlist.html', context)
def Profile(request): if request.method == "POST": if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) context = {'text': "Your profile has been edited!"} return render(request, 'profile.html', context) return render(request, 'profile.html')
def note(request): if request.method == "POST": if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) if request.method == "GET": if 'id' in request.GET: idx = request.GET.get('id') context = search.notebyId(request, idx) return render(request, 'notes/note.html', context)
def registerUser(request): if request.method == 'POST': if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) form = UserCreationForm(request.POST) if form.is_valid(): form.save() return redirect('login') else: form = UserCreationForm() return render(request, 'registration/signup.html', {'form': form})
def userLogin(request): context = {} if request.method == "POST": if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) username = request.POST.get('uname') password = request.POST.get('psw') user = authenticate(request, username=username, password=password) if user is not None: login(request, user) return redirect('home') else: context = {'msg': 'Failed'} return render(request, 'registration/login.html', context)
def upload_multiple_files(request): if request.method == 'POST': if 'searchword' in request.POST: context = search.searchbar(request) return render(request, 'results.html', context) else: form = UploadFileForm(request.POST, request.FILES) files = request.FILES.getlist('files') if form.is_valid(): for f in files: handle_uploaded_file(f) context = { 'msg': '<span style="color: green;">File successfully uploaded</span>' } return render(request, "uploader/multiple.html", context) else: form = UploadFileForm() return render(request, 'uploader/multiple.html', {'form': form})
def Home(request): if request.method == "POST": context = search.searchbar(request) return render(request, 'results.html', context) return render(request, 'home.html')