Skip to content

Feature/hidden problems#106

Open
XanderVertegaal wants to merge 10 commits into
developfrom
feature/hidden-problems
Open

Feature/hidden problems#106
XanderVertegaal wants to merge 10 commits into
developfrom
feature/hidden-problems

Conversation

@XanderVertegaal
Copy link
Copy Markdown
Contributor

Closes #56

This PR introduces a new field 'hidden' on Problems, and allows users belonging to the Master Annotator user group (and superusers) to hide certain problems, so only they can see them. 'Hidden' status is clearly indicated with an info banner at the top of the screen that also contains some explanation on what this status entails.

image

A filter on the left side of the screen (only visible to Master Annotators and superusers) allows you to filter problems according to their hidden status.

@XanderVertegaal XanderVertegaal added the enhancement New feature or request label May 14, 2026
Copy link
Copy Markdown
Contributor

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks well-designed and well-implemented to me. My one reservation is that when someone tries to access a problem they are not supposed to see, you return a different problem instead. That should be a 404 or 403, as far as I'm concerned.

I do think the UI is well designed and I like the thorough testing. 👍

Comment on lines +91 to +93
response = client.get(f"/api/problem/{hidden_problem.id}/")
assert response.status_code == status.HTTP_200_OK
assert response.data['problem']['id'] == sample_problem.id, "Unauthenticated users requesting a hidden problem should receive the first non-hidden problem instead."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this strange. Asking for a problem with a particular ID, which you're not allowed to see, and then getting another problem with a different ID instead. That will look like a bug to legitimate non-masters. Why not just return a 404?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning behind this is that this view is also used by users who change their filters in such a way that the problem they are currently viewing is excluded. It feels a bit heavy-handed to hit them with a 404, but I'm happy to be convinced otherwise.

Maybe we can return a 404 if there are no filters applied (since the user will then be looking for a specific problem, e.g. by manipulating the URL) anyway, and return the first available problem (as it is) otherwise?

A separate suggestion would be to show a small toast/pop-up message when a different problem is returned, so it is more obvious to the user that they have been 'redirected' to the first available problem, not the problem they requested.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The justification you're giving sounds like a list endpoint, where the query might return zero or more problems. In that case, if the list was filtered by a particular ID, I would expect it to return an empty list if the user cannot see the problem with that ID. Only if there was no ID-based filter criterion, would I expect that the user might get other results than the one they had in mind initially.

The test code I'm reading, on the other hand, seems to suggest that this is an endpoint that is supposed to return exactly one problem. If that is the case, the problem either exists or it doesn't (from the point of view of the user). In this case, where the user is not allowed to see the problem in question, there are two ways in which you can present this: "it exists but you're not allowed to see it" (403) or (I'm going to pretend) "it doesn't exist" (404).

Letting a user select one particular ID, like in this test, and then showing a problem with a different ID is never correct, as far as I'm concerned.

Perhaps the frontend is using this endpoint in a way that I'm not aware of? We can discuss this tomorrow or the day after if necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, you only added two lines, but for some reason, GitHub thinks that you replaced the entire file. Can you tell what is causing this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies, this is my editor "illegally" changing the line endings from LF to CRLF. I'll push a commit that fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hide/disregard problems

2 participants