Skip to content

Commit

Permalink
interface: keep the viewcode in the urls
Browse files Browse the repository at this point in the history
The change of the user's data as well as the change of
the password has been transferred to the Angular user profile.

* Adds functionality for editing user data in angular.
* Adds functionality to change user password in angular.
* Closes rero#2000.
* Closes rero#2101.
* Closes rero#2195.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Feb 28, 2022
1 parent 34b5abe commit 10cffb4
Show file tree
Hide file tree
Showing 16 changed files with 315 additions and 35 deletions.
43 changes: 41 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ redisbeat = "*"
jsonpickle = ">=1.4.1"
ciso8601 = "*"
# TODO: to be removed when the thumbnail will be refactored
invenio-userprofiles = {git = "https://github.com/rero/invenio-userprofiles.git", rev = "v1.2.1-rero1.0"}
invenio-userprofiles = {git = "https://github.com/rero/invenio-userprofiles.git", rev = "41d2b471cde1a93f660ba7bf0037ee3fb80b65fc"}

## Additionnal constraints on python modules
flask-wiki = {git = "https://github.com/rero/flask-wiki.git", tag = "v0.0.1"}
Expand Down
12 changes: 12 additions & 0 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ def _(x):
#: proxies) removes these headers again before sending the response to the
#: client. Set to False, in case of doubt.
ACCOUNTS_USERINFO_HEADERS = False

#: User profile
RERO_PUBLIC_USERPROFILES_READONLY = False
RERO_PUBLIC_USERPROFILES_READONLY_FIELDS = [
'first_name',
'last_name',
'birth_date'
]

#: USER PROFILES
USERPROFILES_READ_ONLY = False;

# Disable User Profiles
USERPROFILES = True
USERPROFILES_COUNTRIES = get_profile_countries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h4 class="alert-heading">{{ _('Caution!') }}</h4>
<p class="mb-0">{{ _('A well detailed request is more likely to be satisfied') }}</p>
</div>

<form id="ill-public-form" action="{{ url_for('ill_requests.ill_request_form') }}" method="POST" class="form" role="form" novalidate>
<form id="ill-public-form" action="{{ url_for('ill_requests.ill_request_form', viewcode=viewcode) }}" method="POST" class="form" role="form" novalidate>
{{ form.hidden_tag() }}
{%- if form.csrf_token and form.csrf_token.errors %}
<div class="alert alert-danger" role="alert">
Expand Down
13 changes: 7 additions & 6 deletions rero_ils/modules/ill_requests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
blueprint = Blueprint(
'ill_requests',
__name__,
url_prefix='/ill_requests',
url_prefix='/<string:viewcode>',
template_folder='templates',
static_folder='static',
)


@blueprint.route('/create/', methods=['GET', 'POST'])
@blueprint.route('/ill_requests/new', methods=['GET', 'POST'])
@check_user_is_authenticated(redirect_to='security.login')
@check_logged_as_patron
def ill_request_form():
def ill_request_form(viewcode):
"""Return professional view."""
form = ILLRequestForm(request.form)
# pickup locations selection are based on app context then the choices
Expand All @@ -58,7 +58,7 @@ def ill_request_form():
ill_request_data['pickup_location'])

# get the patron account of the same org of the location pid
def get_patron(location_pid):
def get_patron(loc_pid):
loc = Location.get_record_by_pid(loc_pid)
for ptrn in current_patrons:
if ptrn.organisation_pid == loc.organisation_pid:
Expand All @@ -73,6 +73,7 @@ def get_patron(location_pid):
_('The request has been transmitted to your library.'),
'success'
)
return redirect(url_for('patrons.profile', tab='ill_request'))
return redirect(url_for('patrons.profile', viewcode=viewcode))

return render_template('rero_ils/ill_request_form.html', form=form)
return render_template('rero_ils/ill_request_form.html',
form=form, viewcode=viewcode)
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
{%- endblock css %}

{%- block body %}
<public-patron-profile language="{{ current_i18n.locale.language[:2] }}"></public-patron-profile>
<public-patron-profile language="{{ current_i18n.locale.language[:2] }}" viewcode="{{ viewcode }}"></public-patron-profile>
{%- endblock body %}

{%- block javascript %}
{{ super() }}
{{ node_assets('@rero/rero-ils-ui/dist/public-patron-profile', tags='defer') }}
{{ webpack['reroils_public.js']}}
{{ node_assets('@rero/rero-ils-ui/dist/public-patron-profile', patterns=['polyfills-es5*.js','main-es5*.js'], tags='nomodule defer') }}
{{ node_assets('@rero/rero-ils-ui/dist/public-patron-profile', patterns=['polyfills-es2015*.js','main-es2015*.js'], tags='type="module"') }}
{%- endblock javascript %}
14 changes: 9 additions & 5 deletions rero_ils/modules/patrons/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ def logged_user():
),
'librarianRoles': current_app.config.get(
'RERO_ILS_LIBRARIAN_ROLES', []
)
),
'userProfile': {
'readOnly': current_app.config.get(
'RERO_PUBLIC_USERPROFILES_READONLY', False),
'readOnlyFields': current_app.config.get(
'RERO_PUBLIC_USERPROFILES_READONLY_FIELDS', []),
}
}
}
if not current_user.is_authenticated:
Expand Down Expand Up @@ -169,9 +175,7 @@ def logged_user():
return jsonify(data)


@blueprint.route('/global/patrons/profile', defaults={'viewcode': 'global'},
methods=['GET', 'POST'])
@blueprint.route('/<string:viewcode>/patrons/profile')
@blueprint.route('/<string:viewcode>/patrons/profile', methods=['GET', 'POST'])
@check_logged_as_patron
@register_menu(
blueprint,
Expand All @@ -186,7 +190,7 @@ def logged_user():
)
def profile(viewcode):
"""Patron Profile Page."""
return render_template('rero_ils/patron_profile.html')
return render_template('rero_ils/patron_profile.html', viewcode=viewcode)


@blueprint.app_template_filter('format_currency')
Expand Down
5 changes: 5 additions & 0 deletions rero_ils/modules/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def __init__(self, user):
"""User class initializer."""
self.user = user

@property
def id(self):
"""Get user id."""
return self.user.id

@classmethod
def create(cls, data, **kwargs):
"""User record creation.
Expand Down
30 changes: 30 additions & 0 deletions rero_ils/modules/users/templates/rero_ils/user_password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2022 RERO

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/>.

#}
{% extends 'rero_ils/page.html' %}

{%- block body %}
<h1 class="mt-2">{{ _('Change password') }}</h1>
<public-user-password-change referer="{{ request.referrer }}"></public-user-password-change>
{%- endblock body %}

{%- block javascript %}
{{ webpack['reroils_public.js']}}
{{ node_assets('@rero/rero-ils-ui/dist/public-user-password-change', patterns=['polyfills-es5*.js','main-es5*.js'], tags='nomodule defer') }}
{{ node_assets('@rero/rero-ils-ui/dist/public-user-password-change', patterns=['polyfills-es2015*.js','main-es2015*.js'], tags='type="module"') }}
{%- endblock javascript %}
Loading

0 comments on commit 10cffb4

Please sign in to comment.