API V2: test that command is actually saved (#9827)
* API V2: test that command is actually saved
* Build details page: normalize/trim command paths (second attempt) (#9831)
Continuation of the work done in
https://github.com/readthedocs/readthedocs.org/pull/9815 that didn't work as we
expected.
We weren't saving the commands properly when hitting the API since
`serializers.SerializerMethodField` is a read-only field. This commit fixes this
problem by using a different Serializer depending if it's a GET request or not,
and if it's made by an Admin or not.
It overrides the method `BuildViewSet.get_serializer_class` to manage these
different cases and return the proper serializer.
Done on top of https://github.com/readthedocs/readthedocs.org/pull/9827 to be sure the
tests for saving commands are passing.
* Feedback from review addressed
- rename serializer to mention "ReadOnly" on it's class name
- add docstrings to these serializers
* Typo when accessing the action
* Optional builder hash on local instance
Old builds don't have the builder hash in the docroot, since that was implmented
recently.
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
Co-authored-by: Benjamin Balder Bach <benjamin@readthedocs.org>