예제 #1
0
	def post(self,urlParameter):
		flag = 0;
		link = self.request.get("project")
		user=users.get_current_user()
		if user:
			userid = user.user_id()
			userAuth = User.query(User.userid == userid).fetch(1)
			if userAuth:
				funds = self.request.get("funds")
				ngo, title = link.split("_")
				print title
				q = ndb.gql("SELECT * FROM Project WHERE link = :1 AND ngo = :2", title,ngo).fetch(1)
				for p in userAuth[0].projects:
					if p[0] == link:
						p[1] = p[1] + funds
						flag = 1
				if(flag == 0):
					userAuth[0].projects.append([link,funds])
				userAuth[0].projects = sorted(userAuth[0].projects, key=lambda tup: tup[1])
				userAuth[0].put()
				q[0].funding.append((userid,funds))
				q[0].put()
				parameter = {"message":"You Have Successfully Funded a Project.","title":"Successfully Funded"}
			else:
				parameter = {"message":"You Are Not Authorized to Fund a Project.","title":"Error"}
		else:
			parameter = {"message":"Please Login to Fund a Project.","title":"Error"}
		self.render("message.html",parameter)
예제 #2
0
	def get(self):
		user=users.get_current_user()
		try:
			hitCount = HitCount.query().fetch(1)[0]
			hits = int(hitCount.hitCount) + 1
		except:
			hits = 0
			hitCount = HitCount()
		hitCount.hitCount = str(hits)
		hitCount.put()
		if user:
			userid = user.user_id()
 	    		userAuthenticationQuery = User.query(User.userid == userid).fetch(1)	 	    	      
                        NGOauthenticationQuery = NGO.query(NGO.userid == userid).fetch(1)
                        if (not userAuthenticationQuery) and (not NGOauthenticationQuery) :
				self.redirect("/signup/registration")
		projects = Project.query().fetch()
		randProjects = []
		try:
			for i in range(0,4):
				randomInt = randint(0,len(projects)-1)
				if projects[randomInt] not in randProjects:
					randProjects.append(projects[randomInt])
		except:
			pass
		parameter = {"projects" : randProjects, "hits":hits}
		self.render('frontPage.html', parameter)        
예제 #3
0
 def post(self):
         detailedDescription = self.request.get("detailedDescription")
         
         count=int(self.request.get("count"))
         projectObject = Project()
         user=users.get_current_user()
         if user:
                 userid = user.user_id()
                 authenticationUser = User.query(User.userid==userid).fetch(1)
                 authenticationNGO = NGO.query(NGO.userid==userid).fetch(1)
                 if authenticationNGO:
                         ngo = projectObject.ngo
                         existingProject = Project.query(Project.ngo==userid).fetch(1)
                         if existingProject:
                                 projectObject.detailedDescription = detailedDescription
                                 while count>0:
                                         j=1
                                         Counter=str(count-count+j)
                                         taskTitle = self.request.get("taskTitle"+Counter)
                                         taskDescription = self.request.get("taskDescription"+Counter)
                                         taskFund = self.request.get("taskFund"+Counter)
                                         count=count-1
                                         j=j-1
                                         projectObject.tasks = [TaskList(taskTitle = taskTitle, taskDescription = taskDescription, taskFund = taskFund)]
                                 projectObject.put()
                                 self.redirect("/home")
                         else:
                                 self.redirect("/propose")
                 elif authenticationUser:
                         self.redirect("/home")
                 else:
                         self.redirect("/")
         else:
                 self.redirect("/login")
예제 #4
0
	def get(self):
		user=users.get_current_user()
		if user:
			userid = user.user_id()
			userAuth = User.query(User.userid == userid).fetch(1)
			ngoAuth = NGO.query(NGO.userid == userid).fetch(1)
			if userAuth:
				userProj = []
				link = userAuth[0].projects
				for p in link:
					ngo, title = p[0].split("_")
					projects = ndb.gql("SELECT * FROM Project WHERE link = :1 AND ngo = :2", title,ngo).fetch(1)
					if projects:
						userProj.append((projects[0],p[1]));
						print userProj
				parameter = {"proj":userProj, "user": 1, "length":len(userProj)}
				self.render("/userProjects.html",parameter)
			elif ngoAuth:
				ngoProjects = []
				ngoAuth
				for p in ngoAuth:
					proj = Project.query(Project.ngo == p.userid).fetch(1)
					ngoProjects.append(proj[0]);
				print ngoAuth[0]
				parameter = {"ngoProjects":ngoProjects, "user": 0, "length":len(ngoProjects),"ngo":ngoAuth[0]}
				self.render("/ngoProjects.html",parameter)
		else:
			self.render("/login.html")
 def get(self):
     user = users.get_current_user()
     try:
         hitCount = HitCount.query().fetch(1)[0]
         hits = int(hitCount.hitCount) + 1
     except:
         hits = 0
         hitCount = HitCount()
     hitCount.hitCount = str(hits)
     hitCount.put()
     if user:
         userid = user.user_id()
         userAuthenticationQuery = User.query(
             User.userid == userid).fetch(1)
         NGOauthenticationQuery = NGO.query(NGO.userid == userid).fetch(1)
         if (not userAuthenticationQuery) and (not NGOauthenticationQuery):
             self.redirect("/signup/registration")
     projects = Project.query().fetch()
     randProjects = []
     try:
         for i in range(0, 4):
             randomInt = randint(0, len(projects) - 1)
             if projects[randomInt] not in randProjects:
                 randProjects.append(projects[randomInt])
     except:
         pass
     parameter = {"projects": randProjects, "hits": hits}
     self.render('frontPage.html', parameter)
예제 #6
0
 def post(self):
         detailedDescription = self.request.get("detailedDescription")
         
         count=int(self.request.get("count"))
         projectObject = Project()
         user=users.get_current_user()
         if user:
                 userid = user.user_id()
                 authenticationUser = User.query(User.userid==userid).fetch(1)
                 authenticationNGO = NGO.query(NGO.userid==userid).fetch(1)
                 if authenticationNGO:
                         ngo = projectObject.ngo
                         existingProject = Project.query(Project.ngo==userid).fetch(1)
                         if existingProject:
                                 projectObject.detailedDescription = detailedDescription
                                 while count>0:
                                         j=1
                                         Counter=str(count-count+j)
                                         taskTitle = self.request.get("taskTitle"+Counter)
                                         taskDescription = self.request.get("taskDescription"+Counter)
                                         taskFund = self.request.get("taskFund"+Counter)
                                         count=count-1
                                         j=j-1
                                         projectObject.tasks = [TaskList(taskTitle = taskTitle, taskDescription = taskDescription, taskFund = taskFund)]
                                 projectObject.put()
                                 self.redirect("/home")
                         else:
                                 self.redirect("/propose")
                 elif authenticationUser:
                         self.redirect("/home")
                 else:
                         self.redirect("/")
         else:
                 self.redirect("/login")
예제 #7
0
	def get(self):
		user=users.get_current_user()
		if user:
			userid = user.user_id()
			userAuth = User.query(User.userid == userid).fetch(1)
			ngoAuth = NGO.query(NGO.userid == userid).fetch(1)
			if userAuth:
				userProj = []
				link = userAuth[0].projects
				for p in link:
					ngo, title = p[0].split("_")
					projects = ndb.gql("SELECT * FROM Project WHERE link = :1 AND ngo = :2", title,ngo).fetch(1)
					if projects:
						userProj.append((projects[0],p[1]));
						print userProj
				parameter = {"proj":userProj, "user": 1, "length":len(userProj)}
				self.render("/userProjects.html",parameter)
			elif ngoAuth:
				ngoProjects = []
				link = ngoAuth[0].projects
				for p in link:
					proj = Project.query(Project.ngo == p.userid).fetch(1)
					ngoProjects.append(proj[0]);
				parameter = {"projects":ngoProjects, "user": 0, "length":len(ngoProjects),"ngo":ngoAuth[0]}
				self.render("/ngoProjects.html",parameter)
		else:
			self.render("/login.html")
예제 #8
0
	def post(self,urlParameter):
		flag = 0;
		link = self.request.get("project")
		user=users.get_current_user()
		if user:
			userid = user.user_id()
			userAuth = User.query(User.userid == userid).fetch(1)
			if userAuth:
				funds = self.request.get("funds")
				ngo, title = link.split("_")
				print title
				q = ndb.gql("SELECT * FROM Project WHERE link = :1 AND ngo = :2", title,ngo).fetch(1)
				for p in userAuth[0].projects:
					if p[0] == link:
						p[1] = p[1] + funds
						flag = 1
				if(flag == 0):
					userAuth[0].projects.append([link,funds])
				userAuth[0].projects = sorted(userAuth[0].projects, key=lambda tup: tup[1])
				userAuth[0].put()
				q[0].funding.append((userid,funds))
				q[0].put()
				parameter = {"message":"You Have Successfully Funded a Project."}
			else:
				parameter = {"message":"You Are Not Authorized to Fund a Project."}
		else:
			parameter = {"message":"Please Login to Fund a Project."}
		self.render("message.html",parameter)
예제 #9
0
 def get(self):
     user = users.get_current_user()
     if user:
         userid = user.user_id()
         authenticationQuery = User.query(User.userid == userid).fetch(1)
         if not authenticationQuery:
             self.redirect("/signup/registration")
     self.render('frontPage.html')
def createUser():
    newName = valName(input("Name: "))
    newUsername = valUsername(input("Username: "******"Password: "******"Repeat Password: "******"Account Type(Admin, SuperAdmin or Editor): "))
    db.append(User(newName, newUsername, newPassword, accRole).toDictionary())
    with open("newDB.json", 'w') as json_file:
        json.dump(db, json_file)
예제 #11
0
	def get(self):
		user=users.get_current_user()
		if user:
			userid = user.user_id()
 	    		authenticationQuery = User.query(User.userid == userid).fetch(1)	 	    	      
			if not authenticationQuery:
				self.redirect("/signup/registration")    
		self.render('frontPage.html')        
예제 #12
0
	def post(self):
		user= users.get_current_user()
		if user:
			userid = user.user_id()
			authenticationUser = User.query(User.userid == userid).fetch(1)
			authenticationNgo = NGO.query(NGO.userid == userid).fetch(1)
			if authenticationUser or authenticationNgo:
				self.redirect("/home")
			else:
				name = self.request.get("name")	
				email = user.email()
				description = self.request.get("description")
				pancardNumber = self.request.get("pancardNumber")
				chiefFunctionary = self.request.get("chiefFunctionary")
				chairman = self.request.get("chairman")
				sectorOfOperation = self.request.get("sectorOfOperation")
				stateOfOperation = self.request.get("stateOfOperation")
				email = self.request.get("email")
				website = self.request.get("website")
				registrationNumber = self.request.get("registrationNumber")
				dateOfRegistration = self.request.get("dateOfRegistration")
				stateOfRegistration = self.request.get("stateOfRegistration")
				telephone = self.request.get("telephone")	
				address = self.request.get("address")
				dateOfRegistration  =  self.date(dateOfRegistration)
				ngo = NGO()
				ngo.userid = userid
				ngo.name = name
				ngo.credibility = False
				ngo.description = description
				ngo.pancardNumber = pancardNumber
				ngo.email = email
				ngo.website = website
				ngo.chiefFunctionary = chiefFunctionary
				ngo.chairman = chairman
				ngo.sectorOfOperation = sectorOfOperation
				ngo.stateOfOperation = stateOfOperation
				ngo.registrationNumber = registrationNumber
				ngo.dateOfRegistration = dateOfRegistration
				ngo.stateOfRegistration = stateOfRegistration 
				ngo.telephone = telephone 
				ngo.projects = []
				ngo.address = address 
				ngo.email = email
				ngo.put()

				index = search.Index(name = "NGO")		
				document = search.Document(doc_id = userid, fields = [ search.TextField(name = "name", value = name ),
								       search.TextField(name = "description", value = description),
								       search.TextField(name = "state", value = stateOfRegistration)])
				try:
					index.put(document)
				except search.Error:
					logging.exception("Put Failed")
				sleep(5) #cheap trick but none the less it works!
				self.redirect("/home")	
		else:
			self.redirect("/login") 
예제 #13
0
	def get(self):
		user=users.get_current_user()
		if user:
			userid = user.user_id()
 			authenticationUser = User.query(User.userid == userid).fetch(1)
			if  not authenticationUser:
				self.render("userRegistration.html")
			else:
				self.redirect("/home")
		else:
			self.redirect("/signup")
예제 #14
0
 def get(self):
     user = users.get_current_user()
     if user:
         userid = user.user_id()
         authenticationUser = User.query(User.userid == userid).fetch(1)
         if not authenticationUser:
             self.render("userRegistration.html")
         else:
             self.redirect("/home")
     else:
         self.redirect("/signup")
예제 #15
0
	def post(self):
		user= users.get_current_user()
		name = self.request.get("name")	
		userid = user.user_id()
		gender = self.request.get("gender")
		userObject = User()
		userObject.userid=userid
		userObject.name = name
		userObject.gender = gender
		userObject.projects = []
		userObject.put()
		sleep(5)
		self.redirect("/home")
예제 #16
0
	def get(self):
		user=users.get_current_user()
		if user:
			userid = user.user_id()
 	    		userAuthenticationQuery = User.query(User.userid == userid).fetch(1)	 	    	      
                        NGOauthenticationQuery = NGO.query(NGO.userid == userid).fetch(1)
                        if (not userAuthenticationQuery) and (not NGOauthenticationQuery) :
				self.redirect("/signup/registration")
		projects = Project.query().fetch(3)
		parameter = {"projects" : projects }
		self.render('frontPage.html', parameter)        
예제 #17
0
	def post(self):
		user= users.get_current_user()
		if user:
			userid = user.user_id()
			authenticationUser = User.query(User.userid == userid).fetch(1)
			authenticationNgo = NGO.query(NGO.userid == userid).fetch(1)
			if authenticationUser or authenticationNgo:
				self.redirect("/home")
			else:
				name = self.request.get("name")	
				email = user.email()
				description = self.request.get("description")
				pancardNumber = self.request.get("pancardNumber")
				chiefFunctionary = self.request.get("chiefFunctionary")
				chairman = self.request.get("chairman")
				sectorOfOperation = self.request.get("sectorOfOperation")
				stateOfOperation = self.request.get("stateOfOperation")
				registrationNumber = self.request.get("registrationNumber")
				dateOfRegistration = self.request.get("dateOfRegistration")
				stateOfRegistration = self.request.get("stateOfRegistration")
				telephone = self.request.get("telephone")	
				address = self.request.get("address")
				dateOfRegistration  =  self.date(dateOfRegistration)
				ngo = NGO()
				ngo.userid = userid
				ngo.name = name
				ngo.credibility = False
				ngo.description = description
				ngo.pancardNumber = pancardNumber
				ngo.chiefFunctionary = chiefFunctionary
				ngo.chairman = chairman
				ngo.sectorOfOperation = sectorOfOperation
				ngo.stateOfOperation = stateOfOperation
				ngo.registrationNumber = registrationNumber
				ngo.dateOfRegistration = dateOfRegistration
				ngo.stateOfRegistration = stateOfRegistration 
				ngo.telephone = telephone 
				ngo.projects = []
				ngo.address = address 
				ngo.email = email
				ngo.put()

				index = search.Index(name = "NGO")		
				document = search.Document(doc_id = userid, fields = [ search.AtomField(name = "name", value = name ),
								       search.TextField(name = "description", value = description)])
				try:
					index.put(document)
				except search.Error:
					logging.exception("Put Failed")
				sleep(5) #cheap trick but none the less it works!
				self.redirect("/signup/ngoRegistration/proofOfRegistration")	
		else:
			self.redirect("/login") 
 def get(self, urlParameter):
     print urlParameter
     ngo, title = urlParameter.split("_")
     q = ndb.gql("SELECT * FROM Project WHERE link = :1 AND ngo = :2",
                 title, ngo).fetch(1)
     funds = 0
     print q
     if q:
         parameters = {}
         for p in q:
             parameters["project"] = p
             ngoP = NGO.query(NGO.userid == p.ngo).fetch(1)
             parameters["ngo"] = ngoP[0]
         for task in parameters["project"].tasks:
             funds = funds + int(task[2])
         i = 0
         parameters["collected"] = 0
         parameters["funding"] = []
         while i < len(parameters["project"].funding):
             user = User.query(User.userid ==
                               parameters["project"].funding[i][0]).fetch(1)
             parameters["collected"] = parameters["collected"] + int(
                 parameters["project"].funding[i][1])
             parameters["funding"].append(
                 (user[0], parameters["project"].funding[i][1]))
             i = i + 1
         parameters["funding"].reverse()
         print parameters["project"].funding
         parameters["support"] = i
         print parameters["support"]
         projects = Project.query(
             Project.category == parameters["project"].category).fetch()
         closeProjects = []
         try:
             for i in range(0, 4):
                 randomInt = randint(0, len(projects) - 1)
                 if (projects[randomInt] not in closeProjects
                         and projects[randomInt] != parameters["project"]):
                     closeProjects.append(projects[randomInt])
         except:
             pass
         parameters["closeProjects"] = closeProjects
         parameters["funds"] = funds
         self.render("projectPage.html", parameters)
예제 #19
0
 def get(self):
     user = users.get_current_user()
     if user:
         userid = user.user_id()
         userAuthentication = User.query(User.userid == userid).fetch(1)
         ngoAuthentication = NGO.query(NGO.userid == userid).fetch(1)
         if userAuthentication:
             parameter = {}
             ngos = NGO.query().fetch(4)
             userObject = userAuthentication[0]
             userProjects = []
             for p in userObject.projects:
                 ngo, title = p[0].split("_")
                 print p[0]
                 proj = ndb.gql(
                     "SELECT * FROM Project WHERE link = :1 AND ngo = :2",
                     title, ngo).fetch(1)
                 if proj:
                     userProjects.append(proj[0])
             projects = Project.query().fetch(100)
             print userObject.projects
             closeProjects = []
             decorated = [(project,
                           project.distance(userAuthentication[0].lat,
                                            userAuthentication[0].lng))
                          for project in projects]
             closeProjects = sorted(decorated, key=lambda tup: tup[1])[0:4]
             parameter["projects"] = closeProjects
             parameter["userProjects"] = userProjects
             parameter["ngos"] = ngos
             parameter["currUser"] = userAuthentication[0]
             self.render("userHomePage.html", parameter)
         elif ngoAuthentication:
             parameter = {}
             proj = Project.query(
                 Project.ngo == ngoAuthentication[0].userid).fetch()
             parameter["ngoProjects"] = proj
             parameter["length"] = len(proj)
             parameter["ngo"] = ngoAuthentication[0]
             self.render("ngoHomePage.html", parameter)
         else:
             self.redirect("/signup/registration")
     else:
         self.redirect("/")
예제 #20
0
 def get(self):
     user = users.get_current_user()
     if user:
         userid = user.user_id()
         userAuthentication = User.query(User.userid == userid).fetch(1)
         if userAuthentication:
             parameter = {}
             userObject = userAuthentication[0]
             projectsIdentifier = userObject.projects[:10]
             projects = []
             for projectIdentifier in projectsIdentifier:
                 key = ndb.Key("Project", projectIdentifier)
                 projects.append(key.get())
             parameter["projects"] = projects
             self.render("projectUpdate.html", parameter)
         else:
             self.redirect("/")
     else:
         self.redirect("/login")
예제 #21
0
	def get(self):
		user = users.get_current_user()
                if user:
                        userid = user.user_id()
                        userAuthentication =  User.query(User.userid == userid).fetch(1)
                        if userAuthentication:
				parameter = {}
				userObject = userAuthentication[0]
				projectsIdentifier = userObject.projects[:10]
				projects = []
				for projectIdentifier in projectsIdentifier:
					key = ndb.Key("Project", projectIdentifier)
					projects.append(key.get())
				parameter["projects"] = projects
                                self.render("projectUpdate.html", parameter)
                        else:
                                self.redirect("/")
                else:   
                        self.redirect("/login")
예제 #22
0
	def get(self):
		user = users.get_current_user()
		if user:
			userid = user.user_id()
			userAuthentication =  User.query(User.userid == userid).fetch(1)
			ngoAuthentication = NGO.query(NGO.userid == userid).fetch(1)
			if userAuthentication:
				parameter = {}
				ngos = NGO.query().fetch(4)
				userObject = userAuthentication[0]
				userProjects = []
				for p in userObject.projects:
					ngo, title = p[0].split("_")
					print p[0]
					proj = ndb.gql("SELECT * FROM Project WHERE link = :1 AND ngo = :2", title,ngo).fetch(1)
					if proj:
						userProjects.append(proj[0]);
				projects = Project.query().fetch(100)
				print userObject.projects
				cProjects = []
				decorated = [(project,project.distance(userAuthentication[0].lat,userAuthentication[0].lng)) for project in projects if project.distance(userAuthentication[0].lat,userAuthentication[0].lng)<50]
				print decorated
				cProjects = sorted(decorated, key=lambda tup: tup[1])[0:4] 
				parameter["cProjects"] = cProjects
				parameter["userProjects"] = userProjects 
				parameter["ngos"] = ngos
				parameter["currUser"] = userAuthentication[0]
				self.render("userHomePage.html", parameter)
			elif ngoAuthentication:
				parameter={}
				proj = Project.query(Project.ngo == ngoAuthentication[0].userid).fetch()
                                parameter["ngoProjects"] = proj
                                parameter["length"] = len(proj)
                                parameter["ngo"]=ngoAuthentication[0]
				self.render("ngoHomePage.html", parameter)
			else:
				self.redirect("/signup/registration")
		else:
			self.redirect("/")
예제 #23
0
    def get(self,urlParameter):
		print urlParameter
		ngo, title = urlParameter.split("_")
		q = ndb.gql("SELECT * FROM Project WHERE link = :1 AND ngo = :2", title,ngo).fetch(1)
		funds = 0
		print q
		if q:
			parameters = {}
			for p in q:
				parameters["project"] = p
				ngoP = NGO.query(NGO.userid == p.ngo).fetch(1)
				parameters["ngo"] = ngoP[0]
			for task in parameters["project"].tasks:
				funds = funds + int(task[2]);
			i=0
			parameters["collected"] = 0
			parameters["funding"] = []
			while i < len(parameters["project"].funding):
				user = User.query(User.userid == parameters["project"].funding[i][0]).fetch(1)
				parameters["collected"] = parameters["collected"] + int(parameters["project"].funding[i][1])
				parameters["funding"].append((user[0], parameters["project"].funding[i][1]))
				i=i+1
			parameters["funding"].reverse()
			print parameters["project"].funding
			parameters["support"]=i
			print parameters["support"]
			projects = Project.query(Project.category == parameters["project"].category).fetch()
			closeProjects = []
			try:
				for i in range(0,4):
					randomInt = randint(0,len(projects)-1)
					if(projects[randomInt] not in closeProjects and projects[randomInt] != parameters["project"]):
						closeProjects.append(projects[randomInt])
			except:
				pass
			parameters["closeProjects"] = closeProjects
			parameters["funds"] = funds
			self.render("projectPage.html", parameters)
예제 #24
0
def addUser():
    userno = inputUserno()

    name = None
    if userno:
        name = textInput("name").capitalize()

    surname = None
    if name:
        surname = textInput("surname").capitalize()

    age = None
    if surname:
        age = numberInput("age")

    username = None
    if age:
        username = textInput("username")
    password = None
    if username:
        password = textInput("password")
    if userno and name and surname and age and username and password:
        obj = User(userno, name, surname, age, username, password)
        db.addUserToDb(obj)
예제 #25
0
	def get(self):
		user = users.get_current_user()
		if user:
			userid = user.user_id()
			userAuthentication =  User.query(User.userid == userid).fetch(1)
			ngoAuthentication = NGO.query(NGO.userid == userid).fetch(1)
			if userAuthentication:
				parameter = {}
				ngos = NGO.query().fetch(3)
				userObject = userAuthentication[0]
                                projectsIdentifier = userObject.projects[:3]
                                userProjects = []
                                for projectIdentifier in projectsIdentifier:
                                        key = ndb.Key("Project", projectIdentifier)
                                        userProjects.append(key.get())
				projects = Project.query().fetch(3)
                                parameter["projects"] = projects
				parameter["userProjects"] = userProjects 
				parameter["ngos"] = ngos
				self.render("userHomePage.html", parameter)
			elif ngoAuthentication:
				parameter={}
                                ngo = ngoAuthentication[0]
                                projectsIdentifierList = ngo.projects
                                ngoProjects = []
				if projectsIdentifierList:
                             		for projectIdentifier in projectsIdentifierList:
                                	        ngo, title = self.stripProjectIdentifier(projectIdentifier)
                                       	        projectObject = Project.query(Project.ngo == ngo, Project.title == title).fetch(1)[0]
                                        	ngoProjects.append(projectObject)
                                parameter["ngoProjects"] = ngoProjects
				self.render("ngoHomePage.html", parameter)
			else:
				self.redirect("/signup/registration")
		else:
			self.redirect("/")
예제 #26
0
def register(user_name, user_passwd, user_passwd2, user_nick, *args, **kwargs):
    '''用户注册'''
    print(user_name, user_passwd, user_nick)
    if user_name == '' or user_name == None:
        # 用户名为空返回 1
        raise ValueError("用户名不能为空")

    if user_passwd == '' or user_passwd == None:
        raise ValueError("用户密码不能为空")

    if user_passwd2 == '' or user_passwd2 == None:
        raise ValueError("用户密码不能为空")

    if user_passwd2 != user_passwd:
        raise ValueError("两次输入的密码不一致")

    userdata = {
        "username": user_name,
        "passwd": user_passwd,
        "money": 10000,
        "jifen": 0,
        "usernick": user_nick,
        "cratetime": gmtime(),
        "logintime": gmtime(),
        "lv": 1,
        "exp_lv": 0,
    }
    # 实例用户对象
    user = User(userdata.get("username"))
    # 判断用户是否已经注册
    if user.getUserID():
        print("用户已经注册。请重新登录")
        raise ValueError("用户已注册")
    # 上传用户属性,并且刷新数据库
    user.setUserinfo(**userdata)
    user.updateUserinfo()
예제 #27
0
def addUserToDb():
    db.append(User(*getUserData()))
예제 #28
0
def createUserObject():
    return User(*getDataFromUser())
예제 #29
0
def Qeydiyyat():
    userSayi = input("User sayini teyin edin:")
    for say in range(int(
            userSayi)):  #int ona gore yaziriq ki range-in output-u reqemdi.
        users.append(User(*melumatlariAl()))
예제 #30
0
from lib import User

USERS = [User('Chappie', 'chappie', ''), # Leave this line. Chappie must be the first user
		 User('Real Name', 'slack username', 'github username')]
REPOS = ['repository', 'names']

# Slack Settings
SLACK_TOKEN = 'token'
SLACK_ROOM_NAME = 'room name for notifications'
CHECK_MESSAGES_INTERVAL = 1

# GitHub Settings
GITHUB_USERNAME = '******'
GITHUB_PASSWORD = '******'
CHECK_PULL_REQUESTS_INTERVAL = 3000
예제 #31
0
        num_txs = int(header['result']['block_meta']['header']['num_txs'])
        if block_time > end_block_time:
            continue
        if block_time < start_block_time:
            break

        sec = int(block_time - start_block_time)
        num_blocks_per_sec[sec] += 1
        num_tx_per_sec[sec] += num_txs

    print("Submitted: %d tx in %.2fs, tps=%.2f, blocks=%d" %
          (num_transactions, elapsed, num_transactions / elapsed,
           end_height - start_height))
    print(num_blocks_per_sec)
    print(num_tx_per_sec)
    keys = sorted(num_blocks_per_sec.keys())
    for key in keys:
        print("second=%d. blocks=%d. num tx=%d." %
              (key, num_blocks_per_sec[key], num_tx_per_sec[key]))
    if len(keys) > 2:
        avg_tps = sum([num_tx_per_sec[x] for x in keys[1:]]) / (keys[-1] - 1)
        print("Avg tps = %d w/o first block" % avg_tps)


if __name__ == "__main__":
    rpc = RPC('http://localhost:3030/')
    alice = User(rpc, "alice.near")
    bob = User(rpc, "bob.near")

    benchmark(rpc, [alice, bob], 10)
예제 #32
0
 def post(self):
     user = users.get_current_user()
     name = self.request.get("name")
     userid = user.user_id()
     gender = self.request.get("gender")
     email = self.request.get("email")
     address = self.request.get("address")
     lat = self.request.get("lat")
     lng = self.request.get("lng")
     userObject = User()
     userObject.userid = userid
     userObject.name = name
     userObject.email = email
     userObject.gender = gender
     userObject.address = address
     userObject.lat = lat
     userObject.lng = lng
     userObject.projects = []
     userObject.put()
     sleep(5)
     self.redirect("/home")
예제 #33
0
    input_soyad = input("Soyadinizi daxil edin:")
    input_username = input("Username-i daxil edin:")
    input_password = input("Parolunuzu daxil edin:")
    return [input_ad, input_soyad, input_username, input_password]


"""userMelumatlari=melumatlariAl()  --->>> silinsede proqram isdiyecek"""
"""for melumat in userMelumatlari:
   print(melumat)"""
"""user=User(userMelumatlari[0],userMelumatlari[1],userMelumatlari[2],userMelumatlari[3])---->===---->>>user=User(*userMelumatlari)"""
"""user=User(*melumatlariAl())
#built in function ---->>> users.append()
users.append()
user.showData(user) belede olar qisaltmaq ucun asagidaki kimi yazmaq meqsede uygundu"""

user = User(*melumatlariAl())
#built in function ---->>> users.append()
users.append(User(*melumatlariAl()))
users[0].showData()


def Qeydiyyat():
    userSayi = input("User sayini teyin edin:")
    for say in range(int(
            userSayi)):  #int ona gore yaziriq ki range-in output-u reqemdi.
        users.append(User(*melumatlariAl()))


def MelumatlariGoster():
    for user in users:
        user.showData()
예제 #34
0
def createUser():
    return User(*getData())
예제 #35
0
	def post(self):
		user= users.get_current_user()
		name = self.request.get("name")	
		userid = user.user_id()
		gender = self.request.get("gender")
		email = self.request.get("email")
		address = self.request.get("address")
		lat = self.request.get("lat")
		lng = self.request.get("lng")
		userObject = User()
		userObject.userid=userid
		userObject.name = name
		userObject.email = email
		userObject.gender = gender
		userObject.address = address
		userObject.lat = lat
		userObject.lng = lng
		userObject.projects = []
		userObject.put()
		sleep(5)
		self.redirect("/home")
예제 #36
0
파일: main.py 프로젝트: panickat/btc_note
from lib import User, DB
"""
Pendiente de optimizar:
    1. En un lapso de un minuto usar live_usd last_usd contenidos en el objeto User (sin usar request)
    2. preguntar si hacer request al inicializar un Usuario, si ha pasado un lapso(minuto) 
    desde la ultima vez que se llamo a request

- la proxima ves que se llame a User se puede omitir la db
"""

db = DB()
user = User(name="cris", db=db)