Repository: pypi/warehouse

Issue:
Change 'statistics' text based on whether it is the logged in user
Right now, we have the following text on the user profile page:

![screenshot from 2018-04-09 12-49-03](https://user-images.githubusercontent.com/3323703/38496203-855bca30-3bf4-11e8-8643-3655e76c7c9b.png)

This text shows whether the user being viewed is logged in or not.

What would be better:

1. *If* the logged in user is viewing their *own* public profile, show:

```html
View statistics for your projects via Libraries.io, or by using Google BigQuery.
```

2. *Else* (the user is not logged in, or is viewing the profile of _another_ user), show:

```
View statistics for <username>'s projects via Libraries.io, or by using Google BigQuery.
```
---

**Screenshot Required**: This issue will require an update to the visual design of the site. To help our team give you faster feedback, please include a screenshot in your Pull Request.



Discussion:
This will be a tad bit tricky, since we are annoyingly strict about access to the session when rendering pages to help in caching. It will either need to be rendered client side, or we'll need to use a client side include for it.
@dstufft - we are already using an include for the 'edit' account button here:
https://github.com/pypa/warehouse/blob/master/warehouse/templates/accounts/profile.html#L35

So, I think it might just be a case of extending (and perhaps renaming?) this file:

https://github.com/pypa/warehouse/blob/master/warehouse/templates/includes/accounts/edit-profile-button.html
@nlhkabu That would work yea, though it'll shift the HTML around a bit since the csi just replaces the content where the csi itself is, it can't replace the content down further.

Resolving patch:
diff --git a/warehouse/accounts/views.py b/warehouse/accounts/views.py
--- a/warehouse/accounts/views.py
+++ b/warehouse/accounts/views.py
@@ -477,9 +477,9 @@ def profile_callout(user, request):
 
 
 @view_config(
-    route_name="includes.edit-profile-button",
+    route_name="includes.profile-actions",
     context=User,
-    renderer="includes/accounts/edit-profile-button.html",
+    renderer="includes/accounts/profile-actions.html",
     uses_session=True,
 )
 def edit_profile_button(user, request):
diff --git a/warehouse/routes.py b/warehouse/routes.py
--- a/warehouse/routes.py
+++ b/warehouse/routes.py
@@ -76,8 +76,8 @@ def includeme(config):
         domain=warehouse,
     )
     config.add_route(
-        "includes.edit-profile-button",
-        "/_includes/edit-profile-button/{username}",
+        "includes.profile-actions",
+        "/_includes/profile-actions/{username}",
         factory="warehouse.accounts.models:UserFactory",
         traverse="/{username}",
         domain=warehouse,


Test patch:
diff --git a/tests/unit/test_routes.py b/tests/unit/test_routes.py
--- a/tests/unit/test_routes.py
+++ b/tests/unit/test_routes.py
@@ -108,8 +108,8 @@ def add_policy(name, filename):
             domain=warehouse,
         ),
         pretend.call(
-            "includes.edit-profile-button",
-            "/_includes/edit-profile-button/{username}",
+            "includes.profile-actions",
+            "/_includes/profile-actions/{username}",
             factory="warehouse.accounts.models:UserFactory",
             traverse="/{username}",
             domain=warehouse,