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

On books page, for borrowed book, show time remaining on loan #1110

Closed
mekarpeles opened this issue Sep 13, 2018 · 9 comments
Closed

On books page, for borrowed book, show time remaining on loan #1110

mekarpeles opened this issue Sep 13, 2018 · 9 comments
Labels
Affects: UI Issues with the web site's user interface. [managed] Good First Issue Easy issue. Good for newcomers. [managed] hacktoberfest Issues appropriate for Hacktoberfest participants Lead: @mekarpeles Issues overseen by Mek (Staff: Program Lead) [managed] Module: Books Page Module: Borrowing / Lending Needs: Design Feedback Needs: Designs Needs: Feedback A proposed feature or bug resolution needs community feedback prior to forging ahead. [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed]
Milestone

Comments

@mekarpeles
Copy link
Member

mekarpeles commented Sep 13, 2018

https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/type/edition/view.html is the file that renders the books page.

The read buttons themselves are rendered using:
https://github.com/internetarchive/openlibrary/blob/master/openlibrary/macros/LoanStatus.html

The loan/lending logic can be found in:
https://github.com/internetarchive/openlibrary/blob/master/openlibrary/core/lending.py

The desired outcome is near the button, similar to the Loans page, we show the expiration date of the loan
Screenshot 2024-03-08 at 12 29 34 PM

@mekarpeles
Copy link
Member Author

mekarpeles commented Sep 13, 2018

This data is already available on the https://openlibrary.org/account/loans page, it should also show up on the book pages (i.e. work + edition page), e.g. https://openlibrary.org/works/OL14909099W/Debt / https://openlibrary.org/books/OL24088724M/Debt

Preferably above/below/near the blue "Read eBook" button

@tabshaikh
Copy link
Collaborator

@mekarpeles maybe you could highlight some files to work on in this issue

@mekarpeles mekarpeles added this to the Google Code-In 2018 milestone Sep 17, 2018
@mekarpeles mekarpeles added the hacktoberfest Issues appropriate for Hacktoberfest participants label Sep 29, 2018
@mekarpeles mekarpeles removed this from the Google Code-In 2018 milestone Sep 29, 2018
@justanotherlad
Copy link

Hi ! I'm just beginning with open-source. Can you guide me how to work on this issue?

@mekarpeles mekarpeles removed the easy label Oct 10, 2018
@mekarpeles
Copy link
Member Author

Hi @swastikbanerjee07!

  1. First, follow the instructions to setup Open Library using Docker
  2. You may want to borrow a book on production (https://openlibrary.org) and then navigate to your /account/loans page. The corresponding code should be in openlibrary/templates/account/borrow.html You should see a block of code in the template like loan['expiry'] which is how that template is getting the loan expiration date
  3. On the books page template (openlibrary/templates/type/edition/view.html) you'll see see a section called editionTools which loads a macro $:macros.databarWork(page, editions_page=True). The code to this macro is in openlibrary/macros/databarWork.html
  1. Within the databarWork.html macro, you'll have to fetch a loan (if it exists) just like is done in the loans page in step catalog/onix/onix.py attempts to use a global variable in init(), but doesn't declare it global #2. And then you'll want to display the time remaining. Once you're at this step, we'll be able to help guide you regarding the style / position, etc.

One thing which makes this task a bit hard is loans don't really work on local developer instances. We can help you mock them or, once you have something you think is working, we can run the code on https://dev.openlibrary.org so you can test against real data.

@Zacharius
Copy link

I have a likely solution at https://github.com/Zacharius/openlibrary/tree/1110/feature/loan-timer-on-book-page. Can someone run it on the dev site to see if it works?

I ran the docker image with the code and it didnt give any errors or look wonky on the books page so thats promising. Not sure how else to test it

@Zacharius
Copy link

@mekarpeles any chance you can help me test this?

@jdlrobson jdlrobson added the Needs: Feedback A proposed feature or bug resolution needs community feedback prior to forging ahead. [managed] label Dec 15, 2018
@jdlrobson
Copy link
Collaborator

^ ping @mekarpeles can you give @Zacharius some feedback?

@shreyansh23
Copy link
Contributor

@mekarpeles I was trying to solve this issue.
I followed the instructions in your previous comment.
I observed how expiry data is coming in /account/loans page.
I reached here,

    path = "/account/loans"

    @require_login
    def GET(self):
        user = accounts.get_current_user()
        user.update_loan_status()
        loans = borrow.get_loans(user)
        return render['account/borrow'](user, loans)

I want this loans object available to edition templates. I am stuck how to implement that. I think I am thinking in the wrong way.
Any suggesions or can I get expiry date in some other way?

@mekarpeles mekarpeles removed the Good First Issue Easy issue. Good for newcomers. [managed] label May 14, 2019
@mekarpeles mekarpeles removed their assignment May 14, 2019
@tabshaikh tabshaikh added this to the Hacktoberfest milestone Sep 25, 2019
@xayhewalo
Copy link
Collaborator

Still no seeing time remaining for a borrowed work. @Zacharius did @mekarpeles ever get back to you?

@xayhewalo xayhewalo added Affects: UI Issues with the web site's user interface. [managed] Priority: 3 Issues that we can consider at our leisure. [managed] State: Backlogged Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed] labels Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Affects: UI Issues with the web site's user interface. [managed] Good First Issue Easy issue. Good for newcomers. [managed] hacktoberfest Issues appropriate for Hacktoberfest participants Lead: @mekarpeles Issues overseen by Mek (Staff: Program Lead) [managed] Module: Books Page Module: Borrowing / Lending Needs: Design Feedback Needs: Designs Needs: Feedback A proposed feature or bug resolution needs community feedback prior to forging ahead. [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed]
Projects
None yet
Development

No branches or pull requests

8 participants