예제 #1
0
 def _post(self, what, transaction, changed_by):
     where = {f: what.get(f) for f in self.decisionFields}
     if self.table.select(where=where, transaction=transaction):
         raise SignoffRequiredError("Required Signoffs cannot be directly modified")
     else:
         try:
             self.table.insert(changed_by=changed_by, transaction=transaction, **what)
             return Response(status=201, response=json.dumps({"new_data_version": 1}))
         except ValueError as e:
             self.log.warning("Bad input: %s", e.args)
             return problem(400, "Bad Request", str(e.args))
예제 #2
0
    def _post(self, form, transaction, changed_by):
        if not form.validate():
            self.log.warning("Bad input: %s", form.errors)
            return Response(status=400, response=json.dumps(form.errors))

        where = {f: form[f].data for f in self.decisionFields}
        if self.table.select(where=where, transaction=transaction):
            raise SignoffRequiredError(
                "Required Signoffs cannot be directly modified")
        else:
            try:
                self.table.insert(changed_by=changed_by,
                                  transaction=transaction,
                                  **form.data)
                return Response(status=201,
                                response=json.dumps({"new_data_version": 1}))
            except ValueError as e:
                self.log.warning("Bad input: %s", e.args)
                return Response(status=400, response=e.args)
예제 #3
0
 def _delete(self, *args, **kwargs):
     raise SignoffRequiredError(
         "Required Signoffs cannot be directly deleted.")