def getDoc(request): if (request.method == "POST" and request.user is not None): post = request.POST usert = request.user pf = PF(request.POST, request.FILES) if pf.is_valid(): print pf.cleaned_data["pdf"].name a = Auther(name=pf.cleaned_data["auther"], institution=pf.cleaned_data["institution"]) j = Jounery(J_name=pf.cleaned_data["jounery"]) p = Paper(user=usert, timestamp=time.localtime(time.time()), pdf=pf.cleaned_data["pdf"], pdfname=pf.cleaned_data["pdf"].name) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() try: j = Jounery.objects.get(J_name=j.J_name) except ObjectDoesNotExist: j.save() p.jounery = j p.save() p.MauthorID = a.id p.auther.add(a) p.save() return HttpResponseRedirect('/paper/view/') else: print pf return notvalid() else: return render(request, "upload.html")
def changeau(req): if (req.method == "POST" and req.GET.get('Aid', False) and req.GET.get('Pid', False)): g = req.GET pap = Paper.objects.get(id=g['Pid']) au = Auther.objects.get(id=g['Aid']) aid = au.id pap.auther.remove(au) af = AF(req.POST) if (af.is_valid()): a = Auther( name=af.cleaned_data["auther"], institution=af.cleaned_data["institution"] ) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() pap.auther.add(a) if (pap.MauthorID == aid): pap.MauthorID = a.id pap.save() return HttpResponseRedirect("/paper/view/") else: return notvalid() elif (req.method == "GET" and req.GET.get('Aid', False) and req.GET.get('Pid', False)): g = req.GET pap = Paper.objects.get(id=g['Pid']) au = Auther.objects.get(id=g['Aid']) return render_to_response("changeauthor.html", {"au": au}) return notvalid() return notvalid()
def changeau(req): if (req.method == "POST" and req.GET.get('Aid', False) and req.GET.get('Pid', False)): g = req.GET pap = Paper.objects.get(id=g['Pid']) au = Auther.objects.get(id=g['Aid']) aid = au.id pap.auther.remove(au) af = AF(req.POST) if (af.is_valid()): a = Auther(name=af.cleaned_data["auther"], institution=af.cleaned_data["institution"]) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() pap.auther.add(a) if (pap.MauthorID == aid): pap.MauthorID = a.id pap.save() return HttpResponseRedirect("/paper/view/") else: return notvalid() elif (req.method == "GET" and req.GET.get('Aid', False) and req.GET.get('Pid', False)): g = req.GET pap = Paper.objects.get(id=g['Pid']) au = Auther.objects.get(id=g['Aid']) return render_to_response("changeauthor.html", {"au": au}) return notvalid() return notvalid()
def addauthor1(req): if (req.method == "GET" and req.GET.get('id', False)): g = req.GET pap = Paper.objects.get(id=g['id']) if (pap and pap.user == req.user): af = AF() return render(req, "addauthor.html") elif (req.method == "POST"): g = req.GET pap = Paper.objects.get(id=g['id']) af = AF(req.POST) if (af.is_valid()): a = Auther( name=af.cleaned_data["auther"], institution=af.cleaned_data["institution"] ) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() pap.auther.add(a) pap.save() return HttpResponseRedirect("/paper/view/") else: return notvalid()
def change(req): if (req.method == "GET" and req.GET.get('id', False)): g = req.GET pap = Paper.objects.get(id=g['id']) if (pap and pap.user == req.user): au = Auther.objects.get(id=pap.MauthorID) # pap.delete() return render_to_response("change.html", {"paper": pap, "au": au}) elif (req.method == "POST" and req.GET.get('id', False)): g = req.GET pf = PF(req.POST, req.FILES) try: pap = Paper.objects.get(id=g['id']) au = Auther.objects.get(id=pap.MauthorID) except ObjectDoesNotExist: return notvalid() pap.auther.remove(au) if (pf.is_valid()): a = Auther( name=pf.cleaned_data["auther"], institution=pf.cleaned_data["institution"] ) j = Jounery( J_name=pf.cleaned_data["jounery"] ) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() try: j = Jounery.objects.get(J_name=j.J_name) except ObjectDoesNotExist: j.save() pap.jounery = j pap.pdf = pf.cleaned_data["pdf"] pap.pdfname = pf.cleaned_data["pdf"].name pap.MauthorID = a.id pap.auther.add(a) pap.save() return HttpResponseRedirect("/paper/view/") else: return notvalid() else: return notvalid()
def change(req): if (req.method == "GET" and req.GET.get('id', False)): g = req.GET pap = Paper.objects.get(id=g['id']) if (pap and pap.user == req.user): au = Auther.objects.get(id=pap.MauthorID) # pap.delete() return render_to_response("change.html", {"paper": pap, "au": au}) elif (req.method == "POST" and req.GET.get('id', False)): g = req.GET pf = PF(req.POST, req.FILES) try: pap = Paper.objects.get(id=g['id']) au = Auther.objects.get(id=pap.MauthorID) except ObjectDoesNotExist: return notvalid() pap.auther.remove(au) if (pf.is_valid()): a = Auther(name=pf.cleaned_data["auther"], institution=pf.cleaned_data["institution"]) j = Jounery(J_name=pf.cleaned_data["jounery"]) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() try: j = Jounery.objects.get(J_name=j.J_name) except ObjectDoesNotExist: j.save() pap.jounery = j pap.pdf = pf.cleaned_data["pdf"] pap.pdfname = pf.cleaned_data["pdf"].name pap.MauthorID = a.id pap.auther.add(a) pap.save() return HttpResponseRedirect("/paper/view/") else: return notvalid() else: return notvalid()
def getDoc(request): if (request.method == "POST" and request.user is not None): post = request.POST usert = request.user pf = PF(request.POST, request.FILES) if pf.is_valid(): print pf.cleaned_data["pdf"].name a = Auther( name=pf.cleaned_data["auther"], institution=pf.cleaned_data["institution"] ) j = Jounery( J_name=pf.cleaned_data["jounery"] ) p = Paper( user=usert, timestamp=time.localtime(time.time()), pdf=pf.cleaned_data["pdf"], pdfname=pf.cleaned_data["pdf"].name ) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() try: j = Jounery.objects.get(J_name=j.J_name) except ObjectDoesNotExist: j.save() p.jounery = j p.save() p.MauthorID = a.id p.auther.add(a) p.save() return HttpResponseRedirect('/paper/view/') else: print pf return notvalid() else: return render(request, "upload.html")
def addauthor1(req): if (req.method == "GET" and req.GET.get('id', False)): g = req.GET pap = Paper.objects.get(id=g['id']) if (pap and pap.user == req.user): af = AF() return render(req, "addauthor.html") elif (req.method == "POST"): g = req.GET pap = Paper.objects.get(id=g['id']) af = AF(req.POST) if (af.is_valid()): a = Auther(name=af.cleaned_data["auther"], institution=af.cleaned_data["institution"]) try: a = Auther.objects.get(name=a.name) except ObjectDoesNotExist: a.save() pap.auther.add(a) pap.save() return HttpResponseRedirect("/paper/view/") else: return notvalid()