reviews don't appear in edition template

Bug #183229 reported by Aaron Swartz
2
Affects Status Importance Assigned to Milestone
Open Library
Won't Fix
Medium
webchick

Bug Description

http://demo.openlibrary.org/b/On_beauty_novel has a review but it doesn't appear.

Aaron Swartz (aaronsw)
Changed in openlibrary:
assignee: nobody → tommi+
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
webchick (webchick) wrote :

odd - this appears to be broken on staging, too -

http://demo.openlibrary.org:8080/b/adventures_of_Tom_Sawyer

We must have overwritten something ...

Revision history for this message
Aaron Swartz (aaronsw) wrote :

blocking launch on this

Changed in openlibrary:
milestone: none → launch
Revision history for this message
Aaron Swartz (aaronsw) wrote :

webchick, can you add this to the templates?

Changed in openlibrary:
assignee: tommi+ → webchick
Revision history for this message
webchick (webchick) wrote :

working on it - the code tommi supplied me via email only solves part of the problem. The links to the individual reviews are showing up, but the actual reviews are not listed on the page as it was before

---------------------------------------------------
SAMPLE CODE
---------------------------------------------------
<a name="reviews"></a>
<br clear="both" />
$if page.d.get('reviews'):
    <div id="form-border">
    <div class="bookmarks"><b>Reviews of <a href="#top">$page.title:</a></b></div>
    $for i, review in enumerate(page.d.reviews):
 <div class="result-item">
 <span class="number-results">$(i + 1)</span>
 <span class="result-text"><a href="/$review.name" class="result"> $review.title</a><br />
        $review.text
        - <a href="/$review.author.name">$review.author.displayname</a></span>
        </div>
</div>

Revision history for this message
webchick (webchick) wrote :

I added comments in the code so you can see what I am talking about ...

http://demo.openlibrary.org:8080/type/edition/view.tmpl?m=edit

Revision history for this message
webchick (webchick) wrote :

Bizarre - I removed a div and everything magically appeared -

http://demo.openlibrary.org:8080/type/edition/view.tmpl?b=293&a=292&m=diff

But there is no reason why that div should not be visible:

http://demo.openlibrary.org:8080/static/css/master.css

Revision history for this message
webchick (webchick) wrote :

Well - I was wrong - I put the div back in and it works - so it is a problem with the loop - for instance, here is a book without reviews - the headers should not show.

http://demo.openlibrary.org:8080/b/Whole_earth_catalog

Anyway, I am going to stop talking to myself now.

Revision history for this message
Aaron Swartz (aaronsw) wrote : Re: [Bug 183229] Re: reviews don't appear in edition template

It's the spacing -- ifs and fors need to be indented by exactly four spaces.

Revision history for this message
Tommi (tommi+-deactivatedaccount) wrote :

Yeah, the template syntax is pretty strict.

(Feel free to let me know if there's anything more you'd need help with.)

Revision history for this message
webchick (webchick) wrote :

OK - I have the template working

With Reviews -
http://demo.openlibrary.org:8080/b/Heartbreaking_of_Genius_0

Without Reviews -
http://demo.openlibrary.org:8080/b/France_Zupan

I am not completely satisfied with how the reviews are listed under the "REVIEW BOOK" button, but will address this on the redesign of the book view template.

Tommi - if you want to take a stab at making the word "reviews" under that button only show if there are reviews, that would be most appreciated. I tried, but I kept generating an error in the template. Thanks!

Revision history for this message
Tommi (tommi+-deactivatedaccount) wrote :

Becky - it seems there's an extra space character at the end of this line:

    $if page.d.get('reviews'):

My guess is that removing it should help. Or, you could try replacing the line altogether with this:

    $if page.d.get('reviews') and len(page.d.reviews) > 0:

...I think it should help.

Revision history for this message
webchick (webchick) wrote :

ugh - I tried both options, and moved the word "Reviews" up on the line with the code - but was not successful.

Then for kicks I tried just using the following:

    $if page.d.get('reviews') > 0:

... as I was tinkering around with something similar yesterday. I have also looked at the Search Results macro to see if I could glean any insight since it uses some of the same logic. No luck.

Revision history for this message
Aaron Swartz (aaronsw) wrote :

The spacing was all wrong; I fixed it and it still didn't work for
mysterious reasons. But if I changed the clause to:

$if page.d.reviews:

it started working. I don't know why this is, but it seems to work
now, altho there are some style issues with multiple comments on my
browser.

Revision history for this message
Tommi (tommi+-deactivatedaccount) wrote :

Great. Thanks, Aaron.

Revision history for this message
webchick (webchick) wrote :

I am getting an 'exceptions.TypeError' on the staging server when I try to submit a review -

http://demo.openlibrary.org:8080/addreview?edition=b/Little_women_4

Changed in openlibrary:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.