예제 #1
0
def newuser(request, utype, password, email):
    response = {}
    if request.method == "POST":
        user = authenticate(username=email, password=password)
        if user is not None:
            if not user.is_active:
                print "User is registering"
                first_name = request.POST['first_name']
                password = request.POST['password']
                conpassword = request.POST['conpassword']
                if password == conpassword:
                    user.set_password(password)
                    user.first_name = first_name
                    user.is_active = True
                    user.save()
                    userp = UserProfile()
                    userp.user = user
                    userp.collegeName = request.POST['collegeName']
                    userp.phone = request.POST['telephone']
                    userp.description = request.POST['description']
                    userp.usertype = utype
                    if request.FILES['picture']:
                        userp.profilepicture = request.FILES['picture']
                    else:
                        userp.profilepicture = 'default.jpg'
                    userp.lastLoginDate = datetime.now()
                    userp.save()
                    if utype == 'Organisation':
                        org = Organisation()
                        org.user = user
                        org.name = request.POST['first_name']
                        org.description = request.POST['description']
                        if request.FILES['picture']:
                            org.logo = request.FILES['picture']
                        else:
                            org.logo = 'default.jpg'
                        org.address = request.POST['address']
                        org.save()
                    return HttpResponseRedirect('/login')
                else:
                    response['message'] = "Password not matching"
            else:
                response['message'] = 'User already active'
        else:
            response['message'] = 'User is not allowed to be registered'
    response['utype'] = utype
    response['password'] = password
    response['email'] = email
    return render(request, 'site/registernewuser.html', response)
예제 #2
0
def newuser(request,utype,password,email):
	response={}
	if request.method == "POST":
		user=authenticate(username=email, password=password)
		if user is not None:
			if not user.is_active:
				print "User is registering"
				first_name=request.POST['first_name']
				password=request.POST['password']
				conpassword=request.POST['conpassword']
				if password == conpassword:
					user.set_password(password)
					user.first_name=first_name
					user.is_active=True
					user.save()
					userp=UserProfile()
					userp.user=user
					userp.collegeName=request.POST['collegeName']
					userp.phone=request.POST['telephone']
					userp.description=request.POST['description']
					userp.usertype=utype
					if request.FILES['picture']:
						userp.profilepicture=request.FILES['picture']
					else:
						userp.profilepicture='default.jpg'
					userp.lastLoginDate=datetime.now()
					userp.save()
					if utype == 'Organisation':
						org=Organisation()
						org.user=user
						org.name=request.POST['first_name']
						org.description=request.POST['description']
						if request.FILES['picture']:
							org.logo=request.FILES['picture']
						else:
							org.logo='default.jpg'
						org.address=request.POST['address']
						org.save()
					return HttpResponseRedirect('/login')
				else:
					response['message']="Password not matching"
			else:
				response['message']='User already active'
		else:
			response['message']='User is not allowed to be registered'
	response['utype']=utype
	response['password']=password
	response['email']=email
	return render(request,'site/registernewuser.html',response)
예제 #3
0
def newusercap(request, utype, password, email, capadminid):
    print "newusercap"
    response = {}
    if request.method == "POST":
        user = authenticate(username=email, password=password)
        if user is not None:
            if not user.is_active:
                print "User is registering"
                first_name = request.POST['first_name']
                password = request.POST['password']
                conpassword = request.POST['conpassword']
                if password == conpassword:
                    user.set_password(password)
                    user.first_name = first_name
                    user.is_active = True
                    user.save()
                    userp = UserProfile()
                    userp.user = user
                    userp.collegeName = request.POST['collegeName']
                    userp.phone = request.POST['telephone']
                    userp.description = request.POST['description']
                    userp.usertype = utype
                    if request.FILES['picture']:
                        userp.profilepicture = request.FILES['picture']
                    else:
                        userp.profilepicture = 'default.jpg'
                    userp.lastLoginDate = datetime.now()
                    userp.save()
                    cap = CapMember()
                    cap.capadmin = User.objects.get(id=capadminid)
                    cap.capmember = user
                    cap.save()
                    return HttpResponseRedirect('/login')
                else:
                    response['message'] = "Password not matching"
            else:
                response['message'] = 'User already active'
        else:
            response['message'] = 'User is not allowed to be registered'
    response['utype'] = utype
    response['password'] = password
    response['email'] = email
    response['capadminid'] = capadminid
    response['capadmin'] = User.objects.get(id=capadminid)
    return render(request, 'site/registernewuser.html', response)
예제 #4
0
def newusercap(request,utype,password,email,capadminid):
	print "newusercap"
	response={}
	if request.method == "POST":
		user=authenticate(username=email, password=password)
		if user is not None:
			if not user.is_active:
				print "User is registering"
				first_name=request.POST['first_name']
				password=request.POST['password']
				conpassword=request.POST['conpassword']
				if password == conpassword:
					user.set_password(password)
					user.first_name=first_name
					user.is_active=True
					user.save()
					userp=UserProfile()
					userp.user=user
					userp.collegeName=request.POST['collegeName']
					userp.phone=request.POST['telephone']
					userp.description=request.POST['description']
					userp.usertype=utype
					if request.FILES['picture']:
						userp.profilepicture=request.FILES['picture']
					else:
						userp.profilepicture='default.jpg'
					userp.lastLoginDate=datetime.now()
					userp.save()
					cap=CapMember()
					cap.capadmin=User.objects.get(id=capadminid)
					cap.capmember=user
					cap.save()
					return HttpResponseRedirect('/login')
				else:
					response['message']="Password not matching"
			else:
				response['message']='User already active'
		else:
			response['message']='User is not allowed to be registered'
	response['utype']=utype
	response['password']=password
	response['email']=email
	response['capadminid']=capadminid
	response['capadmin']=User.objects.get(id=capadminid)
	return render(request,'site/registernewuser.html',response)