コード例 #1
0
ファイル: crudoperations.py プロジェクト: vecna/GLBackend
    def update_receiversetting(self, receiver_gus, conf_id, request, receiver_desc=None):

        store = self.getStore()

        profile_desc = PluginProfiles(store).get_single(request['profile_gus'])

        # Admin do not pass receiver_desc, and then is not checked capability
        if not receiver_desc:
            pass
        elif  profile_desc['plugin_type'] == u'notification' and receiver_desc['can_configure_notification']:
            pass
        elif profile_desc['plugin_type'] == u'delivery' and receiver_desc['can_configure_delivery']:
            pass
        else:
            raise ForbiddenOperation

        receivercfg_iface = ReceiverConfs(store)
        config_update = receivercfg_iface.update(conf_id, receiver_gus, request)

        if config_update['active']:
            # keeping active only the last configuration requested
            receivercfg_iface.deactivate_all_but(config_update['config_id'], config_update['context_gus'],
                receiver_gus, config_update['plugin_type'])

        self.returnData(config_update)
        self.returnCode(200)
        return self.prepareRetVals()
コード例 #2
0
ファイル: receiver.py プロジェクト: seanmrandall/GLBackend
    def put(self, receiver_token_auth, conf_id, *uriargs):
        """
        Parameters:
        Parameters: receiver_token_auth, receiver_configuration_id
        Request: receiverConfDesc
        Response: receiverConfDesc
        Errors: InvalidInputFormat, ProfileGusNotFound, ContextGusNotFound, ReceiverGusNotFound,

        update the resource ReceiverConf by a specific receiver, and if is requested as active,
        deactivate the others related to the same context.
        """

        receivertip_iface = ReceiverTip()

        try:
            request = validateMessage(self.request.body, requests.receiverReceiverDesc)

            receivers_map = yield receivertip_iface.get_receivers_by_tip(receiver_token_auth)
            user = receivers_map['actor']

            # ++ sanity checks that can't be make by validateMessage or by model:
            profile_iface = PluginProfiles()
            profile_desc = yield profile_iface.get_single(request['profile_gus'])

            if profile_desc['plugin_type'] == u'notification' and user['can_configure_notification']:
                pass
            elif profile_desc['plugin_type'] == u'delivery' and user['can_configure_delivery']:
                pass
            else:
                raise ForbiddenOperation
            # -- end of the sanity checks

            receivercfg_iface = ReceiverConfs()
            config_update = yield receivercfg_iface.update(conf_id, user['receiver_gus'], request)

            if config_update['active']:
                # keeping active only the last configuration requested
                yield receivercfg_iface.deactivate_all_but(config_update['config_id'], config_update['context_gus'],
                    user['receiver_gus'], config_update['plugin_type'])

            self.write(config_update)
            self.set_status(200) # OK

        except InvalidTipAuthToken, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})
コード例 #3
0
ファイル: receiver.py プロジェクト: seanmrandall/GLBackend
    def post(self, receiver_token_auth, *uriargs):
        """
        Parameters: receiver_token_auth
        Request: receiverConfDesc
        Response: receiverConfDesc
        Errors: TipGusNotFound, InvalidTipAuthToken, ForbiddenOperation, ContextGusNotFound, ReceiverGusNotFound

        Create a new configuration for a plugin
        """

        receivertip_iface = ReceiverTip()

        try:
            request = validateMessage(self.request.body, requests.receiverReceiverDesc)

            receivers_map = yield receivertip_iface.get_receivers_by_tip(receiver_token_auth)
            user = receivers_map['actor']

            # ++ sanity checks that can't be make by validateMessage or by model:
            profile_iface = PluginProfiles()
            profile_desc = yield profile_iface.get_single(request['profile_gus'])

            if profile_desc['plugin_type'] == u'notification' and user['can_configure_notification']:
                pass
            elif profile_desc['plugin_type'] == u'delivery' and user['can_configure_delivery']:
                pass
            else:
                raise ForbiddenOperation
            # -- end of the sanity checks

            receivercfg_iface = ReceiverConfs()
            config_desc = yield receivercfg_iface.new(user['receiver_gus'], request)

            if config_desc['active']:
                # keeping active only the last configuration requested
                yield receivercfg_iface.deactivate_all_but(config_desc['config_id'], config_desc['context_gus'],
                    user['receiver_gus'], config_desc['plugin_type'])

            self.write(config_desc)
            self.set_status(201) # Created

        except InvalidTipAuthToken, e:

            self.set_status(e.http_status)
            self.write({'error_message': e.error_message, 'error_code' : e.error_code})