示例#1
0
def djng_current_rmi(context):
    """
    Returns a dictionary of all methods for the current View of this request, marked with the
    @allow_remote_invocation decorator. The return string can be used directly to initialize
    the AngularJS provider, such as ``djangoRMIProvider.configure({­% djng_current_rmi %­});``
    """
    return mark_safe(json.dumps(get_current_remote_methods(context.get('view'))))
def djng_current_rmi(context):
    """
    Returns a dictionary of all methods for the current View of this request, marked with the
    @allow_remote_invocation decorator. The return string can be used directly to initialize
    the AngularJS provider, such as ``djangoRMIProvider.configure({­% djng_current_rmi %­});``
    """
    return mark_safe(json.dumps(get_current_remote_methods(context.get('view'))))
示例#3
0
 def test_get_current_remote_methods(self):
     view = RemoteMethodsView()
     view.request = self.factory.get('/straight_methods/')
     remote_methods = get_current_remote_methods(view)
     self.assertDictEqual(
         {
             'foo': {
                 'url': '/straight_methods/',
                 'headers': {
                     'DjNg-Remote-Method': 'foo'
                 },
                 'method': 'auto'
             },
             'bar': {
                 'url': '/straight_methods/',
                 'headers': {
                     'DjNg-Remote-Method': 'bar'
                 },
                 'method': 'auto'
             }
         }, remote_methods)
 def test_get_current_remote_methods(self):
     view = RemoteMethodsView()
     view.request = self.factory.get('/straight_methods/')
     remote_methods = get_current_remote_methods(view)
     self.assertDictEqual({'foo': {'url': '/straight_methods/', 'headers': {'DjNg-Remote-Method': 'foo'}, 'method': 'auto'}, 'bar': {'url': '/straight_methods/', 'headers': {'DjNg-Remote-Method': 'bar'}, 'method': 'auto'}},
                          remote_methods)