Beispiel #1
0
def insertDetails(request):
	if request.method == "POST":	
		uid = request.session['uID']
		name = request.POST['uname']
		add = request.POST['add']
		cty = request.POST['city']
		stat = request.POST['state']
		cntry = request.POST.get('country', False)
		pinno = request.POST['pin']
		contno = request.POST['contactno']
		res = Login.objects.get(id = uid)
		res.username = name
		res.save()
		request.session['uName'] = name
		try:
			ins = UserDetails.objects.get(uId_id = uid)
			ins.address = add
			ins.city = cty
			ins.state = stat
			ins.country = cntry
			ins.pin = pinno
			ins.contactno = contno
			ins.save()
			return render(request, 'loggedin.html', {"username" : name, "add" : add, "city" : cty, "state" : stat, "country" : cntry, 						"pin" : pinno, "contno" : contno, "status" : "Modify", "msg" : "Data Saved Successfully..."})
		except:
			ins = UserDetails(uId_id = uid, address = add, city = cty, state = stat, country = cntry, pin = pinno, contactno = contno)
			ins.save()
			return render(request, 'loggedin.html', {"username" : name, "add" : add, "city" : cty, "state" : stat, "country" : cntry, 						"pin" : pinno, "contno" : contno, "status" : "Modify", "msg" : "Data Saved Successfully..."})
	else:
		return viewDetails(request)
Beispiel #2
0
def insertDetails(request):
    if request.method == "POST":
        uid = request.session['uID']
        name = request.POST['uname']
        add = request.POST['add']
        cty = request.POST['city']
        stat = request.POST['state']
        cntry = request.POST.get('country', False)
        pinno = request.POST['pin']
        contno = request.POST['contactno']
        res = Login.objects.get(id=uid)
        res.username = name
        res.save()
        request.session['uName'] = name
        try:
            ins = UserDetails.objects.get(uId_id=uid)
            ins.address = add
            ins.city = cty
            ins.state = stat
            ins.country = cntry
            ins.pin = pinno
            ins.contactno = contno
            ins.save()
            return render(
                request, 'loggedin.html', {
                    "username": name,
                    "add": add,
                    "city": cty,
                    "state": stat,
                    "country": cntry,
                    "pin": pinno,
                    "contno": contno,
                    "status": "Modify",
                    "msg": "Data Saved Successfully..."
                })
        except:
            ins = UserDetails(uId_id=uid,
                              address=add,
                              city=cty,
                              state=stat,
                              country=cntry,
                              pin=pinno,
                              contactno=contno)
            ins.save()
            return render(
                request, 'loggedin.html', {
                    "username": name,
                    "add": add,
                    "city": cty,
                    "state": stat,
                    "country": cntry,
                    "pin": pinno,
                    "contno": contno,
                    "status": "Modify",
                    "msg": "Data Saved Successfully..."
                })
    else:
        return viewDetails(request)
Beispiel #3
0
def index(request):
    if request.method == 'POST':
        # save new post
        username = request.POST['username']
        password = request.POST['password']
        address = request.POST['address']

        post = UserDetails(username=username)
        post.password = password
        post.last_update = datetime.datetime.now()
        post.address = address
        post.save()

    # Get all posts from DB
    posts = UserDetails.objects
    return render_to_response('index.html', {'UserDetails': posts},
                              context_instance=RequestContext(request))