docs: def legislator(request, abbr, _id, slug=None):
      '''
      Context:
          - vote_preview_row_template
          - roles
          - abbr
          - district_id
          - metadata
          - legislator
          - sources
          - sponsored_bills
          - legislator_votes
          - has_votes
          - nav_active
  
      Templates:
          - billy/web/public/legislator.html
          - billy/web/public/vote_preview_row.html
  
      '''
      try:
          meta = Metadata.get_object(abbr)
      except DoesNotExist:
          raise Http404
  
      legislator = db.legislators.find_one({'_id': _id})
      if legislator is None:
          spec = {'_all_ids': _id}
          cursor = db.legislators.find(spec)
          msg = 'Two legislators returned for spec %r' % spec
          assert cursor.count() < 2, msg
          try:
              legislator = next(cursor)
          except StopIteration:
              raise Http404('No legislator was found with leg_id = %r' % _id)
          else:
              return redirect(legislator.get_absolute_url(), permanent=True)
  
      if not legislator['active']:
          return legislator_inactive(request, abbr, legislator)
  
      district = db.districts.find({'abbr': abbr, 'chamber': legislator['chamber'],
                                    'name': legislator['district']})
      if district:
          district_id = district[0]['division_id']
      else:
          district_id = None
  
      sponsored_bills = legislator.sponsored_bills(
          limit=6, sort=[('action_dates.first', pymongo.DESCENDING)])
  
      # Note to self: Another slow query
      legislator_votes = legislator.votes_6_sorted()
      has_votes = bool(legislator_votes)
      return render(
          request, templatename('legislator'),
          dict(vote_preview_row_template=templatename('vote_preview_row'),
               roles=legislator.roles_manager, abbr=abbr,
               district_id=district_id, metadata=meta, legislator=legislator,
               sources=legislator['sources'],
               sponsored_bills=list(sponsored_bills),
               legislator_votes=list(legislator_votes),
               has_votes=has_votes,
               nav_active='legislators'))