Skip to content

Commit

Permalink
Fix pdf name
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamek committed Jun 12, 2018
1 parent bd75237 commit 0ed11d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions blacklist/views/api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ def get_thumbnail(blacklist_id: int):
return send_from_directory(current_app.config['THUMBNAIL_STORAGE_FOLDER'], filename='thumbnail_{}.png'.format(blacklist.id)), 200


@api_index.route('/pdf/<int:pdf_id>.pdf', methods=['GET'])
def get_pdf(pdf_id: int):
@api_index.route('/pdf/<string:pdf_sum>.pdf', methods=['GET'])
def get_pdf(pdf_sum: str):

pdf = Pdf.query.filter_by(id=pdf_id).first()
pdf = Pdf.query.filter_by(sum=pdf_sum).first()
if not pdf:
return jsonify({
'message': 'PDF with ID {} not found.'.format(pdf_id)
'message': 'PDF with sum {} not found.'.format(pdf_sum)
}), 400

return send_from_directory(current_app.config['PDF_STORAGE_FOLDER'], filename='{}.pdf'.format(pdf.sum)), 200
Expand Down
2 changes: 1 addition & 1 deletion blacklist/views/crawl/templates/crawl.index.crawl.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>{{ _('Crawl LOG') }}</h1>
{% for item in pagination.items %}
<tr>
<th scope="row">{{item.id}}</th>
<td><a href="{{ url_for('api.index.get_pdf', pdf_id=item.id) }}" target="_blank">{{item.name}}</a></td>
<td><a href="{{ url_for('api.index.get_pdf', pdf_sum=item.sum) }}" target="_blank">{{item.name}}</a></td>
<td>{{item.sum}}</td>
<td>{{item.blacklist.count()}}</td>
<td>{{item.signed|format_boolean|safe}}</td>
Expand Down

0 comments on commit 0ed11d2

Please sign in to comment.