def handle(self, request, data): try: dependency_id = self.initial['id'] # print "\n#################\n", request, "\n#################\n", data, "\n#################\n" response = api.fil_update_dependency_metadata(request, dependency_id, data['version'], data['permissions']) if 200 <= response.status_code < 300: messages.success(request, _('Successfully dependency creation and upload.')) return data else: raise sdsexception.SdsException(response.text) except Exception as ex: redirect = reverse("horizon:sdscontroller:administration:index") error_message = "Unable to create dependency.\t %s" % ex.message exceptions.handle(request, _(error_message), redirect=redirect)
def update_cell(self, request, datum, id, cell_name, new_cell_value): try: # updating changed value by new value response = api.fil_get_dependency_metadata(request, id) data = json.loads(response.text) data[cell_name] = new_cell_value # TODO: Check only the valid keys, delete the rest if 'id' in data: # PUT does not allow this key del data['id'] if 'path' in data: # PUT does not allow this key del data['path'] api.fil_update_dependency_metadata(request, id, data['version'], data['permissions']) except Conflict: # Returning a nice error message about name conflict. The message # from exception is not that clear for the user message = _("Cant change value") raise ValidationError(message) except Exception: exceptions.handle(request, ignore=True) return False return True