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 author date when showing author name to librarians #9052

Merged

Conversation

Aeltumn
Copy link
Contributor

@Aeltumn Aeltumn commented Apr 9, 2024

Closes #7799

[feature]

Technical

This is a continuation of #8076. Addresses the comments on this previous PR and completes the feature. Notable changes:

  • Removed integration test as those have since been removed
  • Don't show the ( - ) if no birth date is known. It should show when no death date is set, but not if there's no birth date either
  • Use a dictionary to store the author information and only pass along the dates on the book view
  • Only show the years if the user is in librarian mode
  • Added a regex to determine the year, using one to just take the first 4 consequtive digits. This is based on a comment by @cdrini. Is this a fitting regex or did you have another one in mind?

It took some effort to figure out use to run the regex as it needs the re import. So there might have been a simpler way.

Testing

Log in with an account that is in /usergroup/librarian.
Navigate to a random book and check if the author is showing a birth and death year.

Screenshot

Before logging in
loggedout

After logging in
loggedin

Stakeholders

@jimchamp

@jimchamp jimchamp changed the title Add author date when showing author name to librarians, closes #7799 Add author date when showing author name to librarians Apr 17, 2024
Copy link
Collaborator

@jimchamp jimchamp left a comment

Choose a reason for hiding this comment

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

Thanks, @Aeltumn!

This should be good to go after the new suggested changes are implemented.

@@ -53,6 +53,7 @@
# functions imported from elsewhere
"parse_datetime",
"safeint",
"extract_year",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"extract_year",

This function was not imported from another file...
Move this line above the "functions imported from elsewhere" comment.

@@ -37,11 +37,12 @@ <h2 class="work-subtitle">
$ author_names = (work or edition).author_names
$if authors:
<h2 class="edition-byline">
$:macros.BookByline([(author.name, author.url(), author.birth_date, author.death_date) for author in authors], attrs='itemprop="author"')
$ is_librarian = ctx.user and (ctx.user.is_librarian() or ctx.user.is_super_librarian())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
$ is_librarian = ctx.user and (ctx.user.is_librarian() or ctx.user.is_super_librarian())
$ is_librarian = ctx.user and ctx.user.is_librarian()

All members of /usergroup/super-librarians are members of /usergroup/librarians.

Edit: I see that is not the case in our local environment. Make this change last, so that you are able to test the other suggested changes in your local environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the entire statement from another template, hence the or super_librarian. But I'll delete it from here after I'm done testing.

@@ -58,7 +58,7 @@ <h2 class="editFormTitle">$:title</h2>
<h1 class="editFormBookTitle">$this_title</h1>
$if authors:
<h3 class="editFormBookAuthors">
$:macros.BookByline([(author.name, author.url(), author.birth_date, author.death_date) for author in authors])
$:macros.BookByline([{'name': a.name, 'url': a.url()} for author in authors])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
$:macros.BookByline([{'name': a.name, 'url': a.url()} for author in authors])
$:macros.BookByline([{'name': a.name, 'url': a.url()} for a in authors])

This is causing errors in book edit pages. Did you test this? Also, the birth and death dates would be useful to librarians while they are editing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Managing my changes in git was a bit of a mess, so I must've gotten this mixed up somewhere.
Will fix, add the birth/date date here, and test.

@jimchamp jimchamp added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Apr 18, 2024
@Aeltumn Aeltumn requested a review from jimchamp April 19, 2024 00:27
@Aeltumn
Copy link
Contributor Author

Aeltumn commented Apr 19, 2024

I've addressed the comments and re-tested my changes.

@jimchamp jimchamp added On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing and removed Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] labels Apr 19, 2024
Copy link
Collaborator

@jimchamp jimchamp left a comment

Choose a reason for hiding this comment

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

Everything seems to be working as expected on testing. Thanks, @Aeltumn.

@jimchamp jimchamp merged commit d9fb943 into internetarchive:author-dates Apr 19, 2024
1 check passed
jimchamp added a commit that referenced this pull request Apr 19, 2024
* adding date of birth and death date in almost every place

* adding actual files, not just tests

* cleaning test file and making another test

* cleaning test file from local tests lines

* updating get doce test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add author date when showing author name to librarians (#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

---------

Co-authored-by: Lucas Sales <sales_l@hotmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Aeltumn <12281102+Aeltumn@users.noreply.github.com>
merwhite11 pushed a commit to merwhite11/openlibrary that referenced this pull request May 2, 2024
…ve#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
merwhite11 pushed a commit to merwhite11/openlibrary that referenced this pull request May 2, 2024
…ve#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
merwhite11 pushed a commit to merwhite11/openlibrary that referenced this pull request May 6, 2024
…ve#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
merwhite11 pushed a commit to merwhite11/openlibrary that referenced this pull request May 6, 2024
…ve#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
merwhite11 pushed a commit to merwhite11/openlibrary that referenced this pull request May 6, 2024
…ve#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
merwhite11 pushed a commit to merwhite11/openlibrary that referenced this pull request May 6, 2024
…ve#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
merwhite11 pushed a commit to merwhite11/openlibrary that referenced this pull request May 6, 2024
…ve#9052)

* Re-implement changes

- Store data in dictionaries
- Only show years for librarians on book page

* Delete integration test

* Use a regex to determine the year to display

* Use single quotes

* Add helper function to extract a year

* Register helper

* Final fixes

* Small clean-up

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants