def get_relationship_links(self, rel, instance): return OrderedDict(( ('self', reverse('%s-relationship' % self.get_basename(), self.request, args=[instance.pk, rel.relname])), ('related', reverse('%s-related' % self.get_basename(), self.request, args=[instance.pk, rel.relname])), ))
def get_relationship_links(self, rel, instance): return OrderedDict(( ('self', reverse( '%s-relationship' % self.get_basename(), self.request, args=[instance.pk, rel.relname] )), ('related', reverse( '%s-related' % self.get_basename(), self.request, args=[instance.pk, rel.relname] )), ))
def get_collection_actions(self): """ Returns a dictionary of {urlname: url} for a collection's action routes. These routes are dynamically generated using the @list_route decorator on view methods. """ base_name = self.get_basename() view_names = self._get_dynamic_views()[1] return OrderedDict((( view_name, reverse("%s-%s" % (base_name, view_name), self.request) ) for view_name in view_names))
def get_resource_actions(self, resource_id): """ Returns a dictionary of {urlname: url} for a resource's action routes. These routes are dynamically generated using the @detail_route decorator on view methods. """ base_name = self.get_basename() view_names = self._get_dynamic_views()[0] return OrderedDict((( view_name, reverse("%s-%s" % (base_name, view_name), self.request, args=[resource_id]) ) for view_name in view_names))
def get_collection_actions(self): """ Returns a dictionary of {urlname: url} for a collection's action routes. These routes are dynamically generated using the @list_route decorator on view methods. """ base_name = self.get_basename() view_names = self._get_dynamic_views()[1] return OrderedDict( ((view_name, reverse("%s-%s" % (base_name, view_name), self.request)) for view_name in view_names))
def get_resource_actions(self, resource_id): """ Returns a dictionary of {urlname: url} for a resource's action routes. These routes are dynamically generated using the @detail_route decorator on view methods. """ base_name = self.get_basename() view_names = self._get_dynamic_views()[0] return OrderedDict(((view_name, reverse("%s-%s" % (base_name, view_name), self.request, args=[resource_id])) for view_name in view_names))
def get_resource_links(self, instance): """ Returns a links object for a resource in conformance with: http://jsonapi.org/format/#document-resource-object-links Additionally, it includes any detail routes attached to the viewset. """ view_name = "%s-detail" % self.get_basename() resource_id = self.get_resource_id(instance) links = OrderedDict(( ('self', reverse(view_name, self.request, args=(resource_id, ))), )) links.update(self.get_resource_actions(resource_id)) # TODO: maybe move to HTML renderer? links = {name: unquote_brackets(link) for name, link in links.items()} return links
def get_resource_links(self, instance): """ Returns a links object for a resource in conformance with: http://jsonapi.org/format/#document-resource-object-links Additionally, it includes any detail routes attached to the viewset. """ view_name = "%s-detail" % self.get_basename() resource_id = self.get_resource_id(instance) links = OrderedDict(( ('self', reverse(view_name, self.request, args=(resource_id, ))), )) links.update(self.get_resource_actions(resource_id)) # TODO: maybe move to HTML renderer? links = {name: unquote_brackets(link) for name, link in list(links.items())} return links