def get_username(request):
    """Returns the username from request."""
    # Retrieve the username either from a cookie (when logging out) or
    # the authenticated user.
    username = "not-login"
    if hasattr(request, "user"):
        username = request.user.username
        if request.session.get('staff', False):
            username = "%s(*)" % username

    return username