Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

users: add new fields, move fields from the patron #1695

Conversation

jma
Copy link
Contributor

@jma jma commented Feb 11, 2021

Co-Authored-by: Johnny Mariéthoz [email protected]

Why are you opening this PR?

Dependencies

My PR depends on the following rero-ils-ui's PR(s):

How to test?

  • check several scenarios of online registration and then create a patron
  • create a patron directly
  • check existing username, email, etc.

Code review check list

  • Commit message template compliance.
  • Commit message without typos.
  • File names.
  • Functions names.
  • Functions docstrings.
  • Unnecessary commited files?
  • Cypress tests successful?

@jma jma force-pushed the maj-user-patron-add-new-fields branch 5 times, most recently from 5956da6 to 30ea20e Compare February 24, 2021 13:58
@jma jma force-pushed the maj-user-patron-add-new-fields branch from 30ea20e to c249e2b Compare February 24, 2021 14:19
@jma jma changed the title in progress user: add new fields Feb 24, 2021
@jma jma force-pushed the maj-user-patron-add-new-fields branch from c249e2b to b042219 Compare February 24, 2021 14:26
@jma jma marked this pull request as ready for review February 24, 2021 14:31
@jma jma force-pushed the maj-user-patron-add-new-fields branch 6 times, most recently from 98d13ee to 35ce713 Compare March 1, 2021 07:04
Copy link

@iGormilhit iGormilhit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message proposition:

users: add new fields, move fields from the patron

* Replaces the phone field by home, business, mobile, other phone fields
  in the user data model.
* Adds country and gender fields in the user data model.
* Adds 3 invenio-userprofiles configuration to specify the list of
  countries, the default country and the read only fields.
* Makes the barcode repetitive.
* Removes all user fields from the patron data model.
* Adds the second address, the local code, the source fields in the
  patron data model.

Comment on lines 60 to 61
"secound_address": {
"title": "Secound address",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"secound_address": {
"title": "Secound address",
"second_address": {
"title": "Second address",

@@ -6,10 +6,13 @@
"additionalProperties": false,
"propertiesOrder": [
"user_id",
"secound_address",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"secound_address",
"second_address",

@@ -6,10 +6,13 @@
"additionalProperties": false,
"propertiesOrder": [
"user_id",
"secound_address",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"secound_address",
"second_address",

Comment on lines 60 to 61
"secound_address": {
"title": "Secound address",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"secound_address": {
"title": "Secound address",
"second_address": {
"title": "Second address",

"country": {
"type": "text"
},
"secound_address": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"secound_address": {
"second_address": {

Comment on lines 136 to 137
"title": "business phone number",
"description": "business phone number with the international prefix, without spaces.",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"title": "business phone number",
"description": "business phone number with the international prefix, without spaces.",
"title": "Business phone number",
"description": "Business phone number with the international prefix, without spaces.",

@jma jma force-pushed the maj-US1889-patron-edit-personnal-data branch from 729a78f to ea9b133 Compare March 1, 2021 08:22
* Adds a new 'user' resource to manage the user profiles. It contains
  the user personal data as opposed to the patron data that are link to
  a specific organisation.
* Writes a REST API:
  * A GET, POST, PUT methods to create, update and retrieves the patron
    personal information.
  * A search endpoint to retrieve the patron personal information given
    an email or a username.
* Creates units testing.
* Centralizes several views and methods in a specific `User` python
  class.
* Disables the validation email for freshly created user.
* Uses the standard ngx-formly `widget` field for the user JSON schema.

Co-Authored-by: Aly Badr <[email protected]>
Co-Authored-by: Johnny Mariéthoz <[email protected]>
@jma jma force-pushed the maj-user-patron-add-new-fields branch 2 times, most recently from 1828eae to 4b77046 Compare March 1, 2021 08:31
@jma jma requested a review from iGormilhit March 1, 2021 08:38
@jma jma force-pushed the maj-user-patron-add-new-fields branch 2 times, most recently from 377ebb6 to fdf434b Compare March 1, 2021 09:40
@iGormilhit iGormilhit changed the title user: add new fields users: add new fields, move fields from the patron Mar 1, 2021
Copy link

@iGormilhit iGormilhit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit messages approved.

@jma jma force-pushed the maj-user-patron-add-new-fields branch 3 times, most recently from 3cc4c88 to 702696c Compare March 1, 2021 13:18
@jma jma requested a review from BadrAly March 1, 2021 13:28
@jma jma requested a review from lauren-d March 1, 2021 13:28
@benerken
Copy link
Contributor

benerken commented Mar 2, 2021

  • the patron account screen is "slim" : is it possible to use a larger part of the screen ?

  • The message doesn't change from " The loan history is not saved." even if I modified to keep the history.
    image

  • The status button of the ILL requests is not aligned correctly. Ex: https://ilsdev.test.rero.ch/global/patrons/profile?tab=ill_request

@pronguen pronguen self-requested a review March 2, 2021 11:03
Copy link
Contributor

@pronguen pronguen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • In the professional view
    • (!) I am not able to add a new user (personal data).
      image
    • When creating a new user, it is very difficult to find Switzerland in the list of countries. Ideally put Switzerland as default value (this should then be different for UCL). Also sort the list alphabetically (as in provisionActivity in the document editor), or put the few preferred values on top.
  • In the public view
    • In account/settings/profile/, some field labels should not have uppercase letter for the 2nd word (Postal Code, Birth Date)
    • In account/settings/profile/, if I update my profile, and then change the page language to English (for example), I land on /lang/?lang_code=en and receive a Page not found.
    • From RERO ILS homepage, when I click on "My account", it lasts long before displaying the account. A spinner would be great.
    • Some responsive problems: in the ILL requests tab
      image
    • Some responsive problems: in the fees tab
      image

@jma
Copy link
Contributor Author

jma commented Mar 3, 2021

  • In the public view

    • In account/settings/profile/, if I update my profile, and then change the page language to English (for example), I land on /lang/?lang_code=en and receive a Page not found.

This is an Invenio bug, present also on SONAR. An issue has been open: inveniosoftware/invenio-userprofiles#119

All of the following problem will be done in an other US (patron profile using Angular):

  • From RERO ILS homepage, when I click on "My account", it lasts long before displaying the account. A spinner would be great.
  • Some responsive problems: in the ILL requests tab
    image
  • Some responsive problems: in the fees tab
    image
  • [] The status button of the ILL requests is not aligned correctly. Ex: https://ilsdev.test.rero.ch/global/patrons/profile?tab=ill_request

@@ -331,7 +331,7 @@ def get_patrons_barcodes():
barcodes = []
for uuid in patrons_ids:
patron = Patron.get_record_by_id(uuid)
barcode = patron.patron.get('barcode')
patron_barcodes = patron.patron.get('barcode')
if barcode:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if patron_barcodes ?

@@ -394,8 +394,8 @@ def get_random_patron(exclude_this_barcode):
.filter('term', organisation__pid=org_pid)\
.source(['patron']).scan()
for patron in patrons:
if patron.patron.barcode != exclude_this_barcode:
return Patron.get_patron_by_barcode(barcode=patron.patron.barcode)
if patron.patron.barcode[0] != exclude_this_barcode:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since a patron can have multiple barcodes, this check is not valid anymore. Need to check that the exclude_this_barcode is not in the list patron.patron.barcode

@@ -122,6 +122,7 @@ def import_users(infile, append, verbose, password, lazy, dont_stop_on_error,
patron.reindex()
pids.append(patron.pid)
except Exception as err:
raise(err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to comment this line?

@@ -303,7 +314,7 @@ def generate_item_barcode(data=None):
data['barcode'] = 'f-{}'.format(
datetime.now().strftime('%Y%m%d%I%M%S%f'))
if data.get('patron') and not data.get('patron', {}).get('barcode'):
data['patron']['barcode'] = 'f-{}'.format(
data['patron']['barcode'][0] = 'f-{}'.format(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data['patron']['barcode'] = ['f-{}'.format(
datetime.now().strftime('%Y%m%d%I%M%S%f'))]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. But as the barcode is required for a patron, this case should never happens! Can I remove this?

@jma jma force-pushed the maj-user-patron-add-new-fields branch from 702696c to a9f6dc7 Compare March 3, 2021 07:03
@jma jma requested a review from BadrAly March 3, 2021 07:04
@@ -21,6 +21,6 @@
<i class="fa fa-user fa-5x"></i>
</div>
<hgroup class="col-sm-10 col-lg-11 align-self-center">
<h1 class="mb-0">{{ record.first_name }} {{ record.last_name }}</h1>
<h1 class="mb-0">{{ record.dumps().first_name }} {{ record.dumps().last_name }}</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is better to store result of dumps into a local variable because dumps() do a call to database (see patrons.api.dumps())
Maybe that could be done in the parent template (patron_profile.html) or as argument when calling the template

<div class="row pl-2 pr-2">
<div class="col-lg-3 font-weight-bold">
{{_('Keep history')}}:
</a>
</div>
<div class="col-lg-9">
<i class="fa fa-circle mr- text-{{ 'success' if record.patron.keep_history else 'danger' }}"></i>
{% if record.patron.keep_history %}
{% if record.dumps().keep_history %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same before

@@ -59,7 +59,7 @@
<span class="badge badge-danger font-weight-normal">{{ fees.open.total_amount | format_currency(fees.open.currency) }}</span>
</a>
</li>
{% if record.patron.keep_history %}
{% if record.dumps().keep_history %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same before


res, _ = postdata(
client,
post_entrypoint,
data
)
print(res.json)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be removed

* Replaces the phone field by home, business, mobile, other phone fields
  in the user data model.
* Adds country and gender fields in the user data model.
* Adds 3 invenio-userprofiles configuration to specify the list of
  countries, the default country and the read only fields.
* Makes the barcode repetitive.
* Removes all user fields from the patron data model.
* Adds the second address, the local code, the source fields in the
  patron data model.
* Closes rero#1724, rero#1634, rero#1615, rero#1490, rero#1467, rero#1318, rero#1384, rero#1670.

Co-Authored-by: Johnny Mariéthoz <[email protected]>
@jma jma force-pushed the maj-user-patron-add-new-fields branch from a9f6dc7 to fb8f162 Compare March 3, 2021 08:20
@jma jma merged commit dd8ef3f into rero:maj-US1889-patron-edit-personnal-data Mar 3, 2021
@jma jma deleted the maj-user-patron-add-new-fields branch January 13, 2022 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants