1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-14 09:08:32 +00:00

Merge branch '488-creating-an-invitation-fails-hard-if-the-message-is-not-provided' into 'develop'

Resolve "Creating an invitation fails hard if the `message` is not provided"

Closes 

See merge request 
This commit is contained in:
Nigel Gott 2021-06-25 12:21:32 +00:00
commit cfcdcd33e0
4 changed files with 47 additions and 3 deletions
backend
src/baserow/core
tests/baserow
changelog.md

View file

@ -407,7 +407,7 @@ class CoreHandler:
return group_invitation
def create_group_invitation(
self, user, group, email, permissions, message, base_url
self, user, group, email, permissions, base_url, message=""
):
"""
Creates a new group invitation for the given email address and sends out an
@ -423,12 +423,12 @@ class CoreHandler:
:param permissions: The group permissions that the user will get once he has
accepted the invitation.
:type permissions: str
:param message: A custom message that will be included in the invitation email.
:type message: str
:param base_url: The base url of the frontend, where the user can accept his
invitation. The signed invitation id is appended to the URL (base_url +
'/TOKEN'). Only the PUBLIC_WEB_FRONTEND_HOSTNAME is allowed as domain name.
:type base_url: str
:param message: A custom message that will be included in the invitation email.
:type message: Optional[str]
:raises ValueError: If the provided permissions are not allowed.
:raises UserInvalidGroupPermissionsError: If the user does not belong to the
group or doesn't have right permissions in the group.

View file

@ -197,6 +197,35 @@ def test_create_group_invitation(api_client, data_fixture):
assert response_json["message"] == "Test"
assert "created_on" in response_json
response = api_client.post(
reverse("api:groups:invitations:list", kwargs={"group_id": group_1.id}),
{
"email": "test2@test.nl",
"permissions": "ADMIN",
"message": "",
"base_url": "http://localhost:3000/invite",
},
format="json",
HTTP_AUTHORIZATION=f"JWT {token_1}",
)
response_json = response.json()
assert response.status_code == HTTP_200_OK
assert response_json["message"] == ""
response = api_client.post(
reverse("api:groups:invitations:list", kwargs={"group_id": group_1.id}),
{
"email": "test2@test.nl",
"permissions": "ADMIN",
"base_url": "http://localhost:3000/invite",
},
format="json",
HTTP_AUTHORIZATION=f"JWT {token_1}",
)
response_json = response.json()
assert response.status_code == HTTP_200_OK
assert response_json["message"] == ""
@pytest.mark.django_db
def test_get_group_invitation(api_client, data_fixture):

View file

@ -499,6 +499,20 @@ def test_create_group_invitation(mock_send_email, data_fixture):
assert invitation.message == ""
assert GroupInvitation.objects.all().count() == 2
invitation = handler.create_group_invitation(
user=user,
group=group,
email="test3@test.nl",
permissions="ADMIN",
base_url="http://localhost:3000/invite",
)
assert invitation.invited_by_id == user.id
assert invitation.group_id == group.id
assert invitation.email == "test3@test.nl"
assert invitation.permissions == "ADMIN"
assert invitation.message == ""
assert GroupInvitation.objects.all().count() == 3
@pytest.mark.django_db
def test_update_group_invitation(data_fixture):

View file

@ -3,6 +3,7 @@
## Unreleased
* Made it possible to list table field meta-data with a token.
* Fix the create group invite endpoint failing when no message provided.
* Single select options can now be ordered by drag and drop.
## Released (2021-06-02)