-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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(org member invite): create OrganizationMemberInviteSerializer #87475
base: master
Are you sure you want to change the base?
Conversation
"member-limit:restricted": member_invite.member_limit_restricted, | ||
"partnership:restricted": member_invite.partnership_restricted, | ||
}, | ||
"teams": {}, |
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.
I looked into the code: we always assign role=None
for invited members. Seems a little redundant to have a dict where "role" is always None
—should we make this field default to a list instead?
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.
the teams and team roles can be assigned via the UI, it could be that we're not testing it explicitly. we'll need to decide how this data will be stored here, in the existing system we appear to make the objects (OrganizationMemberTeam
) but we won't be able to do that here
we could store the role and team as a mapping of team_id: role
perhaps (i would suggest id instead of slug because slug is mutable)
|
||
def test_simple(self): | ||
member_invite = self.create_member_invite(organization=self.org, email=self.email) | ||
result = serialize(member_invite, None, OrganizationMemberInviteSerializer()) |
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.
Not sure why I need to pass the serializer here ;_;
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.
hmm i was able to get it to pass by omitting the serializer
@@ -50,6 +52,32 @@ def generate_token(): | |||
return secrets.token_hex(nbytes=32) | |||
|
|||
|
|||
# Causes a circular import error when importing | |||
# from sentry.api.serializers.models.organization_member.response | |||
_OrganizationMemberFlags = TypedDict( |
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.
Any idea on how to fix this? :thunk:
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.
do we have to serialize this exactly like OrganizationMember does? this is a whole new endpoint and we'll have to create a new FE object to handle this anyway.
it could make it easier to serialize the fields directly
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #87475 +/- ##
=======================================
Coverage 87.74% 87.74%
=======================================
Files 9891 9893 +2
Lines 560952 561028 +76
Branches 22129 22129
=======================================
+ Hits 492186 492255 +69
- Misses 68362 68369 +7
Partials 404 404 |
@@ -50,6 +52,32 @@ def generate_token(): | |||
return secrets.token_hex(nbytes=32) | |||
|
|||
|
|||
# Causes a circular import error when importing | |||
# from sentry.api.serializers.models.organization_member.response | |||
_OrganizationMemberFlags = TypedDict( |
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.
do we have to serialize this exactly like OrganizationMember does? this is a whole new endpoint and we'll have to create a new FE object to handle this anyway.
it could make it easier to serialize the fields directly
if self.token_expires_at > timezone.now(): | ||
return False | ||
return True |
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.
nit
if self.token_expires_at > timezone.now(): | |
return False | |
return True | |
return self.token_expires_at <= timezone.now(): |
|
||
def test_simple(self): | ||
member_invite = self.create_member_invite(organization=self.org, email=self.email) | ||
result = serialize(member_invite, None, OrganizationMemberInviteSerializer()) |
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.
hmm i was able to get it to pass by omitting the serializer
"member-limit:restricted": member_invite.member_limit_restricted, | ||
"partnership:restricted": member_invite.partnership_restricted, | ||
}, | ||
"teams": {}, |
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.
the teams and team roles can be assigned via the UI, it could be that we're not testing it explicitly. we'll need to decide how this data will be stored here, in the existing system we appear to make the objects (OrganizationMemberTeam
) but we won't be able to do that here
we could store the role and team as a mapping of team_id: role
perhaps (i would suggest id instead of slug because slug is mutable)
Build out the
OrganizationMemberInviteSerializer
, to be used by the new member invite endpoints.