0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 09:14:46 +01:00
Commit Graph

15 Commits

Author SHA1 Message Date
Ben White
450501ad14
feat: Enforce usage of parent functions for main viewset (#21730) 2024-04-29 11:45:16 +02:00
Ben White
4dd3c35933
feat: Personal API key scopes (#20151) 2024-02-20 11:02:58 +00:00
Ben White
aff0d6349e
feat: Simplify standard permissions (#20172) 2024-02-12 13:55:21 +00:00
Michael Matloka
e455481364
docs: Show the project membership endpoint (#18303) 2023-11-02 18:14:23 +01:00
Ellie Huxtable
0257b2bcb9
chore: Use ruff formatter (#18207)
* Use ruff formatter

Ruff is now also a formatter! And it runs in a fraction of a second
across our whole codebase vs "I waited more than 30s and cancelled it
because I got bored".

* Config and command -> ruff

* Run 'ruff format .'

* Update query snapshots

* Run 'ruff format .'

* Fix format after commit hook

* Update query snapshots

* Fix type error - ignore comment moved

* Exclude hogql grammar from formatting and reverted grammar

* Run format

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tom Owers <tom@paace.co>
2023-10-31 13:41:57 +00:00
Tom Owers
5513be7731
chore: upgraded Ruff linter (#18188)
* Upgraded Ruff linter

* Formatted whole codebase with new ruff rules

* Revert import removal

* Fixed mypi issues or added ignores

* Fixed schema formatting

* Fixed hogvm failing tests

* Remove duplicate key in list
2023-10-26 12:38:15 +02:00
Michael Matloka
3e9fd2e49e
refactor(api): Include team and organization in serializer context (#15294)
* refactor(api): Include `team` and `organization` in serializer context

* Optimize team/organization access

* Update query snapshots

* Update query snapshots

* Update query snapshots

* Update posthog/api/routing.py

Co-authored-by: Thomas Obermüller <thomas.obermueller@gmail.com>

* Rename `access_team/organization` to `get_*`

* Update query snapshots

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Thomas Obermüller <thomas.obermueller@gmail.com>
2023-05-01 18:55:24 +02:00
Karl-Aksel Puulmann
4db2af5d7f
fix(query-performance): Speed up permissioning in API (#13952)
* Get #team_effective_membership_level under test

* Extract method into class

* Refactor team_effective_membership_level to require less lookups

* Test and scaffolding for dashboard methods

* Move dashboard methods to user_permissions

* Optimize dashboard methods

* Insights priviledge logic to user_permissions

* Make insight priviledge code efficient

* Fix bug to improve efficiency

* Refactor efficiency tests

* Use UserPermissions in some dashboard-related views

* Use UserPermissions in some insight-related views

* Fix a typo

* Remove insight, dashboard model methods

* Experiment: make shared dashboards not have effective_priviledge_levels/effective_restriction_level

* Remove team#get_effective_membership_level

* Simplify TeamBaseSerializer

* Update organization API

* Update UserViewSet

* update team view

* Reduce some lookups

* Make UserPermissions not dependant on organization being passed

* cast-to-user

* Test listing with basic as FE calls it

* Update dashboard views

* JOIN organizations table, dont rely on request.user.organization

* Update snapshots

* Handle shared dashboards slightly better

* Simplify team API

* Fix test_team.py

* Update middleware tests

* Update ee team tests

* Fully refactor a problematic call pattern

* Solve ee API errors

* Solve lint fails

* Reset in insights as well

* Cast

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Update snapshots

* Remove merge conflict

* Update snapshots

* Remove items

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-01-30 11:44:16 +02:00
Michael Matloka
5d2ad6c7bb
chore(deps): Update black to 22.8.0 (#11596)
* chore(deps): Update `black` to `22.8.0`

* Format
2022-09-05 14:38:54 +02:00
Michael Matloka
d7067544ad
Fix is_active being unused when querying User (#8793)
* Fix `is_active` being unused when querying `User`

* Simplify a `.filter()`

* Update test_feature_flag.ambr

* Remove `User.is_active` filter from `get_overridden_feature_flags`

* Fix exclude in `OrganizationMemberViewSet` queryset

* Revert snapshot update

* Update test_organization_members.py
2022-03-02 14:27:08 +00:00
Michael Matloka
3a678e7261
Dashboard privilege API and collaborators UI (#8424)
* Add basic `/api/projects/:id/dashboard/:id/collaborators`

* Handle more collaboration cases and add base tests

* Add some collaborators UI to share modal

* Improve Python typing

* Improve TS typing

* Allow addition and deletion of collaborators from UI

* Add upsell prototype

* Improve upsell button

* Add `effective_restriction_level` to `DashboardSerializer`

* Improve `LemonSelect` value handling

* Improve `LemonSelect` behavior when selecting existing value

* Refactor the way privilege level name is determined

* Don't destroy `ShareModal` on close to avoid logic remounting

* Split out upsell into own PR

* Fix TS

* Fix typing

* Increase security with more tests

* Inline `parents_query_dict`

* Dashboard collaborator bubbles (#8450)

* Add collaborator bubbles to restricted dashboard headers

* Rename `index.tsx` to `ProfilePicture.tsx` for readability

* Improve tooltip handling

* Create ProfileBubbles.stories.tsx

* Make collaborator bubbles tooltip dashboard-level

* Always show collaborator bubbles

* Dashboard restrictions (#8462)

* Add frontend-side restrictions editing restrictions to dashboards

* Restrict `InsightCard`

* Align info message margin

* Disallow locking yourself out of the dashboard

* Handle dashboard restrictions in the insight page

* Allow disabling `InsightsTable` series checkbox

* Fix minor issues

* Align .page-title-row height

* Fix typing

* Fix arg name

* Address review feedback

* Fix n+1 queries issue
2022-02-08 16:22:09 +00:00
Tim Glaser
f47b1308b5
[Proposal] Add automatic swagger doc generation (#8148)
* Add automatic swagger doc generation

* Fix test and mypy

* formatting

* fix formatting

* formatting

* update

* fix mypy
2022-01-24 17:21:56 +00:00
Michael Matloka
3a67367ac7
Project-based permissioning TopNavigation (#6027)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type

* Add "Per-project access" feature flag, premium feature, and organization switch

* Rename `OrganizationMembershipLevel` to `OrganizationAccessLevel`

* Create `ExplicitTeamMembership` model

* Show whether projects are restricted in the project switcher

* Update organizations API code

* Fix migrations

* Move organization tests that require EE to `ee`

* Revert `OrganizationMembershipLevel` rename

* Fix organization tests

* Update migration

* Fix schema and add Members to Project Settings

* Build out test memberships API with security tests

* Update `TeamMembers` and `teamMembersLogic`

* Move "Per-project access" description to tooltip

* Add moar tests

* Fix Project Members list logic

* Add additional membership checks

* Update migrations

* Fix typing

* Adjust explicit team memberships API similarly

* Fix typo

* Unify `ExplicitTeamMemberSerializer`

* Remove old changes to `membersLogic` usage

* Use `effective_membership_level` on `TeamBasicSerializer`

* Clean up organization update tests

* Explicitly disallow enabling per-project access for free

* Fix circular import

* Remove `id` from `UserSerializer`

* Fix typing

* Try to fix import

* Fix fatal typing

* Add more tests

* Update permissioning.ts

* Add clarifying comment to migration

* Fix import

* Revert `TopNavigation` changes

* Restore `TopNavigation` changes

This reverts commit 05fd9e4ed6.

* Try to add a story for `TopNavigation`

* minor clarifications

* Revert `TopNavigation` changes

* Restore `TopNavigation` changes

* Make new access control entirely project-based

* Update migrations

* Add `project_based_permissioning` to `TeamBasicSerializer`

* Update test_team.py

* Fix `isRestricted` in `ProjectRow`

* Disable project creation for non-admins

* Make project icon in top nav itself dynamic as well

* Fix story

* Delete 0169_project_based_permissioning.py

* Apply suggestions from code review

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Update frontend/src/layout/navigation/TopNavigation.tsx

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Address feedback

* Project-based permissioning full data access restrictions (#6068)

* Fix Access Control restriction tooltip

* Add `TeamMemberAccessPermission` and use it in viewsets

* Add `ErrorProjectUnavailable` scene

* Ignore mypy

* Update MainNavigation.tsx

* Update explicit_team_member.py

* Fix frontend detection of unavailable project

* Fix some tests and edge cases

* Fix basic permissions

* Add more tests

* Simplify `ExplicitTeamMemberViewSet` permissions

* Improve restrictions and add moar tests

* Update frontend

* Fix a couple of things

* Fix import

* Fix some edge cases

* Fix typing errors

* Use hedgehog instead of moth

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Address feedback

* Add proper permissioning to dashboard views

* Update ee/api/test/test_dashboard.py

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>

* Run prettier

* Remove debug code

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-29 22:43:40 +00:00
Michael Matloka
eb6db7c075
Project-based permissioning members addition + removal (#6028)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type

* Add "Per-project access" feature flag, premium feature, and organization switch

* Rename `OrganizationMembershipLevel` to `OrganizationAccessLevel`

* Create `ExplicitTeamMembership` model

* Show whether projects are restricted in the project switcher

* Update organizations API code

* Fix migrations

* Move organization tests that require EE to `ee`

* Revert `OrganizationMembershipLevel` rename

* Fix organization tests

* Update migration

* Fix schema and add Members to Project Settings

* Build out test memberships API with security tests

* Update `TeamMembers` and `teamMembersLogic`

* Move "Per-project access" description to tooltip

* Add moar tests

* Fix Project Members list logic

* Add additional membership checks

* Update migrations

* Fix typing

* Adjust explicit team memberships API similarly

* Fix typo

* Unify `ExplicitTeamMemberSerializer`

* Remove old changes to `membersLogic` usage

* Use `effective_membership_level` on `TeamBasicSerializer`

* Clean up organization update tests

* Explicitly disallow enabling per-project access for free

* Fix circular import

* Remove `id` from `UserSerializer`

* Fix typing

* Try to fix import

* Fix fatal typing

* Add more tests

* Update permissioning.ts

* Add clarifying comment to migration

* Fix import

* Revert `TopNavigation` changes

* Add project member addition button+modal

* minor clarifications

* Revert `TopNavigation` changes

* Make new access control entirely project-based

* Update migrations

* Add `project_based_permissioning` to `TeamBasicSerializer`

* Update test_team.py

* Fix Access Control restriction tooltip

* minor improvements

* fix frontend typing

* Fix frontend typing a bit more

* adjust copy & UI a bit

* Address feedback on field comment

* "Privacy settings" to "Access Control"

* Make `FusedTeamMemberType` comment clearer

* Remove useless `export`

* Delete 0169_project_based_permissioning.py

* Clean some code up a bit

* Project-based permissioning member removal (#6067)

* Fix  `teamMembersLogic` loaders

* Allow explicit project members to leave

* Add member removal/leaving button to Members with Project Access

* Restore error message

* Fix error message

* Correct things

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-22 17:32:35 +00:00
Michael Matloka
bc3e223265
Project-based permissioning framework (#5976)
* Refactor `AvailableFeature` from strings to an enum everywhere

* Fix circular dependency and type

* Add "Per-project access" feature flag, premium feature, and organization switch

* Rename `OrganizationMembershipLevel` to `OrganizationAccessLevel`

* Create `ExplicitTeamMembership` model

* Show whether projects are restricted in the project switcher

* Update organizations API code

* Fix migrations

* Move organization tests that require EE to `ee`

* Revert `OrganizationMembershipLevel` rename

* Fix organization tests

* Update migration

* Fix schema and add Members to Project Settings

* Build out test memberships API with security tests

* Update `TeamMembers` and `teamMembersLogic`

* Move "Per-project access" description to tooltip

* Add moar tests

* Fix Project Members list logic

* Add additional membership checks

* Update migrations

* Fix typing

* Adjust explicit team memberships API similarly

* Fix typo

* Unify `ExplicitTeamMemberSerializer`

* Remove old changes to `membersLogic` usage

* Use `effective_membership_level` on `TeamBasicSerializer`

* Clean up organization update tests

* Explicitly disallow enabling per-project access for free

* Fix circular import

* Remove `id` from `UserSerializer`

* Fix typing

* Try to fix import

* Fix fatal typing

* Add more tests

* Update permissioning.ts

* Add clarifying comment to migration

* Fix import

* minor clarifications

* Revert `TopNavigation` changes

* Make new access control entirely project-based

* Update migrations

* Add `project_based_permissioning` to `TeamBasicSerializer`

* Update test_team.py

* Fix Access Control restriction tooltip

* adjust copy & UI a bit

* Address feedback on field comment

* "Privacy settings" to "Access Control"

* Ignore mypy

* Rename `Team` field `project_based_permissioning` to `access_control`

* Update migrations

Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
2021-09-22 18:29:59 +02:00