Skip to content

Commit

Permalink
membership-request [inveniosoftware#855]: implement decision flow
Browse files Browse the repository at this point in the history
  • Loading branch information
fenekku committed Jul 23, 2024
1 parent f4967e5 commit a2428f5
Show file tree
Hide file tree
Showing 5 changed files with 445 additions and 354 deletions.
4 changes: 3 additions & 1 deletion invenio_communities/members/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def create_url_rules(self):
route(
"GET", routes["membership_requests"], self.search_membership_requests
),
route("PUT", routes["membership_requests"], self.update_membership_requests),
route(
"PUT", routes["membership_requests"], self.update_membership_requests
),
]

@request_view_args
Expand Down
4 changes: 2 additions & 2 deletions invenio_communities/members/services/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def _member_changed(self, member, community=None):
for user_id in user_ids:
on_user_membership_change(Identity(user_id))

def accept_invite(self, identity, record=None, data=None, **kwargs):
"""On accept invite."""
def accept_member_request(self, identity, record=None, data=None, **kwargs):
"""Upon acceptance of a member request (invitation or membership request)."""
self._member_changed(record)

def members_add(self, identity, record=None, community=None, data=None, **kwargs):
Expand Down
31 changes: 18 additions & 13 deletions invenio_communities/members/services/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AcceptAction(actions.AcceptAction):

def execute(self, identity, uow):
"""Execute action."""
service().accept_invite(system_identity, self.request.id, uow=uow)
service().accept_member_request(system_identity, self.request.id, uow=uow)
uow.register(
NotificationOp(
CommunityInvitationAcceptNotificationBuilder.build(self.request)
Expand All @@ -61,7 +61,7 @@ class DeclineAction(actions.DeclineAction):

def execute(self, identity, uow):
"""Execute action."""
service().decline_invite(system_identity, self.request.id, uow=uow)
service().close_member_request(system_identity, self.request.id, uow=uow)
uow.register(
NotificationOp(
CommunityInvitationDeclineNotificationBuilder.build(self.request)
Expand All @@ -75,7 +75,7 @@ class CancelAction(actions.CancelAction):

def execute(self, identity, uow):
"""Execute action."""
service().decline_invite(system_identity, self.request.id, uow=uow)
service().close_member_request(system_identity, self.request.id, uow=uow)
uow.register(
NotificationOp(
CommunityInvitationCancelNotificationBuilder.build(self.request)
Expand All @@ -89,7 +89,7 @@ class ExpireAction(actions.ExpireAction):

def execute(self, identity, uow):
"""Execute action."""
service().decline_invite(system_identity, self.request.id, uow=uow)
service().close_member_request(system_identity, self.request.id, uow=uow)
uow.register(
NotificationOp(
CommunityInvitationExpireNotificationBuilder.build(self.request)
Expand Down Expand Up @@ -141,27 +141,32 @@ class CancelMembershipRequestAction(actions.CancelAction):

def execute(self, identity, uow):
"""Execute action."""
service().close_membership_request(system_identity, self.request.id, uow=uow)
service().close_member_request(system_identity, self.request.id, uow=uow)
# TODO: Notification flow: Investigate notifications
super().execute(identity, uow)


class AcceptMembershipRequestAction(actions.AcceptAction):
"""Accept membership request action."""
class DeclineMembershipRequestAction(actions.DeclineAction):
"""Decline membership request action."""

def execute(self, identity, uow):
"""Execute action."""
# TODO: Decision flow: Implement me
pass
service().close_member_request(system_identity, self.request.id, uow=uow)
# TODO: Notification flow: Investigate notifications
super().execute(identity, uow)


class DeclineMembershipRequestAction(actions.DeclineAction):
"""Decline membership request action."""
# TODO: Expiration flow: ExpireAction


class AcceptMembershipRequestAction(actions.AcceptAction):
"""Accept membership request action."""

def execute(self, identity, uow):
"""Execute action."""
# TODO: Decision flow: Implement me
pass
service().accept_member_request(system_identity, self.request.id, uow=uow)
# TODO: Notification flow: Investigate notifications
super().execute(identity, uow)


class MembershipRequestRequestType(RequestType):
Expand Down
Loading

0 comments on commit a2428f5

Please sign in to comment.