Skip to content

Commit

Permalink
Resolve invitation error when user dose not exists any more
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdu-moustafa committed Sep 3, 2024
1 parent 32df825 commit 3bb6cee
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
Empty file added changes/TI-1036.other
Empty file.
34 changes: 34 additions & 0 deletions opengever/api/tests/test_participation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,40 @@ def test_list_all_my_invitations(self, browser):
}
], response.get('items'))

@browsing
def test_inviter_resolution_with_non_existing_user(self, browser):
self.login(self.workspace_owner, browser)

with freeze(datetime(2018, 4, 30, 10, 30)):
iid = getUtility(IInvitationStorage).add_invitation(
self.workspace,
self.regular_user.getProperty('email'),
"Does not exist",
'WorkspaceGuest')

self.login(self.regular_user, browser)

response = browser.open(
self.portal,
view='@my-workspace-invitations',
method='GET',
headers=http_headers(),
).json

self.assertItemsEqual(
[
{
u'@id': u'http://nohost/plone/@workspace-invitations/{}'.format(iid),
u'@type': u'virtual.participations.invitation',
u'accept': u'http://nohost/plone/@workspace-invitations/{}/accept'.format(iid),
u'created': u'2018-04-30T10:30:00+00:00',
u'decline': u'http://nohost/plone/@workspace-invitations/{}/decline'.format(iid),
u'inviter_fullname': u'Unknown ID (Does not exist)',
u'title': u'A Workspace',
u'comment': u''
}
], response.get('items'))


class TestInvitationsPOST(IntegrationTestCase):

Expand Down
5 changes: 2 additions & 3 deletions opengever/workspace/participation/browser/my_invitations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from opengever.base.role_assignments import RoleAssignmentManager
from opengever.base.role_assignments import SharingRoleAssignment
from opengever.base.security import elevated_privileges
from opengever.ogds.base.actor import PloneUserActor
from opengever.ogds.base.actor import Actor
from opengever.ogds.base.utils import get_current_admin_unit
from opengever.ogds.models.group import Group
from opengever.ogds.models.service import ogds_service
Expand Down Expand Up @@ -59,8 +59,7 @@ def get_invitations(self):
target_title = target.Title()

if target:
inviter = PloneUserActor(entry['inviter'],
user=api.user.get(entry['inviter']))
inviter = Actor.lookup(entry['inviter'])
yield {'inviter': inviter.get_label(),
'target_title': target_title,
'iid': entry['iid'],
Expand Down

0 comments on commit 3bb6cee

Please sign in to comment.