def _post(self, transaction, changed_by): change_type = request.json.get("change_type") if change_type == "update": form = ScheduledChangeExistingRuleForm() releaseNames = dbo.releases.getReleaseNames(transaction=transaction) self.log.debug("releaseNames: %s" % releaseNames) self.log.debug("transaction: %s" % transaction) form.mapping.choices = [(item['name'], item['name']) for item in releaseNames] form.mapping.choices.insert(0, ('', 'NULL')) elif change_type == "insert": form = ScheduledChangeNewRuleForm() releaseNames = dbo.releases.getReleaseNames(transaction=transaction) self.log.debug("releaseNames: %s" % releaseNames) self.log.debug("transaction: %s" % transaction) form.mapping.choices = [(item['name'], item['name']) for item in releaseNames] form.mapping.choices.insert(0, ('', 'NULL')) elif change_type == "delete": form = ScheduledChangeDeleteRuleForm() else: return Response(status=400, response="Invalid or missing change_type") return super(RuleScheduledChangesView, self)._post(form, transaction, changed_by)
def _post(self, transaction, changed_by): if request.json and request.json.get("data_version"): form = ScheduledChangeExistingRuleForm() else: form = ScheduledChangeNewRuleForm() releaseNames = dbo.releases.getReleaseNames(transaction=transaction) form.mapping.choices = [(item['name'], item['name']) for item in releaseNames] form.mapping.choices.insert(0, ('', 'NULL')) return super(RuleScheduledChangesView, self)._post(form, transaction, changed_by)