How to use the restless.resources.skip_prepare function in restless

To help you get started, we’ve selected a few restless examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github toastdriven / restless / tests / test_dj.py View on Github external
    @skip_prepare
    def schema(self):
        # A WILD SCHEMA VIEW APPEARS!
        return {
            'fields': {
                'id': {
                    'type': 'integer',
                    'required': True,
                    'help_text': 'The unique id for the post',
                },
                'title': {
                    'type': 'string',
                    'required': True,
                    'help_text': "The post's title",
                },
                'author': {
                    'type': 'string',
github dbca-wa / oim-cms / oim_cms / api.py View on Github external
    @skip_prepare
    def list(self):
        return getattr(self, 'data_' + self.request.GET['list'])()
github dbca-wa / oim-cms / organisation / api.py View on Github external
    @skip_prepare
    def list(self):
        data = list(self.list_qs())
        for row in data:
            if row['point']:
                row['point'] = row['point'].wkt
        return data
github dbca-wa / oim-cms / organisation / api.py View on Github external
    @skip_prepare
    def create(self):
        """Call this endpoint from on-prem AD or from Azure AD.
        Match either AD-object key values or Departmentuser field names.
        """
        user = DepartmentUser()
        # Check for essential request params.
        if 'EmailAddress' not in self.data and 'email' not in self.data:
            raise BadRequest('Missing email parameter value')
        if 'DisplayName' not in self.data and 'name' not in self.data:
            raise BadRequest('Missing name parameter value')
        if 'SamAccountName' not in self.data and 'username' not in self.data:
            raise BadRequest('Missing account name parameter value')

        # Make an assumption that EmailAddress or email is passed in.
        if 'EmailAddress' in self.data:
            LOGGER.info('Creating user {}'.format(self.data['EmailAddress'].lower()))
github dbca-wa / oim-cms / tracking / api.py View on Github external
    @skip_prepare
    def create(self):
        if not isinstance(self.data, list):
            self.data = [self.data]
            deleted = None
        else:
            deleted = EC2Instance.objects.exclude(
                ec2id__in=[i['InstanceId'] for i in self.data]).delete()
        for instc in self.data:
            instance, created = EC2Instance.objects.get_or_create(ec2id=instc['InstanceId'])
            instance.name = [x['Value'] for x in instc['Tags'] if x['Key'] == 'Name'][0]
            instance.launch_time = instc['LaunchTime']
            instance.running = instc['State']['Name'] == 'running'
            instance.extra_data = instc
            instance.save()
        return {'saved': len(self.data), 'deleted': deleted}
github dbca-wa / oim-cms / registers / api.py View on Github external
    @skip_prepare
    def current(self):
        # Slightly-expensive query: iterate over each 'current' event and call save().
        # This should automatically expire any events that need to be non-current.
        for i in ITSystemEvent.objects.filter(current=True):
            i.save()
        # Return prepared data.
        return {'objects': [self.prepare(data) for data in ITSystemEvent.objects.filter(current=True)]}
github dbca-wa / oim-cms / tracking / api.py View on Github external
    @skip_prepare
    def list(self):
        data = list(self.list_qs())
        return data