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

[v3.4] 494 import equipment #897

Merged
merged 34 commits into from
Aug 4, 2014
Merged

[v3.4] 494 import equipment #897

merged 34 commits into from
Aug 4, 2014

Conversation

orenyk
Copy link
Contributor

@orenyk orenyk commented Aug 4, 2014

resolves #494 as requested by CSSI; this will need to be merged into master as well. I'm going to clean up the branch and remove the testing since it was barely set up; the import was working fine so in the interest of getting the feature implemented I think we should skip testing for now. Additionally, we probably want to refactor all of the import code at some point as well. I'll also verify that all of the changes to the category, equipment model, and equipment object models have been taken into account.

Added :sort_order as an import parameter for categories; updated the relevant views (import and imported) as well as the import library and validation function.
added spec file for the CsvImport module and got working tests for the various module methods of EquipmentImport. Also added pending tests for functionality of both modules.
@orenyk orenyk mentioned this pull request Aug 4, 2014
@orenyk
Copy link
Contributor Author

orenyk commented Aug 4, 2014

Ok, I believe that this is ready to go. It should allow for the importing of categories, equipment models, and equipment objects using appropriately formatted CSVs, with selective overwriting of the first two. The instructions on the import page are modelled after the user import page; this is due for an overwrite (see #520) but should suffice for now. As long as this is behaving as expected and is restricted to admin users, I think we can pull it in.

@@ -26,6 +26,9 @@
get '/import_users/import' => 'import_users#import_page', :as => :csv_import_page
post '/import_users/imported' => 'import_users#import', :as => :csv_imported

get '/import_equipment/import' => 'import_equipment#import_page', :as => :equip_import_page
post '/import_equipment/imported' => 'import_equipment#import', :as => :equip_imported
Copy link
Contributor

Choose a reason for hiding this comment

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

huh. I used a really questionable and slightly confusing naming convention when writing the import users routes two years ago. You adapted the structure to import equipment (import/import_page and imported/import), which is fine so long as we're consistent, but now I'm having second thoughts that what I wrote was really the best.

the imported route does the actual import_ing_, but it does render the successful-import/"imported" page at the end, so, I guess there was a logic.. :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this was very confusing when I was originally looking at it but I was basically copying the import users functionality so I stuck with it :-P.

@dgoerger
Copy link
Contributor

dgoerger commented Aug 4, 2014

This code looks right; I haven't started up a VM though to test. I'll try to remember to run tests on this tonight after work...

I think ideally when implementing this for v4, we should try to abstract this to a generalized Import controller, and then shunt data to specialized or general methods in the model, and make sure we have thorough specs. :)

@dgoerger
Copy link
Contributor

dgoerger commented Aug 4, 2014

This all works on the supplied data sets (in the example documentation), and correctly indicates why import fails e.g. if you try to import a model belonging to a category which doesn't exist in the db.

It was really clever processing the cats first, and then the models, and finally the objects/items, as this makes it possible to import all three at the same time with no prior dependency on preexisting categories, etc. I like it!

Ideally this should have specs, but it's almost a verbatim copy from the Import Users files (I noticed the exclamation marks and nomenclature are the same :P), and for v4 I think these should be abstracted to generalized methods as much as possible, so maybe we can wait on these specs in order to get this backported ASAP before the start of the school year.

@dgoerger
Copy link
Contributor

dgoerger commented Aug 4, 2014

ability.rb correctly limits this to admins, going in for the merge...

dgoerger added a commit that referenced this pull request Aug 4, 2014
@dgoerger dgoerger merged commit 6520271 into release-v3.4 Aug 4, 2014
dgoerger added a commit that referenced this pull request Aug 5, 2014
@orenyk orenyk deleted the 494_import_equipment branch October 27, 2014 15:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants