Ejemplo n.º 1
0
    def hydrate(self, bundle, *args, **kwargs):
        bundle = super(RelatedResource, self).hydrate(bundle, *args, **kwargs)

        parts = bundle.data['related'].split('/')
        bundle.obj.related_ct = get_content_type_for_resource(parts[-3])
        bundle.obj.related_id = int(parts[-2])
        del bundle.data['related']

        return bundle
Ejemplo n.º 2
0
    def hydrate(self, bundle, *args, **kwargs):
        """
        Translates content_type name into real Django ContentType object.

        Name of content type is case insensitive and correspond to the name
        of resource.
        """
        bundle.obj.content_type = get_content_type_for_resource(bundle.data['content_type'])

        return super(DraftResource, self).hydrate(bundle, *args, **kwargs)
Ejemplo n.º 3
0
 def filter_by_tags(self, request, api_name, resource_name, tag_set):
     content_type = get_content_type_for_resource(resource_name)
     resource = get_resource_by_name(resource_name)
     model_class = get_resource_model(resource_name)
     tag_id_set = map(int, tag_set.split(";"))
     try:
         exclude = [int(one) for one in request.GET.getlist('exclude')]
     except Exception, e:
         logger.exception(e)
         exclude = []