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

Auto org selection with cross-org object switcher #5823

Merged
merged 9 commits into from
Jan 24, 2025
Merged

Conversation

ericnewcomer
Copy link
Member

@ericnewcomer ericnewcomer commented Jan 23, 2025

Decided to add Switch view for normal users when clicking on link for objects they have access to but aren't currently logged in to see. This is a draft, still needs more tests.

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1e4a789) to head (ab21a01).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5823   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          459       460    +1     
  Lines        25127     25178   +51     
=========================================
+ Hits         25127     25178   +51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ericnewcomer ericnewcomer changed the title [WIP] Auto org selection with cross-org object switcher Auto org selection with cross-org object switcher Jan 24, 2025
@ericnewcomer ericnewcomer marked this pull request as ready for review January 24, 2025 06:35
if user.is_staff:
return org

membership = org.get_membership(user)
Copy link
Member

Choose a reason for hiding this comment

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

seems like this could be combined with line 77

Copy link
Member Author

Choose a reason for hiding this comment

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

it feels pretty clear as written to me, what are you proposing exactly?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking line 77 could both filter by org id and user membership but it's fine keeping those separate

@ericnewcomer ericnewcomer merged commit a801b2c into main Jan 24, 2025
5 checks passed
@ericnewcomer ericnewcomer deleted the auto-org branch January 24, 2025 19:20
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2025
orgs = user.orgs.filter(is_active=True).order_by("-created_on")
if orgs.count() > 0:
# take the newest one
choose_org = orgs[0]
Copy link
Member

Choose a reason for hiding this comment

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

why not .first()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants