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'))))
def test_get_current_remote_methods(self): view = RemoteMethodsView() view.request = self.factory.get('/straight_methods/') remote_methods = get_current_remote_methods(view) expected = { 'foo': {'url': '/straight_methods/', 'headers': {'DjNg-Remote-Method': 'foo'}, 'method': 'auto'}, 'bar': {'url': '/straight_methods/', 'headers': {'DjNg-Remote-Method': 'bar'}, 'method': 'auto'}, } self.assertDictEqual(remote_methods, expected)