def post(self): pnm = rev.review_modification_authorized(self) if not pnm: #penid did not match a pen the caller controls return #error already reported group, role = fetch_group_and_role(self, pnm) if not group: return #error already reported action = self.request.get('action') if not action or action not in ['reject', 'accept', 'demote']: return srverr(self, 400, "Valid action required") seekerid = self.request.get('seekerid') if not seekerid: return srverr(self, 400, "No seekerid specified") penid = str(pnm.key().id()) reason = self.request.get('reason') if not reason and (action == "reject" or (action == "demote" and seekerid != penid)): return srverr(self, 400, "Rejection reason required") seekrole = pen_role(seekerid, group) if not (role == "Founder" or (role == "Moderator" and ((action == "accept" and seekrole == "NotFound") or (action != "accept" and seekrole == "Member")))): return srverr(self, 400, "Processing not authorized") seekerpen = pen.PenName.get_by_id(int(seekerid)) if not seekerpen: return srverr(self, 400, "No seeker PenName " + seekerid) #if seeker not found, treat as already processed rather than error if action == "demote" or csv_contains(seekerid, group.seeking): process_membership_action(group, action, pnm, seekerpen, seekrole, reason) returnJSON(self.response, [ group ])
def post(self): pnm = rev.review_modification_authorized(self) if not pnm: #penid did not match a pen the caller controls return #error already reported coop, role = fetch_coop_and_role(self, pnm) if not coop: return #error already reported action = self.request.get('action') if not action or action not in ['reject', 'accept', 'demote']: return srverr(self, 400, "Valid action required") seekerid = self.request.get('seekerid') if not seekerid: return srverr(self, 400, "No seekerid specified") penid = str(pnm.key().id()) reason = self.request.get('reason') if not reason and (action == "reject" or (action == "demote" and seekerid != penid)): return srverr(self, 400, "Rejection reason required") seekrole = pen_role(seekerid, coop) seekerpen = pen.PenName.get_by_id(int(seekerid)) if not seekerpen: return srverr(self, 400, "No seeker PenName " + seekerid) if not membership_action_allowed(coop, action, pnm, role, seekerpen, seekrole): return srverr(self, 400, "Membership modification not authorized") if action == "demote" or csv_contains(seekerid, coop.seeking): process_membership_action(coop, action, pnm, seekerpen, seekrole, reason) else: return srverr(self, 400, "Membership changed already") returnJSON(self.response, [ coop ])
def post(self): pnm = rev.review_modification_authorized(self) if not pnm: return name = self.request.get('name') name_c = canonize(name) if not name_c: self.error(401) self.response.out.write("Invalid value for name") return ctmid = self.request.get('_id') if ctmid: coop = cached_get(intz(ctmid), Coop) if not coop: self.error(404) self.response.out.write("Cooperative Theme " + ctmid + " not found") return if pen_role(pnm.key().id(), coop) != "Founder": self.error(400) self.response.out.write( "Only a Founder may change the theme description.") return coop.name = name coop.name_c = name_c else: coop = Coop(name=name, name_c=name_c) coop.founders = str(pnm.key().id()) if not read_and_validate_descriptive_fields(self, coop): return coop.modified = nowISO() update_coop_admin_log(coop, pnm, "Updated Description", "", "") coop.people = "" # have to rebuild sometime and this is a good time update_coop_and_bust_cache(coop) returnJSON(self.response, [ coop ])
def post(self): pnm = rev.review_modification_authorized(self) if not pnm: #penid did not match a pen the caller controls return #error already reported group, role = fetch_group_and_role(self, pnm) if not group: return #error already reported penid = pnm.key().id() action = self.request.get('action') if action == "apply": if role != "Founder" and not id_in_csv(penid, group.seeking): group.seeking = append_id_to_csv(penid, group.seeking) verify_people(group) cached_put(group) if action == "withdraw": group.seeking = remove_id_from_csv(pnm.key().id(), group.seeking) verify_people(group) cached_put(group) returnJSON(self.response, [ group ])
def post(self): pnm = rev.review_modification_authorized(self) if not pnm: #penid did not match a pen the caller controls return #error already reported coop, role = fetch_coop_and_role(self, pnm) if not coop: return #error already reported penid = pnm.key().id() action = self.request.get('action') if action == "apply": if role != "Founder"\ and not id_in_csv(penid, coop.seeking)\ and not id_in_csv(penid, coop.rejects): coop.seeking = append_id_to_csv(penid, coop.seeking) update_coop_and_bust_cache(coop) elif action == "withdraw": coop.seeking = remove_id_from_csv(pnm.key().id(), coop.seeking) update_coop_and_bust_cache(coop) elif action == "accrej": coop.rejects = remove_id_from_csv(pnm.key().id(), coop.rejects) update_coop_and_bust_cache(coop) returnJSON(self.response, [ coop ])
def post(self): pnm = rev.review_modification_authorized(self) if not pnm: return name = self.request.get('name') name_c = canonize(name) if not name_c: self.error(401) self.response.out.write("Invalid value for name") return grpid = self.request.get('_id') if grpid: group = cached_get(intz(grpid), Group) if not group: self.error(404) self.response.out.write("Group " + grpid + " not found") return if pen_role(pnm.key().id(), group) != "Founder": self.error(400) self.response.out.write( "Only a Founder may change the group description.") return group.name = name group.name_c = name_c else: group = Group(name=name, name_c=name_c) group.founders = str(pnm.key().id()) if not read_and_validate_descriptive_fields(self, group): return group.modified = nowISO() update_group_admin_log(group, pnm, "Updated Description", "", "") group.people = "" # have to rebuild sometime and this is a good time verify_people(group) cached_put(group) # not storing any precomputed group queries, so no cache keys to bust returnJSON(self.response, [ group ])