Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add follow button to patron profile pages #9374

Conversation

pidgezero-one
Copy link
Contributor

@pidgezero-one pidgezero-one commented Jun 1, 2024

Closes #9358

Adds a follow button to a user's patron page.

Technical

  • The button should only show if you are logged in, not looking at your own page, not already following the user, and the user's reading list is public.
  • Moves the is_subscribed check business logic from MyBooksTemplate to the user level so that it can also be leveraged by the patron page. This seems like an appropriate place for it IMO as the user model also includes other object reference checks like is_usergroup_member.

Testing

I added a test patron via the provided instructions.
(The rest of my testing steps are outlined in the Screenshots section)

Screenshot

Viewing my own page: no follow button (public or private)
image
image

Viewing a public patron while logged in: follow button appears
image

Click the follow button: it becomes an unfollow button
image

Viewing a public patron logged out / incognito: follow button appears
image

Clicking the follow button while logged out prompts a login
image

After changing the test user's reading log to public, no button appears, logged in or logged out;
image
image

Stakeholders

@mekarpeles

Attribution Disclaimer: By proposing this pull request, I affirm to have made a best-effort and exercised my discretion to make sure relevant sections of this code which substantially leverage code suggestions, code generation, or code snippets from sources (e.g. Stack Overflow, GitHub) have been annotated with basic attribution so reviewers & contributors may have confidence and access to the correct context to evaluate and use this code.

@pidgezero-one pidgezero-one marked this pull request as ready for review June 1, 2024 18:08
@@ -1,9 +1,12 @@
$def with (page)

$var title: $page.displayname
$ username = page.key.split('/')[-1]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a safer way to get this, such as from get_users_settings? Or is this way of doing it considered pretty safe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be okay in this case.

@pidgezero-one pidgezero-one changed the title [WIP] Add follow button to patron profile pages Add follow button to patron profile pages Jun 1, 2024
@pidgezero-one
Copy link
Contributor Author

Other than my open question in the files listing, I have two more:

  • Is my placement of the follow button ideal (shown in the screenshots) or should I move it elsewhere?
  • I think this might be an Infogami knowledge gap for me, but is there a macro of some sort to create new user accounts on a local dev environment? I'd like to verify that moving the business logic for is_subscribed to the user level doesn't break MyBooksTemplate, but http://localhost:8080/people/aaa/books is a broken link (both on this branch and on master) because (I assume) it's not a real user account due to the way I created it.

@mekarpeles mekarpeles self-assigned this Jun 2, 2024
@mekarpeles
Copy link
Member

mekarpeles commented Jun 2, 2024

Really nice work @pidgezero-one!

re: your questions above:

A few edge cases for us to consider:

  1. If the patron is logged out and the profile they're on is public, the patron should likely see a follow button
  2. If the patron is already following the profile, they should see the unfollow button.

When I am logged in and go to https://testing.openlibrary.org/people/brewster, I see the correct thing:
Screenshot 2024-06-02 at 9 58 50 AM

When I am logged out, I don't:
Screenshot 2024-06-02 at 9 59 23 AM

Also, when I try to click Follow: https://testing.openlibrary.org/people/mekBot/follows.json?debug=true I get

<class 'AttributeError'> at /people/mekBot/follows.json
type object 'PubSub' has no attribute 'get_subscriptions'
Screenshot 2024-06-02 at 10 01 01 AM

On /people/brewster/books it works correctly where, once I follow, I see unfollow btn
Screenshot 2024-06-02 at 10 01 37 AM

Test Checklist

  • If I'm logged in already following public profile X, I should see Unfollow btn
  • If I am logged out and profile X is public, I should see Follow btn
  • If click Follow, the flow should succeed :)

@pidgezero-one
Copy link
Contributor Author

@mekarpeles Thank you! :) I've pushed another commit that addresses these issues, and have updated my screenshots in the PR description according to the checklist provided.

@mekarpeles mekarpeles added On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing Priority: 2 Important, as time permits. [managed] labels Jun 6, 2024
@mekarpeles mekarpeles merged commit e7f11e7 into internetarchive:master Jun 25, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing Priority: 2 Important, as time permits. [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Follow buttons to Patron Profile pages
2 participants