Пример #1
0
	def PUT(self):
		j = self.req.json
		
		if "personw" not in self.req.auth.perms:
			self.status_code = 403
			return {"e":1, "msg":"You don't have permission to do that."}
		
		p = Person()
		self.dbs.add(p)
		
		if not ("name" in j and j["name"]):
			self.status_code = 400
			return {"e":1, "msg":"Name required."}
		if not ("namefull" in j and j["namefull"]):
			self.status_code = 400
			return {"e":1, "msg":"Full name required."}
		if not ("emails" in j and j["emails"]):
			self.status_code = 400
			return {"e":1, "msg":"At least one email is required."}
		
		p.name     = j["name"]
		p.namefull = j["namefull"]
		
		if "number" in j:
			p.number = j["number"]
		
		
		if "emails" in j:
			p.emails = [Email(email=e) for e in j["emails"]]
		
		self.dbs.commit()
		
		return {"e":0,
			"id": p.id,
		}
Пример #2
0
def person(id, name, full, pw, perms):
	p = Person(number=id,
	           name=name,
	           namefull=full,
	           perms=perms)
	p.password_set(pw)
	sess.add(p)
	return p