Exemple #1
0
	def post(self):
		#print self.request.arguments	
		username = self.get_argument('username')
		email = self.get_argument('email1')
		#check username and email
		if db_backend.do_check_user_name(username):
			errors = ["This username: %s has already been used" % username]
		elif db_backend.do_check_user_email(email):
			errors = ["This email: %s has already been used" % email]
		else:
			
			display_email = bool(self.get_argument('display_email',False))
			password = self.get_argument('password1')
			m = hashlib.md5()
			m.update(password)
			password = m.hexdigest().upper()
			
			user = {
					"name" : username,
					"password": password,
					"email" : email,
					"registered_time":time.time(),
					"display_email":display_email,
					}
					
			if db_backend.do_user_register(user):
				send_verify_email(self,email,username,password)
				messages = ["A active email has already been sent to " + email,"Please active your account before login"]
			else:
				self.write_error(500)
				return
		
		self.render("register.html",data=locals())
		return
Exemple #2
0
	def post(self):
		
		content = self.request.files['Filedata'][0]['body']
		register_time = time.time()
		member_list = []
		for member_line in [ line for line in content.splitlines() if not line.startswith("#") ]:
			member_data = member_line.split(',')
			print member_data
			if len(member_data) == 5:
				
				username = member_data[0]
				if db_backend.do_check_user_name(username):
					continue
					
				password = member_data[1]
				email = member_data[2]
				
				display_email = member_data[3]
				if display_email.lower() == "true":
					display_email = True
				else:
					display_email = False
				
				active = member_data[4]
				if active.lower() == "true":
					active = True
				else:
					active = False
				
				user = {
						"name":username,
						"password":password,
						"email":email,
						"registered_time":register_time,
						"display_email":display_email,
						"verify":active,
				}
				member_list.append(user)
		
		if member_list:
			if not db_backend.do_user_register(member_list):
				errors = ["Fail to add members"]
		
		self.render('admin_member_add_with_file.html',data=locals())
Exemple #3
0
	def post(self):
		#print self.request.arguments	
		username = self.get_argument('username')
		email = self.get_argument('email',None)
		#check username and email
		if db_backend.do_check_user_name(username):
			errors = ["This username: %s has already been used" % username]
		else:
			display_email = bool(self.get_argument('display_email',False))
			password = self.get_argument('password1')
			m = hashlib.md5()
			m.update(password)
			password = m.hexdigest().upper()
			
			active = bool(self.get_argument('active',False))
			
			user = {
					"name" : username,
					"password": password,
					"email" : email,
					"registered_time":time.time(),
					"display_email":display_email,
					}
					
			if db_backend.do_user_register(user):
				if active and db_backend.do_active_user_account(username,password):
					pass
				else:
					self.write_error(500)
					return
			else:
				self.write_error(500)
				return
		
		self.render('admin_member_add.html',data=locals())
		return