Example #1
0
    def action_detach(request, channel_oid, sender_oid, target_uid,
                      permissions, profile_oid):
        target_self = sender_oid == target_uid

        # Permission Check
        if target_self and ProfilePermission.PRF_CONTROL_SELF in permissions:
            pass
        elif ProfilePermission.PRF_CONTROL_MEMBER in permissions:
            pass
        else:
            return HttpResponse(status=403)

        # Main Action
        detach_outcome = ProfileManager.detach_profile(channel_oid,
                                                       profile_oid, sender_oid,
                                                       target_uid)

        # Alert messages
        if detach_outcome.is_success:
            messages.info(request, _("Profile detached."))
        else:
            messages.warning(
                request,
                _("Failed to detach the profile. ({})").format(detach_outcome))

        return redirect(
            reverse("info.profile", kwargs={"profile_oid": profile_oid}))
Example #2
0
 def process_pass(self):
     self._result = ProfileManager.detach_profile(self._channel_oid,
                                                  self._profile_oid,
                                                  self._sender_oid,
                                                  self._target_oid)