Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

Commit a3aee36

Browse files
committed
Allow for bulk user role updates with only usernames
Resolves #1748 Allows admins to upload a user import CSV file with only the usernames populated in order to change their roles in bulk (e.g. to ban them). Previously this would only work if the CSV file contained all required user attributes.
1 parent e0f84b4 commit a3aee36

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
* This file will be updated whenever a new release is put into production.
33
* Any problems should be reported via the "report an issue" link in the footer of the application.
44

5-
## Unreleased - 2018-08-03
5+
## v6.3.4 - 2018-08-03
6+
### Changed
7+
* Allowed for bulk-updating of user roles with a csv import with just usernames ([#1748](https://github.com/YaleSTC/reservations/issues/1748)).
8+
69
### Fixed
710
* Fixed broken renewals when reservations were the maximum checkout length ([#1734](https://github.com/YaleSTC/reservations/issues/1734)).
8-
* Fix issue with the manage reservation button for approved requests ([1747](https://github.com/YaleSTC/reservations/issues/1747))
9-
* Fix unauthorized display of procedures and equipment items ([1749](https://github.com/YaleSTC/reservations/issues/1749))
11+
* Fixed issue with the manage reservation button for approved requests ([1747](https://github.com/YaleSTC/reservations/issues/1747))
12+
* Fixed unauthorized display of procedures and equipment items ([1749](https://github.com/YaleSTC/reservations/issues/1749))
1013

1114
## v6.3.3 - 2018-07-20
1215
### Fixed

lib/csv_import.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ def attempt_save_with_csv_data?(user_data)
9393
end
9494

9595
user = set_or_create_user_for_import(user_data)
96+
# Remove nil values to avoid failing validations - we this allows us to
97+
# update role of a bunch of users by passing in only their usernames
98+
# (instead of all of their user data).
99+
data_to_update = user_data.keep_if { |_, v| v.present? }
100+
user.update_attributes(data_to_update)
96101

97-
user.update_attributes(user_data)
98102
# if the updated or new user is valid, save to database and add to array
99103
# of successful imports
100104
return false unless user.valid?

0 commit comments

Comments
 (0)