Exemplo n.º 1
0
 def downschedule(self):
     stewz = db.get_multi(self.commitments)
     for stew in stewz:
         self.unsteward(stew, "rescheduled")
     self.commitments = []
     self.put()
     db.delete_multi(stewz)
Exemplo n.º 2
0
 def happening(self, now):
     slots = []
     for slot in db.get_multi(self.timeslots):
         if isDay(slot, now):
             slots.append(slot)
     if len(slots) is 1:  # if 2, one is exception
         return slots[0]
Exemplo n.º 3
0
def response():
	action = cgi_get("action", choices=["schema", "get", "edit", "delete"])

	# edit/delete always require credentials; getters do configurably
	if not config.db.public or action in ["edit", "delete"]:
		if cgi_get("pw") != config.admin.pw:
			fail("wrong")

	if action == "schema":
		succeed(get_schema())
	elif action == "get":
		sig = cgi_dump()
		res = getmem(sig, False)
		if not res:
			mname = cgi_get("modelName", required=False)
			keys = cgi_get("keys", required=False)
			if mname:
				res = get_page(mname, cgi_get("limit"), cgi_get("offset"),
					cgi_get("order", default="index"), cgi_get("filters", default={}))
			elif keys:
				res = [d.data() for d in get_multi(keys)]
			else:
				res = get(cgi_get("key")).data()
			if config.memcache.db:
				setmem(sig, res, False)
		succeed(res)
	elif action == "edit":
		if config.memcache.db:
			clearmem()
		succeed(edit(cgi_get("data")).data())
	elif action == "delete":
		get(cgi_get("key")).rm()
		succeed()
Exemplo n.º 4
0
 def secs(self, sections=None, depth=0, novars=False, page_breaks=False):
     return "\r\n\r\n".join(sections and [
         db.get(s['key']).content(s['sections'], depth, novars, page_breaks)
         for s in sections
     ] or [
         s.content(depth=depth, novars=novars, page_breaks=page_breaks)
         for s in db.get_multi(self.sections)
     ])
Exemplo n.º 5
0
 def dividend(self):
     pod = self.pod()
     pool = pod.pool.get()
     people = db.get_multi(pod.members())
     div = self.amount * pool.outstanding
     cut = div / len(people)
     for person in people:
         person.wallet.get().deposit(cut, pod, self, "dividend")
     pool.debit(div, pod, self, "dividend")
Exemplo n.º 6
0
 def fulfill(self):
     if self.passed or not self.verified():
         return False
     count = len(self.beneficiaries)
     pod = self.pod()
     service = self.service.get()
     for worker in db.get_multi(self.workers):
         pod.service(worker, service, count, self.notes)
     self.passed = True
     self.put()
     return True
Exemplo n.º 7
0
 def oncreate(self):
     convo = Conversation(topic=self.subject)
     convo.put()
     self.conversation = convo.key
     if self.recipients:
         recipients = db.get_multi(self.recipients)
     else:
         recipients = Member.query().all()
     bod = UPDATE % (self.sender.get().email, self.message)
     for recip in recipients:
         send_mail(to=recip.email, subject=self.subject, body=bod)
Exemplo n.º 8
0
def reg_act(membership, service, workers, beneficiaries, notes):
    act = Act()
    act.membership = membership
    act.service = service
    act.workers = workers
    act.beneficiaries = beneficiaries
    act.notes = notes
    act.put()
    akey = act.key.urlsafe()
    service = act.service.get()
    memship = act.membership.get()
    person = memship.person.get()
    pod = memship.pod.get()
    workers = "\n".join([w.email for w in db.get_multi(act.workers)])
    act.notify(
        "verify service", lambda signer: SERVICE %
        (person.email, pod.name, service.name, act.notes, workers, akey,
         signer.urlsafe(), akey))
    return akey
Exemplo n.º 9
0
 def deposit(self, amount, deed):
     log('compensating "%s/%s" codebase: %s' %
         (self.owner, self.repo, amount))
     contz = self.contributions()
     total = float(sum([cont.count for cont in contz]))
     platcut = amount * ratios.code.get(self.variety, ratios.code.rnd)
     log('dividing %s cut (%s) among %s contributors' %
         (self.variety, platcut, len(contz)))
     details = "variety: %s\nowner: %s" % (self.variety, self.owner)
     for contrib in contz:
         memship = contrib.membership()
         memship and memship.deposit(
             platcut * contrib.count / total, deed, "code usage: %s@%s" %
             (contrib.handle(), self.repo), details, True)
     depcut = amount * ratios.code.dependency
     dnum = len(self.dependencies)
     if dnum:
         depshare = depcut / dnum
         log('dividing dependency cut (%s) among %s codebases' %
             (depcut, dnum))
         for dep in db.get_multi(self.dependencies):
             dep.deposit(depshare, deed)
Exemplo n.º 10
0
 def deposit(self,
             member,
             amount,
             deed,
             note,
             details=None,
             nocode=False,
             pay=False):
     memwall = member.wallet.get()
     if pay:
         memcut = amount * ratios.pay
         amount -= memcut
         memwall.deposit(memcut, self, deed, note, details)
     else:
         memwall.deposit(amount, self, deed, note, details)
     self.pool.get().deposit(amount, self, deed, note, details)
     self.agent and self.agent.get().pool.get().deposit(
         amount * ratios.agent, self, deed, note, details)
     if not nocode:
         for codebase in self.codebases():
             codebase.deposit(amount, deed)
         depcut = amount * ratios.code.dependency
         for dependency in db.get_multi(self.dependencies):
             dependency.deposit(depcut, deed)
Exemplo n.º 11
0
 def unrolled(self):
     d = self.data()
     d['sections'] = [s.unrolled() for s in db.get_multi(self.sections)]
     return d
Exemplo n.º 12
0
 def beforeremove(self, session):
     for stew in db.get_multi(self.commitments, session):
         self.unsteward(stew, "removed")
Exemplo n.º 13
0
 def pods(self):
     return db.get_multi([m.pod for m in self.memberships()])
Exemplo n.º 14
0
 def tasks(self):
     return db.get_multi(sum([p.tasks for p in self.pods()], []))
Exemplo n.º 15
0
 def full(self):
     answers = "\n\n".join([a.full() for a in db.get_multi(self.answers)])
     return "\n\n".join([
         self.topic, answers, self.notes,
         "request follow up: %s" % (self.followup, )
     ])
Exemplo n.º 16
0
 def interested(self, tags):
     tagz = set(map(lambda t: t.urlsafe(), tags))
     return filter(
         lambda p: tagz.intersection(
             set(map(lambda t: t.urlsafe(), p.interests))),
         db.get_multi(self.members()))
Exemplo n.º 17
0
 def afterremove(self, session):
     db.delete_multi(
         db.get_multi(self.timeslots + self.commitments, session), session)