def js_reverse_inline(context): """ Outputs a string of javascript that can generate URLs via the use of the names given to those URLs. """ if 'request' in context: default_urlresolver = urlresolvers.get_resolver(getattr(context['request'], 'urlconf', None)) else: default_urlresolver = urlresolvers.get_resolver(None) return mark_safe(generate_js(default_urlresolver))
def handle(self, file='index.js', *args, **options): location = self.get_location() fs = FileSystemStorage(location=location) if fs.exists(file): fs.delete(file) default_urlresolver = urlresolvers.get_resolver(None) content = generate_js(default_urlresolver) fs.save(file, ContentFile(content)) if len(sys.argv) > 1 and sys.argv[1] in ['collectstatic_js_reverse']: self.stdout.write( '[django-js-reverse] js-reverse file written to %s' % location)
def handle(self, *args, **options): location = self.get_location() file = 'reverse.js' fs = FileSystemStorage(location=location) if fs.exists(file): fs.delete(file) default_urlresolver = urlresolvers.get_resolver(None) content = generate_js(default_urlresolver) fs.save(file, ContentFile(content)) if len(sys.argv) > 1 and sys.argv[1] in ['collectstatic_js_reverse']: self.stdout.write('js-reverse file written to %s' % (location)) # pragma: no cover
def handle(self, *args, **options): location = self.get_location() file = 'reverse.js' fs = FileSystemStorage(location=location) if fs.exists(file): fs.delete(file) urlconf = getattr(settings, 'ROOT_URLCONF', None) default_urlresolver = get_resolver(urlconf) content = generate_js(default_urlresolver) fs.save(file, ContentFile(content)) if len(sys.argv) > 1 and sys.argv[1] in ['collectstatic_js_reverse']: self.stdout.write('js-reverse file written to %s' % (location)) # pragma: no cover
def handle(self, *args, **options): if not hasattr(settings, "STATIC_ROOT") or not settings.STATIC_ROOT: raise ImproperlyConfigured("The collectstatic_js_reverse command needs settings.STATIC_ROOT to be set.") location = os.path.join(settings.STATIC_ROOT, "django_js_reverse", "js") file = "reverse.js" fs = FileSystemStorage(location=location) if fs.exists(file): fs.delete(file) default_urlresolver = urlresolvers.get_resolver(None) content = generate_js(default_urlresolver) fs.save(file, ContentFile(content)) if len(sys.argv) > 1 and sys.argv[1] in ["collectstatic_js_reverse"]: self.stdout.write("js-reverse file written to %s" % (location)) # pragma: no cover
def urls_js(request): default_urlresolver = urlresolvers.get_resolver( getattr(request, 'urlconf', None)) response_body = generate_js(default_urlresolver) return HttpResponse(response_body, **{'content_type': 'application/javascript'})
def js_reverse_inline(context): """ Outputs a string of javascript that can generate URLs via the use of the names given to those URLs. """ return mark_safe(generate_js(get_resolver(_get_urlconf(context))))
def urls_js(request): default_urlresolver = urlresolvers.get_resolver(getattr(request, 'urlconf', None)) response_body = generate_js(default_urlresolver) return HttpResponse(response_body, **{'content_type': 'application/javascript'})