internetarchive / openlibrary

One webpage for every book ever published!

Home Page:https://openlibrary.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Follow buttons to Patron Profile pages

mekarpeles opened this issue · comments

commented

Currently, the patron profile page at https://openlibrary.org/people/ScarTissue has to follow button
Screenshot 2024-05-29 at 8 32 17 AM

But the My Books page at https://openlibrary.org/people/ScarTissue/books does Screenshot 2024-05-29 at 8 33 15 AM

In templates/account/view.html, you can see that the Follow button widget is rendered at

$if not mb.is_my_page and mb.is_subscribed != -1:
$:macros.Follow(mb.username, following=mb.is_subscribed)
when the patron's account is public.

The issue requires you to add a Follow macro to the patron's profile page at https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/type/user/view.html

You will not have th emb (my books) object available to you and so you will have to calculate

  1. Whether the patron's account is public or private -- if it's private, don't render the widget!
  2. Whether this profile page is the current visitor's profile page -- if so, don't render the widget!
  3. Whether the visitor is subscribed or not to this patron

Most of this information is already accessible from the profile page:
https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/type/user/view.html#L5-L6

This code block shows how you might determine if this page is the patron's page and whether the visitor is subscribed to this patron:
https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/upstream/mybooks.py#L442-L447

Hello! Mind if I take this one on?