docs: def profile_view(request, semester, targetUsername, profile=None):
      """
      Show the user their workshift history for the current semester as well as
      upcoming shifts.
      """
      wprofile = get_object_or_404(
          WorkshiftProfile,
          user__username=targetUsername,
          semester=semester
      )
      if wprofile == profile:
          page_name = "My Workshift Profile"
      else:
          page_name = "{}'s Workshift Profile".format(wprofile.user.get_full_name())
  
      past_shifts = WorkshiftInstance.objects.filter(
          Q(workshifter=wprofile) | Q(liable=wprofile),
          closed=True,
      )
      regular_shifts = RegularWorkshift.objects.filter(
          active=True, current_assignees=wprofile,
      )
      assigned_instances = WorkshiftInstance.objects.filter(
          Q(workshifter=wprofile) | Q(liable=wprofile),
          closed=False,
      ).exclude(
          weekly_workshift__current_assignees=wprofile,
      )
      pool_hours = wprofile.pool_hours.order_by(
          "-pool__is_primary", "pool__title",
      )
      first_standing, second_standing, third_standing = \
        any(pool_hours.first_date_standing for pool_hours in wprofile.pool_hours.all()), \
        any(pool_hours.second_date_standing for pool_hours in wprofile.pool_hours.all()), \
        any(pool_hours.third_date_standing for pool_hours in wprofile.pool_hours.all())
  
      full_management = utils.can_manage(request.user, semester=semester)
      any_management = utils.can_manage(request.user, semester, any_pool=True)
      view_note = wprofile == profile or full_management
  
      return render_to_response("profile.html", {
          "page_name": page_name,
          "profile": wprofile,
          "view_note": view_note,
          "past_shifts": past_shifts,
          "regular_shifts": regular_shifts,
          "assigned_instances": assigned_instances,
          "pool_hours": pool_hours,
          "first_standing": first_standing,
          "second_standing": second_standing,
          "third_standing": third_standing,
          "can_edit": any_management,
      }, context_instance=RequestContext(request))