Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1117] Refactor and add docstring to user_name_validator
- Add docstring - Use model.User.get() to find whether a user exists, instead of a lot of SQLAlchemy in ckan.logic. This should make it easier to unit test user_name_validator() in isolation, because the tests will only have to mock one method ckan.model.User.get() instead of having to mock several things. Also SQLAlchemy should just be in the model anyway, not in the logic. - Refactor and add code comments to clarify the obscure thing that user_name_validator() does with context['user_obj'] on user_update()s. This was completely obscure before, now hopefully it's clearer. (But it's a bad design anyway, user_create and user_update shouldn't be sharing the same user_name_validator function.) I don't *think* I broke anything by refactoring this (tests are still passing).
- Loading branch information