Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __call__(self, request, *args, **kwargs):
if request.resolver_match.url_name == 'blog_page_feed_slug':
self.blog_page = BlogPage.extra.get_by_path(kwargs['blog_path'])
if not self.blog_page:
raise http.Http404
else:
self.blog_page = BlogPage.objects.first()
self.request = request
return super(BlogPageFeed, self).__call__(request, *args, **kwargs)
def blog_search(request):
query = request.GET.get('query', None)
if query is not None:
blog_page = BlogPage.objects.first()
entries = blog_page.get_entries().search(query)[:5]
results = []
for entry in entries:
results.append({
'title': entry.title,
'url': entry.get_url(request)
})
data = json.dumps(results)
else:
data = 'fail'
mimetype = 'application/json'
return HttpResponse(data, mimetype)