-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #604 from coopdevs/develop
v3.10.0
- Loading branch information
Showing
9 changed files
with
144 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,6 @@ | ||
// SASS variable overrides must be declared before loading up Active Admin's styles. | ||
// | ||
// To view the variables that Active Admin provides, take a look at | ||
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the | ||
// Active Admin source. | ||
// | ||
// For example, to change the sidebar width: | ||
// $sidebar-width: 242px; | ||
$primary-color: #165e6d; | ||
$link-color: $primary-color; | ||
$table-stripe-color: #f5f5f5; | ||
|
||
// Active Admin's got SASS! | ||
@import "active_admin/mixins"; | ||
@import "active_admin/base"; | ||
|
||
// Overriding any non-variable SASS must be done after the fact. | ||
// For example, to change the default status-tag color: | ||
// | ||
// .status_tag { background: #6090DB; } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Used in the Admin section to import users and members | ||
# to a specific organization, from a CSV file. | ||
|
||
require "csv" | ||
|
||
class UserImporter | ||
Row = Struct.new( | ||
:username, | ||
:member_id, | ||
:entry_date, | ||
:date_of_birth, | ||
:email, | ||
:phone, | ||
:alt_phone, | ||
:gender | ||
) do | ||
def user_from_row | ||
User.new( | ||
username: username, | ||
date_of_birth: date_of_birth, | ||
email: email, | ||
phone: phone, | ||
alt_phone: alt_phone, | ||
gender: gender | ||
) | ||
end | ||
end | ||
|
||
class << self | ||
def call(organization_id, csv_data) | ||
data = csv_data.read | ||
organization = Organization.find(organization_id) | ||
errors = [] | ||
|
||
CSV.parse(data, headers: false) do |data_row| | ||
row = Row.new( | ||
data_row[2..4].join(" "), | ||
data_row[0], | ||
data_row[1], | ||
data_row[6], | ||
data_row[9], | ||
data_row[7], | ||
data_row[8], | ||
User::GENDERS[data_row[5].to_i - 1] | ||
) | ||
process_row(row, organization, errors) | ||
end | ||
|
||
organization.ensure_reg_number_seq! | ||
errors | ||
end | ||
|
||
def process_row(row, organization, errors) | ||
user = row.user_from_row | ||
user.skip_confirmation! # auto-confirm, not sending confirmation email | ||
|
||
if user.save | ||
member_from_row(row, user, organization, errors) | ||
else | ||
errors.push(member_id: row.member_id, email: row.email, | ||
errors: user.errors.full_messages) | ||
end | ||
end | ||
|
||
def member_from_row(row, user, organization, errors) | ||
member = organization.members.create(member_uid: row.member_id, | ||
entry_date: row.entry_date, | ||
user_id: user.id) | ||
|
||
errors.push(member_id: row.member_id, email: row.email, | ||
errors: member.errors.full_messages | ||
) if member.errors.present? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.