def _get_object(self, *args, **kwargs):
     sla_id = self.kwargs["sla_id"]
     try:
         sla = api.bw_get_sla(self.request, sla_id)
         return sla
     except Exception:
         redirect = self.success_url
         msg = _("Unable to retrieve sla details.")
         exceptions.handle(self.request, msg, redirect=redirect)
 def update_cell(self, request, datum, id, cell_name, new_cell_value):
     try:
         # updating changed value by new value
         response = api.bw_get_sla(request, id)
         data = json.loads(response.text)
         data[cell_name] = new_cell_value
         api.bw_update_sla(request, id, data)
     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
    def get_data(self, request, id):
        response = api.bw_get_sla(request, id)
        data = json.loads(response.text)

        sla = SLA(data["project_id"], data["project_name"], data["policy_id"], data["policy_name"], data["bandwidth"])
        return sla