-
-
Notifications
You must be signed in to change notification settings - Fork 184
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(organizations): create endpoints to handle organization invitations #5395
Open
rajpatel24
wants to merge
6
commits into
main
Choose a base branch
from
task-969-create-endpoints-to-handle-org-invitations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c28ad37
Create endpoints to handle organization invitations
rajpatel24 af29b03
Merge branch 'main' into task-969-create-endpoints-to-handle-org-invi…
rajpatel24 ea9a6bd
Update organization invitation tests and email templates
rajpatel24 5394358
Include invite object in the organization members endpoint
rajpatel24 93eb306
Add unit test to validate invite object in organization members list
rajpatel24 1674881
Merge branch 'main' into task-969-create-endpoints-to-handle-org-invi…
noliveleger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
INVITE_OWNER_ERROR = ( | ||
'This account is already the owner of {organization_name}. ' | ||
'You cannot join multiple organizations with the same account. ' | ||
'To accept this invitation, you must either transfer ownership of ' | ||
'{organization_name} to a different account or sign in using a different ' | ||
'account with the same email address. If you do not already have another ' | ||
'account, you can create one.' | ||
) | ||
|
||
INVITE_MEMBER_ERROR = ( | ||
'This account is already a member in {organization_name}. ' | ||
'You cannot join multiple organizations with the same account. ' | ||
'To accept this invitation, sign in using a different account with the ' | ||
'same email address. If you do not already have another account, you can ' | ||
'create one.' | ||
) | ||
INVITE_ALREADY_ACCEPTED_ERROR = 'Invite has already been accepted.' | ||
INVITE_NOT_FOUND_ERROR = 'Invite not found.' | ||
ORG_ADMIN_ROLE = 'admin' | ||
ORG_EXTERNAL_ROLE = 'external' | ||
ORG_MEMBER_ROLE = 'member' | ||
ORG_OWNER_ROLE = 'owner' | ||
USER_DOES_NOT_EXIST_ERROR = \ | ||
'User with username or email {invitee} does not exist or is not active.' |
41 changes: 41 additions & 0 deletions
41
...s/organizations/migrations/0010_add_status_and_invitee_role_to_organization_invitation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 4.2.15 on 2025-01-02 12:25 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('organizations', '0009_update_db_state_with_auth_user'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='organizationinvitation', | ||
name='invitee_role', | ||
field=models.CharField( | ||
choices=[('admin', 'Admin'), ('member', 'Member')], | ||
default='member', | ||
max_length=10, | ||
), | ||
), | ||
migrations.AddField( | ||
model_name='organizationinvitation', | ||
name='status', | ||
field=models.CharField( | ||
choices=[ | ||
('accepted', 'Accepted'), | ||
('cancelled', 'Cancelled'), | ||
('complete', 'Complete'), | ||
('declined', 'Declined'), | ||
('expired', 'Expired'), | ||
('failed', 'Failed'), | ||
('in_progress', 'In Progress'), | ||
('pending', 'Pending'), | ||
('resent', 'Resent'), | ||
], | ||
default='pending', | ||
max_length=11, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajpatel24 What's the difference between
in_progress
andpending
?Edit: looking more at this list, I think it would be very useful if you'd describe each of these statuses - like what action triggers them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@magicznyleszek As of now, we're not using
in_progress
as a status for organization invitations. I included it as a possible choice, along withcompleted
andfailed
, in case the need arises in the future. Once @noliveleger is back (probably today), I'll discuss this with him. Currently, when the organization owner sends an invitation, the status is set topending
. When the invitee accepts the invitation, the status changes toaccepted
in theOrganizationInvitation
table.Additionally, when a user accepts an invitation, we trigger an async task to transfer their projects to the organization. This is part of the existing functionality we're reusing for project transfers along with organization invitations. It uses its own
project-ownership/Invite
table with different statuses, which you might already be familiar with.So, my question for @noliveleger would be: when the project transfer is completed and the status in the
project-ownership/Invite
table is set tocompleted
, do we also need to set the status tocompleted
in theOrganizationInvitation
table, or is theaccepted
state sufficient?To summarize, the
/api/v2/organizations/:organization_id/invites/
API will currently have the following statuses:pending
,accepted
,declined
,cancelled
,expired
, andresent
.If any changes occur regarding this, I'll make sure to update you right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rajpatel24 ,
accepted
would be enough forOrganizationInvitation
.