= Bug 482267 = In peparation for fixing bug 422466 which adds a lazr-js status picker to the translation import queue, the TranslationImportQueueEntry.setStatus needs to be made available through the API. The status attribute had been made read-only and the setStatus method had been introduced for this very purpose but setStatus was still lacking checks on the status value being set. This is were it gets tricky because the normal security policy enforces access restrictions on attributes and methods but not on the parameters to methods. These checks have to be added to the model code, parallelizing some of what is done by the security policy. == Proposed Fix == This branch adds an extra parameter to setStatus called "user" that references the user that is requesting the change. It also adds a canSetStatus method that encapsulates the necessary checks and is also callable from outside to be used by view code to prepare the status picker. Some of the code in canSetStatus is identical to code in security.py so these are exposed as seperate method isUbuntuAndIsUserTranslationGroupOwner and isUserUploaderOrOwner and called from security.py. Also, a new module permission_helpers.py was added to contain a function that is both used in security.py and the model code. It would be the subject of another branch to go through the code and find more places where this function can be used. == Implemention Notes == A lot of tests are affected by the new parameter to setStatus and fixing all the call sites of setStatus is the bulk of the changes in this branch. Tests and scripts are using "rosetta_experts" to be able to freely set statuses. In addition setStatus checks if an import target has been set before allowing anybody to set the status to "Approved". Some tests ignored this and had to be fixed. == Tests == Oh well, just run all the translation tests .. bin/test -vvct lp.translations == Demo/QA == Launchpadlib is your friend. queue = launchpad.translation_import_queue_entries entry = queue.getAllEntries(import_status="Imported")[0] print repr(entry) print entry.status entry.setStatus(new_status='Blocked') entry_link = entry.self_link print entry_link Try out with different credentials so see the results. = Launchpad lint = Checking for conflicts. and issues in doctests and templates. Running jslint, xmllint, pyflakes, and pylint. Using normal rules. Linting changed files: lib/canonical/launchpad/security.py lib/lp/translations/browser/hastranslationimports.py lib/lp/translations/browser/translationimportqueue.py lib/lp/translations/doc/poexport-language-pack.txt lib/lp/translations/doc/poimport-pofile-not-exported-from-rosetta.txt lib/lp/translations/doc/poimport-pofile-old-po-imported.txt lib/lp/translations/doc/poimport-pofile-syntax-error.txt lib/lp/translations/doc/poimport-potemplate-syntax-error.txt lib/lp/translations/doc/poimport.txt lib/lp/translations/doc/rosetta-karma.txt lib/lp/translations/doc/rosetta-poimport-script.txt lib/lp/translations/doc/translationimportqueue.txt lib/lp/translations/interfaces/translationimportqueue.py lib/lp/translations/model/pofile.py lib/lp/translations/model/potemplate.py lib/lp/translations/model/translationbranchapprover.py lib/lp/translations/model/translationimportqueue.py lib/lp/translations/scripts/po_import.py lib/lp/translations/stories/webservice/xx-translationimportqueue.txt lib/lp/translations/tests/test_autoapproval.py lib/lp/translations/tests/test_translationbranchapprover.py lib/lp/translations/tests/test_translationimportqueue.py lib/lp/translations/utilities/permission_helpers.py lib/lp/translations/utilities/tests/helpers.py lib/lp/translations/utilities/tests/test_xpi_import.py lib/lp/translations/utilities/tests/test_xpi_po_exporter.py == Pylint notices == lib/lp/translations/interfaces/translationimportqueue.py 10: [F0401] Unable to import 'lazr.enum' (No module named enum) 20: [F0401] Unable to import 'lazr.restful.interface' (No module named restful) 21: [F0401] Unable to import 'lazr.restful.fields' (No module named restful) 22: [F0401] Unable to import 'lazr.restful.declarations' (No module named restful)