Beispiel #1
0
    def get_single_preprocessor(admin, instance_id=None, **kw):
        """Accepts a single argument, `instance_id`, the primary key of the
        instance of the model to get.

        """
        if instance_id and int(instance_id) not in get_group_ids(admin):
            raise ProcessingException(description='', code=404)
Beispiel #2
0
    def delete_single_preprocessor(admin, instance_id=None, **kw):
        """Accepts a single argument, `instance_id`, which is the primary key
        of the instance which will be deleted.

        """
        if instance_id and int(instance_id) not in get_group_ids(admin):
            raise ProcessingException(description='', code=404)
    def post_preprocessor(admin, data=None, **kw):
        """Accepts a single argument, `data`, which is the dictionary of
        fields to set on the new instance of the model.

        """
        if 'group_id' not in data or 'action_id' not in data:
            raise ProcessingException(description='', code=400)

        if data['group_id'] not in get_group_ids(admin) or \
           data['action_id'] not in get_action_ids(admin):
            raise ProcessingException(description='', code=403)
Beispiel #4
0
    def patch_single_preprocessor(admin, instance_id=None, data=None, **kw):
        """Accepts two arguments, `instance_id`, the primary key of the
        instance of the model to patch, and `data`, the dictionary of fields
        to change on the instance.

        """
        if instance_id and int(instance_id) not in get_group_ids(admin):
            raise ProcessingException(description='', code=404)
        if 'name' in data:
            if not group_regex.match(data['name']):
                raise ProcessingException(description='Accented and special characters are forbidden, except hyphen', code=400)
Beispiel #5
0
    def get_many_preprocessor(admin, search_params=None, **kw):
        """Accepts a single argument, `search_params`, which is a dictionary
        containing the search parameters for the request.

        """
        group_ids = get_group_ids(admin)
        if len(group_ids) == 0:
            group_ids.append(0)

        if 'filters' in search_params:
            search_params['filters'].append({
                u'name': u'id', u'op': u'in', u'val': group_ids
            })
        else:
            search_params.update({
                'filters': [{
                    u'name': u'id',
                    u'op': u'in',
                    u'val': group_ids
                }]
            })