-
Bug
-
Resolution: Unresolved
-
Normal
-
None
-
None
Found when I was looking into CB-367 (#319).
In the review edit template, we set the title of the page depending on the type of item being reviewed: https://github.com/metabrainz/critiquebrainz/blob/ab644df250ebe848953dd1fa6959bb5f64086415/critiquebrainz/frontend/templates/review/modify/edit.html#L3-L10
This check is incomplete, and is different to the way that we do it in the "write review" endpoint: https://github.com/metabrainz/critiquebrainz/blob/901a6cc4f29eb587f4e65d7506d31f33d3df8a28/critiquebrainz/frontend/views/review.py#L283-L287
Additionally, there is also a bug when calling render_template for release_groups, both in the write and edit endpoints: https://github.com/metabrainz/critiquebrainz/blob/901a6cc4f29eb587f4e65d7506d31f33d3df8a28/critiquebrainz/frontend/views/review.py#L280
Here, the reference to entity is actually the view used to show an entity page, and not an object that refers to the entity loaded from the database. In order to simplify the write and edit views we should have only a single call to render_template, and use a dictionary and **kwargs to fill in context argument.
We should make the following changes:
- Load the entity from the database for both write and edit endpoints in the view and pass it to the template as a context variable
- Use a common method to extract entity name in the views, and pass it to the template as a context variable
- Use a dictionary to store template context variables, and pass it to render_template, avoiding the need to have 2 calls for release_group and others
- In the create method, don't perform the check in two different places that results in the error message "Please provide some text or a rating for this review"