/upstream/templates/borrow_admin.tmpl
Type: /type/template
body: value: $def with (page, edition_loans, user_loans, user_ip)

$var title: $page.title

$ _x = ctx.setdefault('bodyid', 'plain')

$ available_loans = page.get_available_loans()

$ current_and_available_loans = page.get_current_and_available_loans()
$ current_loans = current_and_available_loans[0]
$ loan_users = [loan['user'] for loan in current_loans]

$def format_users(users):
    $for user_key in users:
        $ user = get_document(user_key)
        <a href="$user.key">$user.name ($user.key)</a>

<div id="contentBody">

    <div class="navBorrow">
        <a href="javascript:;" onclick="history.go(-1);"><strong>Back</strong></a>
    </div>

        <h1 class="sansserif">Borrow - Administration</h1>

        <p>
            You're logged in as: <br />
            <ul>
                 <li>$ctx.user <i>(ctx.user)</i>, Admin = $ctx.user.is_admin()</li>
                 <li>$user_ip <i>IP</i></li>
                 <li>          
                     $if "inlibrary" in ctx.features:
                         In Library: $get_library()
                     $else:
                         <i>Not in a Library</i>
                     </li>
            </ul>
        </p>

        <hr />

        <p>
            Book can be borrowed = $can_borrow(page) <!-- can_borrow -->
        </p>

        <p>
            $if loan_users:
              Borrowed by: $:format_users(loan_users)
            $else:
              Borrowed by: None
        </p>

        <p>
            Available? <i>(what's been borrowed = false)</i><br />
            <ul>
                <li>BookReader = $is_loan_available(page, 'bookreader')</li>
                <li>PDF = $is_loan_available(page, 'pdf')</li>
                <li>ePub = $is_loan_available(page, 'epub')</li>
            </ul>
        </p>

        <p>
            archive.org ID: <a href="http://www.archive.org/details/$page.ocaid">$page.ocaid</a>
            <ul>
                <li>IA Collections: $page.get_ia_meta_fields()['collection']</li>
                <li>OL Subjects: $page.works[0].get_subjects()</li>
                <li>Overdrive ID: $overdrive_id(page)</li>
            </ul>
        <p>




        <hr />

        <p>
            <b>Current Loan Status:</b><br />
            $edition_loans
        </p>

        <p>
            external-identifiers from archive.org meta.xml: $page.get_lending_resources()
        </p>
        
        <p>
            $ pdf_resource_id = page.get_lending_resource_id('pdf')
            pdf resourceid: $pdf_resource_id<br>
            $ epub_resource_id = page.get_lending_resource_id('epub')
            epub resourceid: $epub_resource_id
        </p>
        
        <p>
            <table>
              <tr><th>Available loans for $page.title:</tr></th>
              $for loan in available_loans:
                 <tr><td>$loan</td></tr>
            </table>
        </p>

        <p>
            edition.get_current_and_available_loans(): $current_and_available_loans
        </p>
        
        <p>
            Book status in ACS4:<br>
            $ bss = 'http://lending.us.archive.org/bss/bss.py'
            $ bss_format = "<a href='" + bss + "/%(what)s/%(urn)s'>%(type)s %(what)s</a><br>"
            $ pdf_loaned = bss_format % { 'what': 'is_loaned_out', 'urn': pdf_resource_id, 'type': 'pdf' }
            $:pdf_loaned
            $ pdf_info = bss_format % { 'what': 'resource_info', 'urn': pdf_resource_id, 'type': 'pdf' }
            $:pdf_info
            $ pdf_fulfillment = bss_format % { 'what': 'fulfillment_info', 'urn': pdf_resource_id, 'type': 'pdf' }
            $:pdf_fulfillment
            
            <br>
            $ epub_loaned = bss_format % { 'what': 'is_loaned_out', 'urn': epub_resource_id, 'type': 'epub' }
            $:epub_loaned
            $ epub_info = bss_format % { 'what': 'resource_info', 'urn': epub_resource_id, 'type': 'epub' }
            $:epub_info
            $ epub_fulfillment = bss_format % { 'what': 'fulfillment_info', 'urn': epub_resource_id, 'type': 'epub' }
            $:epub_fulfillment
        </p>
        

</div>
plugin: upstream
title: Book Loan Administration
m: edit