def encode_resource(resource_encoder):
    def encode_resource_with_encoder(obj):
        if isinstance(obj, Resource):
            return resource_encoder(obj)
        elif isinstance(obj, Suggestion):
            return { "text" : obj.text,
                     "suggested_by" : obj.suggested_by.username,
                     "suggested_date" : obj.suggested_date,
                     "last_modified_date" : obj.last_modified_date,
                     "rating" : obj.rating.votes,
                     "url" : (obj.id) %"/api/suggestions/%s/",
                     "id" : obj.pk
                     }
        elif isinstance(obj, Idea):
            return { "title" : obj.title,
                     "id" : obj.pk,
                     "description" : obj.description,
                     "author" : obj.author,
                     "created_by" : obj.created_by.username,
                     "created_by_date" : obj.created_by_date,
                     "updated_by" : obj.updated_by.username,
                     "updated_by_date" : obj.updated_by_date,
                     "resources" : list(obj.resources.all()),
                     "images" : list(IdeaImage.objects.filter(idea = obj).all())
                     }
        elif isinstance(obj, Url):
            return { "url" : obj.url,
                     "label" : obj.url_label,
                     "type" : obj.url_type.url_type,
                     "images" : list(obj.urlimage_set.all())
                     }            
        elif isinstance(obj, CoordSystem):
            return { "name": obj.name,
                     "description": obj.description,
                     "EPSG_code" : obj.EPSG_code
                     }
        elif isinstance(obj, UrlImage) or isinstance(obj, IdeaImage):
            return { "title" : obj.title,
                     "source" : obj.source,
                     "source_url" : obj.source_url,
                     "image_thumb_url" : "/media/" + obj.image.thumbnail.relative_url,
                     "image_url" : obj.image.url
                     }
        elif isinstance(obj, DataType):
            return obj.data_type
        elif isinstance(obj, Tag):
            return { "name" : obj.tag_name,
                     "url" : "/api/tags/%s/" % obj.tag_name }
        elif hasattr(obj, "strftime"):
            return obj.strftime("%Y-%m-%d")
        else:
            raise TypeError(repr(obj) + " is not JSON serializable")
    return encode_resource_with_encoder
dataset/ETHPy150Open azavea/Open-Data-Catalog/OpenDataCatalog/api/encoder.py/encode_resource/swapped operands of `%`