Exemplo n.º 1
0
 def get_data(self, request, id):
     response = api.fil_get_dependency_metadata(request, id)
     data = json.loads(response.text)
     print(data)
     dependency = Dependency(data['id'], data['name'],
                             data['version'], data['permissions'])
     return dependency
Exemplo n.º 2
0
 def _get_object(self, *args, **kwargs):
     dependency_id = self.kwargs['dependency_id']
     try:
         dependency = api.fil_get_dependency_metadata(self.request, dependency_id)
         return dependency
     except Exception:
         redirect = self.success_url
         msg = _('Unable to retrieve dependency details.')
         exceptions.handle(self.request, msg, redirect=redirect)
Exemplo n.º 3
0
    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