Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide all information_system attributes from es search views #415

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

nicobav
Copy link
Contributor

@nicobav nicobav commented Dec 17, 2024

Previously we restricted the information system from basic drf filters and views for unauthenticated users. This adds hiding the InformationSystem attribues from unauthenticated users in elastic backed searches and views as well.

Refs TIED-171

@nicobav nicobav requested a review from a team December 17, 2024 20:29
@terovirtanen
Copy link
Contributor

TIEDONOHJAUS-API branch is deployed to platta: https://tiedonohjaus-pr415.api.dev.hel.ninja 🚀🚀🚀

@nicobav nicobav force-pushed the TIED-171/all-information-system-es branch from 78d9b94 to c6ca3cc Compare December 18, 2024 06:36
@terovirtanen
Copy link
Contributor

TIEDONOHJAUS-API branch is deployed to platta: https://tiedonohjaus-pr415.api.dev.hel.ninja 🚀🚀🚀

@property
def is_authenticated(self):
request = self.context.get("request")
return request and request.user.is_authenticated
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO

Suggested change
return request and request.user.is_authenticated
return bool(request and request.user.is_authenticated)

would be a bit better because the name suggests the property will be a boolean, and the original version can return also something else, at least None.

@nicobav nicobav force-pushed the TIED-171/all-information-system-es branch from c6ca3cc to f51bd26 Compare December 18, 2024 07:55
@terovirtanen
Copy link
Contributor

TIEDONOHJAUS-API branch is deployed to platta: https://tiedonohjaus-pr415.api.dev.hel.ninja 🚀🚀🚀

@nicobav nicobav requested a review from tuomas777 December 18, 2024 08:45
@nicobav nicobav force-pushed the TIED-171/all-information-system-es branch from f51bd26 to 2885ae3 Compare December 18, 2024 13:37
@terovirtanen
Copy link
Contributor

TIEDONOHJAUS-API branch is deployed to platta: https://tiedonohjaus-pr415.api.dev.hel.ninja 🚀🚀🚀

@nicobav nicobav force-pushed the TIED-171/all-information-system-es branch 2 times, most recently from 8f471c9 to fa42c47 Compare December 18, 2024 14:10
@terovirtanen
Copy link
Contributor

TIEDONOHJAUS-API branch is deployed to platta: https://tiedonohjaus-pr415.api.dev.hel.ninja 🚀🚀🚀


return super().filter_queryset(queryset)
super().initial(request, *args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this method should return the value of the super call or not, but it shouldn't do both of those. Now it does that for authenticated users and doesn't do it for unauthenticated users, which seems odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, its a mistake. The initial method is not expected to return anything - I'll change this a bit

Previously we restricted the information system from basic filters and
views for unauthenticated users.
This adds hiding the InformationSystem attribues from unauthenticated
users in elastic backed searches as well.

Refs TIED-171
@nicobav nicobav force-pushed the TIED-171/all-information-system-es branch from fa42c47 to 0d9768a Compare December 18, 2024 18:39
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 65%)

See analysis details on SonarQube Cloud

@terovirtanen
Copy link
Contributor

TIEDONOHJAUS-API branch is deployed to platta: https://tiedonohjaus-pr415.api.dev.hel.ninja 🚀🚀🚀

@nicobav nicobav requested a review from tuomas777 December 19, 2024 06:14
Copy link
Contributor

@tuomas777 tuomas777 left a comment

Choose a reason for hiding this comment

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

LGTM 👍 🐎

@nicobav nicobav merged commit 5035c8f into main Dec 20, 2024
25 checks passed
@nicobav nicobav deleted the TIED-171/all-information-system-es branch December 20, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants