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.

* Removes the "edit my profile" menu entry.
* Removes the "Change password" menu entry.
* Closes rero#2000.
* Closes rero#2195.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Feb 10, 2022
1 parent a9e3be9 commit fce99b2
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 58 deletions.
51 changes: 48 additions & 3 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 @@ -61,7 +61,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
12 changes: 7 additions & 5 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/create/', 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 Down Expand Up @@ -73,6 +73,8 @@ 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, tab='ill_request'))

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,7 +24,7 @@
{%- 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 %}
Expand Down
18 changes: 10 additions & 8 deletions rero_ils/modules/patrons/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,21 @@ 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:
return jsonify(data)

user = User.get_by_id(current_user.id).dumpsMetadata()
user['id'] = current_user.id
data = {**data, **user}
data['patrons'] = []

data = {**data, **user, 'patrons': []}
for patron in Patron.get_patrons_by_user(current_user):
organisation = patron.get_organisation()
# TODO: need to be fixed this causes errors in production only
Expand Down Expand Up @@ -168,9 +172,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 @@ -185,7 +187,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
Loading

0 comments on commit fce99b2

Please sign in to comment.