Ejemplo n.º 1
0
    def top_level(self, request, api_name=None):
        """This is the same method in the Api model with the execption
        of the serializer used. This uses the SafeSerializer.
        """
        serializer = SafeSerializer()
        available_resources = {}

        if api_name is None:
            api_name = self.api_name

        for name in sorted(self._registry):
            available_resources[name] = {
                'list_endpoint': self._build_reverse_url("api_dispatch_list", kwargs={
                    'api_name': api_name,
                    'resource_name': name,
                }),
                'schema': self._build_reverse_url("api_get_schema", kwargs={
                    'api_name': api_name,
                    'resource_name': name,
                }),
            }

        desired_format = determine_format(request, serializer)
        options = {}

        if 'text/javascript' in desired_format:
            callback = request.GET.get('callback', 'callback')

            if not is_valid_jsonp_callback_value(callback):
                raise BadRequest('JSONP callback name is invalid.')

            options['callback'] = callback

        serialized = serializer.serialize(available_resources, desired_format, options)
        return HttpResponse(content=serialized, content_type=build_content_type(desired_format))
Ejemplo n.º 2
0
 class Meta:
     queryset = User.objects.all()
     resource_name = 'user'
     serializer = SafeSerializer()
     authorization = Authorization()
     authentication = DeveloperApiKeyAuthentication()
     validation = CleanedDataFormValidation(form_class=UserForm)
     list_allowed_methods = ['get', 'post']
     detail_allowed_methods = ['get', 'put', 'delete']
     excludes = ['username', 'password']
Ejemplo n.º 3
0
 class Meta:
     queryset = PaymentMethod.objects.all()
     resource_name = 'payment_method'
     serializer = SafeSerializer()
     authorization = Authorization()
     authentication = DeveloperApiKeyAuthentication()
     list_allowed_methods = [
         'get',
     ]
     detail_allowed_methods = [
         'get',
     ]
Ejemplo n.º 4
0
 class Meta:
     abstract = True
     object_class = None  # Replaced by abstract=True in tastypie 0.14.1
     serializer = SafeSerializer()
     authorization = Authorization()
     authentication = DeveloperApiKeyAuthentication()
Ejemplo n.º 5
0
 class Meta:
     serializer = SafeSerializer()
     authorization = Authorization()
     authentication = DeveloperApiKeyAuthentication()