Skip to content

Commit

Permalink
patron: fix patron profile for dispute event
Browse files Browse the repository at this point in the history
When a patron has some fees containing at least one 'dispute' event, the
server crash because ii tries to convert the amount of dispute (always
none) to a decimal number. This PR fix this problem checking if the
event to display has a valid 'amount' attribute. This PR also fixes some
small HTML problems on the patron profile.

Closes rero#1272

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Oct 13, 2020
1 parent 70b47a8 commit 1ee74ca
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
13 changes: 13 additions & 0 deletions rero_ils/modules/patrons/static/scss/rero_ils/patrons_profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@
width: 100%;
}
}
blockquote {
font-style: italic;
margin: 0;
&:before, &:after {
color: #AAA;
}
&:before {
content: '';
}
&:after {
content: '';
}
}
}
.force-display {
display: block !important;
Expand Down
43 changes: 22 additions & 21 deletions rero_ils/modules/patrons/templates/rero_ils/_macro_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,36 @@ <h6>{{ _('Transactions history') }}</h6>
)}}
</div>
<div class="col-lg-9 event-content">
<div class="row">
<div class="col-lg-10 col-sm-10 d-inline-block text-truncate label">
{{ _(event.type) }} [{{ _(event.subtype) }}]
</div>
<div class="col-lg-2 col-sm-2 amount">
<span
class="badge badge-{% if event.type == 'payment' %}success{% else %}danger{% endif %}">
<div class="row {% if event.type == 'dispute' %}event-highlight{% endif %}">
<div class="col-lg-10 col-sm-10 d-inline-block text-truncate label">
{{ _(event.type) }} {% if event.subtype %} [{{ _(event.subtype) }}] {% endif %}
</div>
<div class="col-lg-2 col-sm-2 amount">
{%- if event.amount %}
<span class="badge badge-{% if event.type == 'payment' %}success{% else %}danger{% endif %}">
{{ event.amount | format_currency(event.currency) }}
</span>
</div>
{%- endif %}
</div>
</div>
{%- if event.note %}
<div class="row">
<div class="col-lg-2 col-sm-1 label-title">
{% if 'note' in event %}
<i class="fa fa-comment-o pr-1" title="{{ _('Note') }}"></i>
{% endif %}
{% if event.library %}
<i class="fa fa-map-marker pr-1" title="{{ _('Library') }}"></i>
{% endif %}
<i class="fa fa-comment-o pr-1" title="{{ _('Note') }}"></i>
</div>
<div class="col-lg-10 col-sm-11">
{% if event.note %}
{{ event.note }}
{% endif %}
{% if event.library %}
{{ event.library.name }}
{% endif %}
<blockquote>{{ event.note }}</blockquote>
</div>
</div>
</div>
{%- endif %}
{%- if event.library %}
<div class="row">
<div class="col-lg-2 col-sm-1 label-title">
<i class="fa fa-map-marker pr-1" title="{{ _('Library') }}"></i>
</div>
<div class="col-lg-10 col-sm-11"> {{ event.library.name }}</div>
</div>
{%- endif %}
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion rero_ils/modules/patrons/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ def profile(viewcode):
@blueprint.app_template_filter('format_currency')
def format_currency_filter(value, currency):
"""Format currency with current locale."""
return format_currency(value, currency)
if value:
return format_currency(value, currency)


@api_blueprint.route('/roles_management_permissions', methods=['GET'])
Expand Down

0 comments on commit 1ee74ca

Please sign in to comment.