Example #1
0
 def add_default_views(self, context, data_dict):
     resources = datapreview.get_new_resources(context, data_dict)
     for resource in resources:
         if self.can_view({'package': data_dict, 'resource': resource}):
             view = {'title': 'PDF View',
                     'description': 'PDF view of the resource.',
                     'resource_id': resource['id'],
                     'view_type': 'pdf'}
             p.toolkit.get_action('resource_view_create')(
                 {'defer_commit': True}, view
             )
Example #2
0
 def add_default_views(self, context, data_dict):
     resources = datapreview.get_new_resources(context, data_dict)
     for resource in resources:
         if (resource.get('format', '').lower() in ['html', 'htm'] or
                 resource['url'].split('.')[-1] in ['html', 'htm']):
             view = {'title': 'Web Page View',
                     'description': 'View of the webpage',
                     'resource_id': resource['id'],
                     'view_type': 'webpage'}
             p.toolkit.get_action('resource_view_create')(
                 {'defer_commit': True, 'ignore_auth': True}, view
             )
Example #3
0
 def add_default_views(self, context, data_dict):
     resources = datapreview.get_new_resources(context, data_dict)
     for resource in resources:
         if self.can_view({'package': data_dict, 'resource': resource}):
             view = {
                 'title': 'PDF View',
                 'description': 'PDF view of the resource.',
                 'resource_id': resource['id'],
                 'view_type': 'pdf'
             }
             p.toolkit.get_action('resource_view_create')(
                 {
                     'defer_commit': True
                 }, view)
Example #4
0
 def add_default_views(self, context, data_dict):
     resources = datapreview.get_new_resources(context, data_dict)
     for resource in resources:
         if (resource.get('format', '').lower() in ['html', 'htm']
                 or resource['url'].split('.')[-1] in ['html', 'htm']):
             view = {
                 'title': 'Web Page View',
                 'description': 'View of the webpage',
                 'resource_id': resource['id'],
                 'view_type': 'webpage'
             }
             p.toolkit.get_action('resource_view_create')(
                 {
                     'defer_commit': True,
                     'ignore_auth': True
                 }, view)
Example #5
0
 def add_default_views(self, context, data_dict):
     resources = datapreview.get_new_resources(context, data_dict)
     for resource in resources:
         if self.can_view({'package': data_dict, 'resource': resource}):
             format = resource.get('format', '')
             view = {
                 'title': 'Geo View',
                 # detect when it is a service, not a file
                 'description': 'View of the {format} file'.format(
                     format=format.upper()
                 ),
                 'resource_id': resource['id'],
                 'view_type': 'geoview'
             }
             p.toolkit.get_action('resource_view_create')(
                 {'defer_commit': True}, view
             )
Example #6
0
 def add_default_views(self, context, data_dict):
     resources = datapreview.get_new_resources(context, data_dict)
     for resource in resources:
         if self.can_view({'package': data_dict, 'resource': resource}):
             format = resource.get('format', '')
             if format.lower() in ['csv', 'tsv']:
                 continue
             view = {
                 'title': 'Text View',
                 'description': 'View of the {format} file'.format(
                     format=format.upper()
                 ),
                 'resource_id': resource['id'],
                 'view_type': 'text'
             }
             p.toolkit.get_action('resource_view_create')(
                 {'defer_commit': True}, view
             )