-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
base: main
Are you sure you want to change the base?
feat(organizations): create endpoints to handle organization invitations #5395
Conversation
092d932
to
64a2b55
Compare
64a2b55
to
1139076
Compare
1139076
to
c28ad37
Compare
@rajpatel24 Wuld that whole invite object be present in |
@magicznyleszek No, the invite object would not be present there. I don't think it's necessary since The |
31ac077
to
ea9a6bd
Compare
32b1431
to
5394358
Compare
|
||
{% trans "All projects, submissions, data storage, transcription and translation usage for their projects will be transferred to you." %} | ||
|
||
{% trans "Note: You will continue to have permissions to manage these projects until the user permissions are changed." %} |
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 don't think this sentence should be here since that's the sender who receives this message.
(Please fix HTML template too)
kobo/apps/organizations/templates/emails/registered_user_invite.txt
Outdated
Show resolved
Hide resolved
…atuses from the model
kobo/apps/organizations/models.py
Outdated
@@ -365,21 +376,26 @@ def send_invite_email(self): | |||
email_message = EmailMessage( | |||
to=to_email, | |||
subject=t( | |||
f"You're invited to join {organization_name}'s organization" | |||
), | |||
f"You're invited to join ##organization_name## organization" |
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.
Does not need to be an f-string anymore
kobo/apps/organizations/models.py
Outdated
sender_language = self.invited_by.extra_details.data.get( | ||
'last_ui_language', 'en' | ||
) | ||
activate(sender_language) |
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.
It seems it would be better to use
with translation.override(sender_language):
...
instead of activate(sender_language)
Otherwise, everytime we use activate()
we should restore the current language when we are done with translations
current_language = django.utils.translation.get_language()
activate(sender_language)
# do what you want with translations
activate(current_language)
kobo/apps/organizations/models.py
Outdated
sender_language = self.invited_by.extra_details.data.get( | ||
'last_ui_language', 'en' | ||
) |
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.
instead of hard-coding 'en'
, we should use either settings.LANGUAGE_CODE
or django.utils.translation.get_language()
current_language = django.utils.translation.get_language()
# or current_language = settings.LANGUAGE_CODE
sender_language = self.invited_by.extra_details.data.get(
'last_ui_language', current_language
)
kobo/apps/organizations/models.py
Outdated
f"You're invited to join {organization_name}'s organization" | ||
), | ||
f"You're invited to join ##organization_name## organization" | ||
).replace('##organization_name##', organization_name), |
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.
You could use your utility replace_placeholders()
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.
Done. Also I have moved the utility function to a new file, as it is a generic utility not specific to the organizations app.
@@ -338,6 +340,7 @@ def _send_status_email(self, instance, status): | |||
if email_func: | |||
email_func() | |||
|
|||
@void_cache_for_request(keys=("organization",)) |
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'm surprised the linter did not catch it but use single quotes 🙏 .
('owner', status.HTTP_200_OK), | ||
('admin', status.HTTP_200_OK), | ||
('member', status.HTTP_403_FORBIDDEN), | ||
('external', status.HTTP_403_FORBIDDEN) |
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 think it should 404 for external. We don't want to reveal the existence of the organization to external.
('owner', status.HTTP_200_OK), | ||
('admin', status.HTTP_200_OK), | ||
('member', status.HTTP_403_FORBIDDEN), | ||
('external', status.HTTP_403_FORBIDDEN) |
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 think it should 404 for external. We don't want to reveal the existence of the organization to external.
… refine permissions
🗒️ Checklist
<type>(<scope>)<!>: <title> TASK-1234
frontend
orbackend
unless it's global📣 Summary
Implemented endpoints for organization invitations, allowing organization owners to invite existing users or unregistered users to join their organization. The invitee can either accept or decline the invitation. If the invitee accepts, their assets will be transferred to the organization.
📖 Description
member
,admin
). Default ismember
.Payload:
Response:
Response:
Payload:
Response:
Response: 204