opensafely-core / airlock

A tool to review & release outputs from an OpenSAFELY backend
Other
2 stars 0 forks source link

Template refactoring part 2 plus bonus permissions updates #650

Closed rebkwok closed 2 months ago

rebkwok commented 2 months ago

The main aim of this PR was to move the logic about which buttons to show at the top of the request content (and whether to enable/disable them, show tooltips etc) out of the template and into the views.

We now build a content_buttons dict for each type of content that needs to display buttons (request, file, dir) and the template just needs to use that to determine whether to show buttons.

However, I also refactored the logic to make use of the permissions in permissions.py, and in doing so came across the odd permission that was only enforced at the view/template level, and the odd one that was missing - the main ones being:

rebkwok commented 2 months ago

This PR is mostly reviewable commit-by-commit, I think, but the last one is to split up the get_button_context function which had grown more than I liked, and it was just too fiddly to go back and rewrite it into the earlier commits.

There's a part 3 to this, to do similar refactoring to the workspace and code views/templates, but those should be less complicated.