Fix opds with shelves

Fix errorhandler ldap without ldap
This commit is contained in:
Ozzieisaacs 2020-04-26 08:40:53 +02:00
parent 0480d493cf
commit 7b789b3701
3 changed files with 135 additions and 59 deletions

View File

@ -344,12 +344,12 @@ def feed_shelf(book_id):
off = request.args.get("offset") or 0
if current_user.is_anonymous:
shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.is_public == 1,
ub.Shelf.id == book_id, not ub.Shelf.deleted).first()
ub.Shelf.id == book_id).first()
else:
shelf = ub.session.query(ub.Shelf).filter(or_(and_(ub.Shelf.user_id == int(current_user.id),
ub.Shelf.id == book_id),
and_(ub.Shelf.is_public == 1,
ub.Shelf.id == book_id)), not ub.Shelf.deleted).first()
ub.Shelf.id == book_id))).first()
result = list()
# user is allowed to access shelf
if shelf:

View File

@ -112,11 +112,12 @@ for ex in default_exceptions:
app.register_error_handler(ex, internal_error)
# Only way of catching the LDAPException upon logging in with LDAP server down
@app.errorhandler(services.ldap.LDAPException)
def handle_exception(e):
log.debug('LDAP server not accessible while trying to login to opds feed')
return error_http(FailedDependency())
if feature_support['ldap']:
# Only way of catching the LDAPException upon logging in with LDAP server down
@app.errorhandler(services.ldap.LDAPException)
def handle_exception(e):
log.debug('LDAP server not accessible while trying to login to opds feed')
return error_http(FailedDependency())
web = Blueprint('web', __name__)

View File

@ -36,17 +36,17 @@
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-6 col-md-6 col-sm-offset-3" style="margin-top:50px;">
<p class='text-justify attribute'><strong>Start Time: </strong>2020-04-18 10:46:25</p>
<p class='text-justify attribute'><strong>Start Time: </strong>2020-04-25 21:22:13</p>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-6 col-sm-offset-3">
<p class='text-justify attribute'><strong>Stop Time: </strong>2020-04-18 11:34:54</p>
<p class='text-justify attribute'><strong>Stop Time: </strong>2020-04-25 22:12:24</p>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-6 col-sm-offset-3">
<p class='text-justify attribute'><strong>Duration: </strong>41:54 min</p>
<p class='text-justify attribute'><strong>Duration: </strong>42:25 min</p>
</div>
</div>
</div>
@ -975,51 +975,19 @@
<tr class="result['header']['style']">
<td>test_kobo_sync.test_kobo_sync</td>
<td class="text-center">3</td>
<td class="text-center">2</td>
<td class="text-center">1</td>
<td class="text-center">8</td>
<td class="text-center">8</td>
<td class="text-center">0</td>
<td class="text-center">0</td>
<td class="text-center">0</td>
<td class="text-center">
<a onclick="showClassDetail('c8', 3)">Detail</a>
<a onclick="showClassDetail('c8', 8)">Detail</a>
</td>
</tr>
<tr id='ft8.1' class='none bg-danger'>
<td>
<div class='testcase'>test_check_sync</div>
</td>
<td colspan='6'>
<div class="text-center">
<a class="popup_link text-center" onfocus='blur()' onclick="showTestDetail('div_ft8.1')">FAIL</a>
</div>
<!--css div popup start-->
<div id='div_ft8.1' class="popup_window test_output" style="display:none;">
<div class='close_button pull-right'>
<button type="button" class="close" aria-label="Close" onfocus='this.blur();'
onclick="document.getElementById('div_ft8.1').style.display='none'"><span
aria-hidden="true">&times;</span></button>
</div>
<div class="text-left pull-left">
<pre class="text-left">Traceback (most recent call last):
File "/home/matthias/Entwicklung/calibre-web-test/test/test_kobo_sync.py", line 89, in test_check_sync
self.assertEqual(r.json()['Resources']['image_url_quality_template'], self.kobo_adress+"/{ImageId}/{width}/{height}/image.jpg")
AssertionError: 'http[35 chars]65c2703d57c660b93b6ebdafa/{ImageId}/image.jpg' != 'http[35 chars]65c2703d57c660b93b6ebdafa/{ImageId}/{width}/{height}/image.jpg'
- http://192.168.188.33:8083/kobo/8e590a265c2703d57c660b93b6ebdafa/{ImageId}/image.jpg
+ http://192.168.188.33:8083/kobo/8e590a265c2703d57c660b93b6ebdafa/{ImageId}/{width}/{height}/image.jpg
? +++++++++++++++++</pre>
</div>
<div class="clearfix"></div>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='pt8.2' class='hiddenRow bg-success'>
<tr id='pt8.1' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_kobo_about</div>
</td>
@ -1028,7 +996,25 @@ AssertionError: 'http[35 chars]65c2703d57c660b93b6ebdafa/{ImageId}/image.jpg' !=
<tr id='pt8.2' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_shelves_add_remove_books</div>
</td>
<td colspan='6' align='center'>PASS</td>
</tr>
<tr id='pt8.3' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_sync_changed_book</div>
</td>
<td colspan='6' align='center'>PASS</td>
</tr>
<tr id='pt8.4' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_sync_invalid</div>
</td>
@ -1036,17 +1022,53 @@ AssertionError: 'http[35 chars]65c2703d57c660b93b6ebdafa/{ImageId}/image.jpg' !=
</tr>
<tr id='pt8.5' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_sync_reading_state</div>
</td>
<td colspan='6' align='center'>PASS</td>
</tr>
<tr id='pt8.6' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_sync_shelf</div>
</td>
<td colspan='6' align='center'>PASS</td>
</tr>
<tr id='pt8.7' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_sync_unchanged</div>
</td>
<td colspan='6' align='center'>PASS</td>
</tr>
<tr id='pt8.8' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_sync_upload</div>
</td>
<td colspan='6' align='center'>PASS</td>
</tr>
<tr class="result['header']['style']">
<td>test_ldap.test_ldap_login</td>
<td class="text-center">8</td>
<td class="text-center">8</td>
<td class="text-center">9</td>
<td class="text-center">9</td>
<td class="text-center">0</td>
<td class="text-center">0</td>
<td class="text-center">0</td>
<td class="text-center">
<a onclick="showClassDetail('c9', 8)">Detail</a>
<a onclick="showClassDetail('c9', 9)">Detail</a>
</td>
</tr>
@ -1123,6 +1145,15 @@ AssertionError: 'http[35 chars]65c2703d57c660b93b6ebdafa/{ImageId}/image.jpg' !=
</tr>
<tr id='pt9.9' class='hiddenRow bg-success'>
<td>
<div class='testcase'>test_ldap_opds_download_book</div>
</td>
<td colspan='6' align='center'>PASS</td>
</tr>
<tr class="result['header']['style']">
@ -1209,7 +1240,7 @@ AssertionError: 'http[35 chars]65c2703d57c660b93b6ebdafa/{ImageId}/image.jpg' !=
</div>
<div class="text-left pull-left">
<pre class="text-left">Traceback (most recent call last):
File "/home/matthias/Entwicklung/calibre-web-test/test/test_logging.py", line 136, in test_logfile_recover
File "/home/matthias/Entwicklung/calibre-web-test/test/test_logging.py", line 137, in test_logfile_recover
self.assertTrue(logpath=="", "logfile config value is not empty after reseting to default")
AssertionError: False is not true : logfile config value is not empty after reseting to default</pre>
</div>
@ -1354,8 +1385,8 @@ AssertionError: False is not true : logfile config value is not empty after rese
<tr class="result['header']['style']">
<td>test_opds_feed.test_opds_feed</td>
<td class="text-center">20</td>
<td class="text-center">20</td>
<td class="text-center">0</td>
<td class="text-center">19</td>
<td class="text-center">1</td>
<td class="text-center">0</td>
<td class="text-center">0</td>
<td class="text-center">
@ -1509,11 +1540,31 @@ AssertionError: False is not true : logfile config value is not empty after rese
<tr id='pt13.17' class='hiddenRow bg-success'>
<tr id='ft13.17' class='none bg-danger'>
<td>
<div class='testcase'>test_opds_shelf_access</div>
</td>
<td colspan='6' align='center'>PASS</td>
<td colspan='6'>
<div class="text-center">
<a class="popup_link text-center" onfocus='blur()' onclick="showTestDetail('div_ft13.17')">FAIL</a>
</div>
<!--css div popup start-->
<div id='div_ft13.17' class="popup_window test_output" style="display:none;">
<div class='close_button pull-right'>
<button type="button" class="close" aria-label="Close" onfocus='this.blur();'
onclick="document.getElementById('div_ft13.17').style.display='none'"><span
aria-hidden="true">&times;</span></button>
</div>
<div class="text-left pull-left">
<pre class="text-left">Traceback (most recent call last):
File "/home/matthias/Entwicklung/calibre-web-test/test/test_opds_feed.py", line 511, in test_opds_shelf_access
self.assertEqual(200, r.status_code)
AssertionError: 200 != 500</pre>
</div>
<div class="clearfix"></div>
</div>
<!--css div popup end-->
</td>
</tr>
@ -2205,8 +2256,8 @@ AssertionError: False is not true : logfile config value is not empty after rese
<tr id='total_row' class="text-center bg-grey">
<td>Total</td>
<td>186</td>
<td>177</td>
<td>192</td>
<td>183</td>
<td>2</td>
<td>0</td>
<td>7</td>
@ -2253,6 +2304,12 @@ AssertionError: False is not true : logfile config value is not empty after rese
<td>Basic</td>
</tr>
<tr>
<th>backports-abc</th>
<td>0.5</td>
<td>Basic</td>
</tr>
<tr>
<th>Flask</th>
<td>1.1.2</td>
@ -2283,6 +2340,12 @@ AssertionError: False is not true : logfile config value is not empty after rese
<td>Basic</td>
</tr>
<tr>
<th>Jinja2</th>
<td>2.11.2</td>
<td>Basic</td>
</tr>
<tr>
<th>PyPDF2</th>
<td>1.26.0</td>
@ -2325,12 +2388,24 @@ AssertionError: False is not true : logfile config value is not empty after rese
<td>Basic</td>
</tr>
<tr>
<th>Unidecode</th>
<td>1.1.1</td>
<td>Basic</td>
</tr>
<tr>
<th>Wand</th>
<td>0.5.9</td>
<td>Basic</td>
</tr>
<tr>
<th>Werkzeug</th>
<td>1.0.1</td>
<td>Basic</td>
</tr>
<tr>
<th>lxml</th>
<td>4.5.0</td>
@ -2339,7 +2414,7 @@ AssertionError: False is not true : logfile config value is not empty after rese
<tr>
<th>Pillow</th>
<td>7.1.1</td>
<td>7.1.2</td>
<td>test_edit_books</td>
</tr>
@ -2381,7 +2456,7 @@ AssertionError: False is not true : logfile config value is not empty after rese
</div>
<script>
drawCircle(177, 2, 0, 7);
drawCircle(183, 2, 0, 7);
</script>
</div>