def manage_collections_post_(request): form = request.web_input(submissions=[], action="") # submissions input format: "submissionID;collectorID" # we have to split it apart because each offer on a submission is a single checkbox # but needs collector's ID for unambiguity intermediate = [x.split(";") for x in form.submissions] submissions = [(int(x[0]), int(x[1])) for x in intermediate] if form.action == "accept": collection.pending_accept(request.userid, submissions) elif form.action == "reject": collection.pending_reject(request.userid, submissions) else: raise WeasylError("Unexpected") raise HTTPSeeOther(location="/manage/collections?feature=pending")
def POST(self): form = web.input(submissions=[], action="") # submissions input format: "submissionID;collectorID" # we have to split it apart because each offer on a submission is a single checkbox # but needs collector's ID for unambiguity intermediate = [x.split(";") for x in form.submissions] submissions = [(int(x[0]), int(x[1])) for x in intermediate] if form.action == "accept": collection.pending_accept(self.user_id, submissions) elif form.action == "reject": collection.pending_reject(self.user_id, submissions) else: raise WeasylError("Unexpected") raise web.seeother("/manage/collections?feature=pending")
def test_offer_and_reject(self): self.offer() self.assertEqual(1, self.count_collections(True)) collection.pending_reject(self.collector, [(self.s, self.collector)]) self.assertEqual(0, self.count_collections(False)) self.assertEqual(0, self.count_collections(True))