coralnet icon indicating copy to clipboard operation
coralnet copied to clipboard

Labelset-import code cleanup

Open StephenChan opened this issue 8 years ago • 0 comments

I'm not a big fan of writing code, immediately saying it needs re-organization, and then putting off that re-organization until later... but well, that's exactly what I'm doing here. I'm just not feeling sharp enough to pull off the refactor right now and I think I need to move on.

For future reference, the latest commit at this point is: cbbd589086bd50e96164c8854d9a8b4edca61bc8

Basically: I initially wrote labelset import in the labels app before realizing it was a lot like the code of the other upload/import views, which are in the upload app. But when I tried moving labelset import to the upload app, I realized that the upload app would have to import a good chunk of things from the labels app, and in general would have a chunk of labels specific logic. So now I'm not sure where the view goes best, or if the form and utility functions should be split up between the two apps somehow.

Another thing that looks silly is that I wrote labelset export in the export app, which is totally inconsistent with how labelset import is in labels now. I guess export is way simpler than upload/import, so it just looks clean wherever you put it. It seemed to fit best with the other export views right now, as I didn't have to import a bunch of things from the labels app.

Also, the different upload/import views should share more code. With the csv_to_dict function I wrote in labels/forms.py, I think I'm well on my way to doing that, but I'm not sure if it makes more sense to do this refactor before or after deciding where labelset import should live.

Finally, I guess "labelset import" could be renamed "labelset upload", at least internally to be consistent with the other pages that work very similarly. Though the wording might sound a bit odd on the user side, so I'm not totally sure.

I'm marking this as Beta 2 because I don't think these views need major functionality changes before the Beta release.

StephenChan avatar Oct 10 '16 02:10 StephenChan