@cache_control(no_cache=True)
def project_badge(request, project_slug):
 version_slug = request.GET.get('version', LATEST)
 style = request.GET.get('style', 'flat')
 try:
  version = Version.objects.public(request.user).get(project__slug=project_slug, slug=version_slug)
 except Version.DoesNotExist:
  url = 'https://img.shields.io/badge/docs-unknown%20version-yellow.svg?style={style}'.format(style=style)
  return HttpResponseRedirect(url)
 version_builds = version.builds.filter(type='html', state='finished').order_by('-date')
 if (not version_builds.exists()):
  url = 'https://img.shields.io/badge/docs-no%20builds-yellow.svg?style={style}'.format(style=style)
  return HttpResponseRedirect(url)
 last_build = version_builds[0]
 if last_build.success:
  color = 'brightgreen'
 else:
  color = 'red'
 url = ('https://img.shields.io/badge/docs-%s-%s.svg?style=%s' % (version.slug.replace('-', '--'), color, style))
 return HttpResponseRedirect(url)

@ cache_control ( no_cache = True ) def project_badge ( request , project_slug ) : version_slug = request . GET . get ( 'version' , LATEST ) style = request . GET . get ( 'style' , 'flat' ) try : version = Version . objects . public ( request . user ) . get ( project__slug = project_slug , slug = version_slug ) except Version . DoesNotExist : url = 'https://img.shields.io/badge/docs-unknown%20version-yellow.svg?style={style}' . format ( style = style ) return HttpResponseRedirect ( url ) version_builds = version . builds . filter ( type = 'html' , state = 'finished' ) . order_by ( '-date' ) if ( not version_builds . exists ( ) ) : url = 'https://img.shields.io/badge/docs-no%20builds-yellow.svg?style={style}' . format ( style = style ) return HttpResponseRedirect ( url ) last_build = version_builds [ 0 ] if last_build . success : color = 'brightgreen' else : color = 'red' url = ( 'https://img.shields.io/badge/docs-%s-%s.svg?style=%s' % ( version . slug . replace ( '-' , '--' ) , color , style ) ) return HttpResponseRedirect ( url )
return a sweet badge for the project .