-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patron: change message on expired account
* Closes #2920. Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
- Loading branch information
1 parent
fe899d3
commit 7e86e34
Showing
7 changed files
with
182 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
rero_ils/theme/templates/rero_ils/_patron_info_message.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{# -*- coding: utf-8 -*- | ||
|
||
RERO ILS | ||
Copyright (C) 2023 RERO | ||
Copyright (C) 2023 UCLouvain | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#} | ||
{% set patron_message = patron_message() %} | ||
{% if patron_message and patron_message.show_info %} | ||
<div class="patron-info-message"> | ||
<div class="container mt-0"> | ||
{% set view = viewcode or config.RERO_ILS_SEARCH_GLOBAL_VIEW_CODE %} | ||
{% if view == config.RERO_ILS_SEARCH_GLOBAL_VIEW_CODE %} | ||
<ul class="list-unstyled py-2 mb-0"> | ||
{% for key, patron in patron_message.data.items() %} | ||
{% if patron.blocked.is_blocked or patron.is_expired %} | ||
<li class="py-1"> | ||
<span class="font-weight-bold">{{ patron.name }}</span> | ||
{% with data=patron %} | ||
{%- include "rero_ils/_patron_info_message_data.html" -%} | ||
{% endwith %} | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
{% if view in patron_message.data %} | ||
{% set message = patron_message.data[view] %} | ||
{% if message.blocked.is_blocked or message.is_expired %} | ||
<div class="py-2"> | ||
{% with data=message %} | ||
{%- include "rero_ils/_patron_info_message_data.html" -%} | ||
{% endwith %} | ||
</div> | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
</div> | ||
{% endif %} |
25 changes: 25 additions & 0 deletions
25
rero_ils/theme/templates/rero_ils/_patron_info_message_data.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{# -*- coding: utf-8 -*- | ||
|
||
RERO ILS | ||
Copyright (C) 2023 RERO | ||
Copyright (C) 2023 UCLouvain | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#} | ||
{% if data.blocked.is_blocked %} | ||
<div class="message-blocked">{{ data.blocked.message }}</div> | ||
{% endif %} | ||
{% if data.is_expired %} | ||
<div class="message-expired">{{ _('Your account has expired.') }} {{ _('Please contact your library.') }}</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# RERO ILS | ||
# Copyright (C) 2023 RERO | ||
# Copyright (C) 2023 UCLouvain | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Tests message UI view for patrons.""" | ||
|
||
from bs4 import BeautifulSoup | ||
from flask import url_for | ||
from invenio_accounts.testutils import login_user_via_view | ||
|
||
|
||
def test_info_message(app, client, patron_martigny, patron_martigny_data, | ||
org_martigny_data): | ||
"""Test info message.""" | ||
patron_martigny['patron']['blocked'] = True | ||
patron_martigny['patron']['blocked_note'] = 'This is a blocked message.' | ||
patron_martigny['patron']['expiration_date'] = '2022-12-31' | ||
patron_martigny.update(patron_martigny, dbcommit=True, reindex=True) | ||
|
||
blocked_message = patron_martigny['patron']['blocked_note'] | ||
|
||
# If the user is not identified, there is no user information | ||
res = client.get('/') | ||
soup = BeautifulSoup(res.data, 'html.parser') | ||
assert soup.find('div', {"class": "patron-info-message"}) is None | ||
|
||
login_user_via_view( | ||
client, | ||
email=patron_martigny_data['email'], | ||
password=patron_martigny_data['password']) | ||
|
||
# If the user is identified, we see the name of the organization | ||
# and the message on the global view | ||
res = client.get(url_for('rero_ils.index')) | ||
soup = BeautifulSoup(res.data, 'html.parser') | ||
li = soup.find('div', {"class": "patron-info-message"}).find('li') | ||
|
||
assert org_martigny_data['name'] == li.find('span').text | ||
assert f'Your account is currently blocked. Reason: {blocked_message}' \ | ||
== li.find('div', {"class": "message-blocked"}).text | ||
assert 'Your account has expired. Please contact your library.'\ | ||
== li.find('div', {"class": "message-expired"}).text | ||
|
||
# If the view of the organization, there is no name of it | ||
res = client.get(url_for( | ||
'rero_ils.index_with_view_code', viewcode=org_martigny_data['code'])) | ||
soup = BeautifulSoup(res.data, 'html.parser') | ||
div = soup.find('div', {"class": "patron-info-message"}) | ||
|
||
assert div.find('span') is None | ||
assert f'Your account is currently blocked. Reason: {blocked_message}' \ | ||
== div.find('div', {"class": "message-blocked"}).text | ||
assert 'Your account has expired. Please contact your library.'\ | ||
== div.find('div', {"class": "message-expired"}).text |