Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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")