diff --git a/CHANGELOG.md b/CHANGELOG.md index 543007354..e568b02ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Fix a bug: "about" page shows a non-functional menu icon - Fix a bug: responsiveness of the "about" page title − Fix a bug: unable to change the slots durations for a new availability +- Fix a bug: some invoices does not have the name of the user - Fix a security issue: updated underscore to 1.12.1 to fix [CVE-2021-23358](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23358) - Fix a security issue: updated lodash to 4.17.21 to fix [CVE-2021-23337](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23337) - Fix a security issue: updated url-parse to 1.5.1 to fix [CVE-2021-27515](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-27515) @@ -23,6 +24,7 @@ - Fix a security issue: updated codemirror to 5.58.2 to fix [CVE-2020-7760](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-7760) - Fix a security issue: updated rails to 5.2.6 to fix [CVE-2021-22904](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-22904) - Fix a security issue: updated react-i18next to 11.8.15 to fix [CVE-2021-23346](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23346) +- [TODO DEPLOY] `rails fablab:fix:invoices_without_names` ## v4.7.8 2021 April 02 - Updated mimemagic to 0.3.10 to fix [a build issue](https://github.com/mimemagicrb/mimemagic/issues/139) diff --git a/app/models/profile.rb b/app/models/profile.rb index e09cb8278..1c5d3c0ed 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -12,7 +12,7 @@ class Profile < ApplicationRecord validates :last_name, presence: true, length: { maximum: 30 } validates_numericality_of :phone, only_integer: true, allow_blank: false, if: -> { Setting.get('phone_required') } - after_commit :update_invoicing_profile, if: :invoicing_data_was_modified?, on: [:update] + after_commit :update_invoicing_profile, if: :invoicing_data_was_modified? def full_name # if first_name or last_name is nil, the empty string will be used as a temporary replacement diff --git a/app/models/user.rb b/app/models/user.rb index 01307ab03..671a82ced 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -438,7 +438,9 @@ class User < ApplicationRecord raise NoProfileError if invoicing_profile.nil? invoicing_profile.update_attributes( - email: email + email: email, + first_name: first_name, + last_name: last_name ) end end diff --git a/lib/tasks/fablab/fix.rake b/lib/tasks/fablab/fix.rake index 8b4918ea4..0356f7301 100644 --- a/lib/tasks/fablab/fix.rake +++ b/lib/tasks/fablab/fix.rake @@ -187,5 +187,13 @@ namespace :fablab do end end end + + desc '[release 4.7.9] fix invoicing profiles without names' + task invoices_without_names: :environment do + InvoicingProfile.where('(first_name IS NULL OR last_name IS NULL) AND user_id IS NOT NULL').each do |ip| + ip.update_attribute('first_name', ip.user.profile.first_name) + ip.update_attribute('last_name', ip.user.profile.last_name) + end + end end end