Exemplo n.º 1
0
    'organization': fields.Nested(org_ref_fields, allow_null=True,
        description='The producer organization'),
    'supplier': fields.Nested(org_ref_fields, allow_null=True,
        description='The supplyer organization (if different from the producer)'),
    'temporal_coverage': fields.Nested(temporal_coverage_fields, allow_null=True,
        description='The temporal coverage'),
    'spatial': fields.Nested(spatial_coverage_fields, allow_null=True, description='The spatial coverage'),
    'license': fields.String(attribute='license.id', description='The dataset license'),

    'uri': fields.UrlFor('api.dataset', lambda o: {'dataset': o},
        description='The dataset API URI', required=True),
    'page': fields.UrlFor('datasets.show', lambda o: {'dataset': o},
        description='The dataset page URL', required=True),
})

dataset_page_fields = api.model('DatasetPage', fields.pager(dataset_fields))

dataset_suggestion_fields = api.model('DatasetSuggestion', {
    'id': fields.String(description='The dataset identifier', required=True),
    'title': fields.String(description='The dataset title', required=True),
    'slug': fields.String(description='The dataset permalink string', required=True),
    'image_url': fields.String(description='The dataset (organization) logo URL'),
    'score': fields.Float(description='The internal match score', required=True),
})

dataset_ref_fields = api.inherit('DatasetReference', base_reference, {
    'title': fields.String(description='The dataset title', readonly=True),
    'uri': fields.UrlFor('api.dataset', lambda d: {'dataset': d},
        description='The API URI for this dataset', readonly=True),
    'page': fields.UrlFor('datasets.show', lambda d: {'dataset': d},
        description='The web page URL for this dataset', readonly=True),
Exemplo n.º 2
0
    'reuses': fields.List(fields.Nested(reuse_ref_fields), description='The post reuses'),

    'owner': fields.Nested(user_ref_fields, description='The owner user', readonly=True, allow_null=True),
    'private': fields.Boolean(description='Is the post visible'),

    'created_at': fields.ISODateTime(description='The post creation date', readonly=True),
    'last_modified': fields.ISODateTime(description='The post last modification date', readonly=True),

    'uri': fields.UrlFor('api.post', lambda o: {'post': o},
        description='The post API URI', readonly=True),
    'page': fields.UrlFor('posts.show', lambda o: {'post': o},
        description='The post page URL', readonly=True),
})


post_page_fields = api.model('PostPage', fields.pager(post_fields))

parser = api.page_parser()


@ns.route('/', endpoint='posts')
class PostsAPI(API):

    @api.doc('list_posts', model=post_page_fields, parser=parser)
    @api.marshal_with(post_page_fields)
    def get(self):
        '''List all posts'''
        args = parser.parse_args()
        return Post.objects.order_by('-created').paginate(args['page'], args['page_size'])

    @api.doc('create_post', responses={400: 'Validation error'})
Exemplo n.º 3
0
        'last_modified':
        fields.ISODateTime(description='The post last modification date',
                           readonly=True),
        'uri':
        fields.UrlFor('api.post',
                      lambda o: {'post': o},
                      description='The post API URI',
                      readonly=True),
        'page':
        fields.UrlFor('posts.show',
                      lambda o: {'post': o},
                      description='The post page URL',
                      readonly=True),
    })

post_page_fields = api.model('PostPage', fields.pager(post_fields))

parser = api.page_parser()


@ns.route('/', endpoint='posts')
class PostsAPI(API):
    @api.doc('list_posts', model=post_page_fields, parser=parser)
    @api.marshal_with(post_page_fields)
    def get(self):
        '''List all posts'''
        args = parser.parse_args()
        return Post.objects.order_by('-created').paginate(
            args['page'], args['page_size'])

    @api.doc('create_post', responses={400: 'Validation error'})
Exemplo n.º 4
0
        fields.ISODateTime(description='The job end date'),
        'status':
        fields.String(description='The job status',
                      required=True,
                      enum=HARVEST_JOB_STATUS.keys()),
        'errors':
        fields.List(fields.Nested(error_fields),
                    description='The job initialization errors'),
        'items':
        fields.List(fields.Nested(item_fields),
                    description='The job collected items'),
        'source':
        fields.String(description='The source owning the job', required=True),
    })

job_page_fields = api.model('HarvestJobPage', fields.pager(job_fields))

validation_fields = api.model(
    'HarvestSourceValidation', {
        'state':
        fields.String(description='Is it validated or not',
                      enum=VALIDATION_STATES.keys(),
                      required=True),
        'by':
        fields.Nested(user_ref_fields,
                      allow_null=True,
                      readonly=True,
                      description='Who performed the validation'),
        'on':
        fields.ISODateTime(
            readonly=True,
Exemplo n.º 5
0
from udata.core.user.api_fields import user_ref_fields

from .signals import on_new_follow


follow_fields = api.model('Follow', {
    'id': fields.String(
        description='The follow object technical ID', readonly=True),
    'follower': fields.Nested(
        user_ref_fields, description='The follower', readonly=True),
    'since': fields.ISODateTime(
        description='The date from which the user started following',
        readonly=True)
})

follow_page_fields = api.model('FollowPage', fields.pager(follow_fields))

parser = api.parser()
parser.add_argument(
    'page', type=int, default=1, location='args', help='The page to fetch')
parser.add_argument(
    'page_size', type=int, default=20, location='args',
    help='The page size to fetch')

NOTE = 'Returns the number of followers left after the operation'


class FollowAPI(API):
    '''
    Base Follow Model API.
    '''
Exemplo n.º 6
0
    'url': fields.String(description='The organization website URL'),
    'slug': fields.String(description='The organization string used as permalink', required=True),
    'description': fields.Markdown(description='The organization description in Markdown', required=True),
    'created_at': fields.ISODateTime(description='The organization creation date', readonly=True),
    'last_modified': fields.ISODateTime(description='The organization last modification date', readonly=True),
    'deleted': fields.ISODateTime(description='The organization deletion date if deleted', readonly=True),
    'metrics': fields.Raw(description='The organization metrics', readonly=True),
    'uri': fields.UrlFor('api.organization', lambda o: {'org': o},
        description='The organization API URI', readonly=True),
    'page': fields.UrlFor('organizations.show', lambda o: {'org': o},
        description='The organization page URL', readonly=True),
    'logo': fields.ImageField(description='The organization logo URLs'),
    'members': fields.List(fields.Nested(member_fields, description='The organization members')),
})

org_page_fields = api.model('OrganizationPage', fields.pager(org_fields))

org_suggestion_fields = api.model('OrganizationSuggestion', {
    'id': fields.String(description='The organization identifier', readonly=True),
    'name': fields.String(description='The organization name', readonly=True),
    'acronym': fields.String(description='The organization acronym', readonly=True),
    'slug': fields.String(description='The organization permalink string', readonly=True),
    'image_url': fields.String(description='The organization logo URL', readonly=True),
    'score': fields.Float(description='The internal match score', readonly=True),
})

logo_fields = api.model('UploadedLogo', {
    'success': fields.Boolean(description='Whether the upload succeeded or not.', readonly=True, default=True),
    'logo': fields.ImageField(),
    # 'error': fields.String(description='An error message if success is false', readonly=True),
})
Exemplo n.º 7
0
        description='The user profile page URL', readonly=True),
    'uri': fields.UrlFor(
        'api.user', lambda o: {'user': o},
        description='The user API URI', required=True),
})

me_fields = api.inherit('Me', user_fields, {
    'email': fields.String(description='The user email', required=True),
    'apikey': fields.String(description='The user API Key', readonly=True),
})

apikey_fields = api.model('ApiKey', {
    'apikey': fields.String(description='The user API Key', readonly=True),
})

user_page_fields = api.model('UserPage', fields.pager(user_fields))

user_suggestion_fields = api.model('UserSuggestion', {
    'id': fields.String(description='The user identifier', readonly=True),
    'first_name': fields.String(description='The user first name',
                                readonly=True),
    'last_name': fields.String(description='The user last name',
                               readonly=True),
    'avatar_url': fields.String(description='The user avatar URL'),
    'slug': fields.String(
        description='The user permalink string', readonly=True),
    'score': fields.Float(
        description='The internal match score', readonly=True),
})

Exemplo n.º 8
0
        description='The organization metrics', readonly=True),
    'uri': fields.UrlFor(
        'api.organization', lambda o: {'org': o},
        description='The organization API URI', readonly=True),
    'page': fields.UrlFor(
        'organizations.show', lambda o: {'org': o},
        description='The organization page URL', readonly=True),
    'logo': fields.ImageField(description='The organization logo URLs'),
    'members': fields.List(
        fields.Nested(member_fields, description='The organization members')),
    'badges': fields.List(fields.Nested(badge_fields),
                          description='The organization badges',
                          readonly=True),
})

org_page_fields = api.model('OrganizationPage', fields.pager(org_fields))

org_suggestion_fields = api.model('OrganizationSuggestion', {
    'id': fields.String(
        description='The organization identifier', readonly=True),
    'name': fields.String(description='The organization name', readonly=True),
    'acronym': fields.String(
        description='The organization acronym', readonly=True),
    'slug': fields.String(
        description='The organization permalink string', readonly=True),
    'image_url': fields.String(
        description='The organization logo URL', readonly=True),
    'page': fields.UrlFor(
        'organizations.show_redirect', lambda o: {'org': o['slug']},
        description='The organization web page URL', readonly=True),
    'score': fields.Float(
Exemplo n.º 9
0
    'id': fields.String(description='The job execution ID', required=True),
    'created': fields.ISODateTime(description='The job creation date',
                                  required=True),
    'started': fields.ISODateTime(description='The job start date'),
    'ended': fields.ISODateTime(description='The job end date'),
    'status': fields.String(description='The job status',
                            required=True, enum=HARVEST_JOB_STATUS.keys()),
    'errors': fields.List(fields.Nested(error_fields),
                          description='The job initialization errors'),
    'items': fields.List(fields.Nested(item_fields),
                         description='The job collected items'),
    'source': fields.String(description='The source owning the job',
                            required=True),
})

job_page_fields = api.model('HarvestJobPage', fields.pager(job_fields))

validation_fields = api.model('HarvestSourceValidation', {
    'state': fields.String(description='Is it validated or not',
                           enum=VALIDATION_STATES.keys(),
                           required=True),
    'by': fields.Nested(user_ref_fields, allow_null=True, readonly=True,
                        description='Who performed the validation'),
    'on': fields.ISODateTime(readonly=True,
            description='Date date on which validation was performed'),
    'comment': fields.String(
        description='A comment about the validation. Required on rejection'
    )
})

source_fields = api.model('HarvestSource', {
Exemplo n.º 10
0
        'uri':
        fields.UrlFor('api.topic',
                      lambda o: {'topic': o},
                      description='The topic API URI',
                      readonly=True),
        'page':
        fields.UrlFor('topics.display',
                      lambda o: {'topic': o},
                      description='The topic page URL',
                      readonly=True),
    },
    mask=
    '*,datasets{id,title,uri,page},reuses{id,title, image, image_thumbnail,uri,page}'
)

topic_page_fields = api.model('TopicPage', fields.pager(topic_fields))

parser = api.page_parser()


@ns.route('/', endpoint='topics')
class TopicsAPI(API):
    @api.doc('list_topics')
    @api.expect(parser)
    @api.marshal_with(topic_page_fields)
    def get(self):
        '''List all topics'''
        args = parser.parse_args()
        return (Topic.objects.order_by('-created').paginate(
            args['page'], args['page_size']))
Exemplo n.º 11
0
    'image': fields.ImageField(description='The reuse thumbnail'),
    'created_at': fields.ISODateTime(description='The reuse creation date', readonly=True),
    'last_modified': fields.ISODateTime(description='The reuse last modification date', readonly=True),
    'deleted': fields.ISODateTime(description='The organization identifier', readonly=True),
    'datasets': fields.List(fields.Nested(dataset_ref_fields), description='The reused datasets'),
    'organization': fields.Nested(org_ref_fields, allow_null=True,
        description='The publishing organization', readonly=True),
    'owner': fields.Nested(user_ref_fields, description='The owner user', readonly=True, allow_null=True),
    'metrics': fields.Raw(description='The reuse metrics', readonly=True),
    'uri': fields.UrlFor('api.reuse', lambda o: {'reuse': o},
        description='The reuse API URI', readonly=True),
    'page': fields.UrlFor('reuses.show', lambda o: {'reuse': o},
        description='The reuse page URL', readonly=True),
})

reuse_page_fields = api.model('ReusePage', fields.pager(reuse_fields))

reuse_suggestion_fields = api.model('ReuseSuggestion', {
    'id': fields.String(description='The reuse identifier', readonly=True),
    'title': fields.String(description='The reuse title', readonly=True),
    'slug': fields.String(description='The reuse permalink string', readonly=True),
    'image_url': fields.String(description='The reuse thumbnail URL'),
    'score': fields.Float(description='The internal match score', readonly=True),
})


reuse_ref_fields = api.inherit('ReuseReference', base_reference, {
    'title': fields.String(description='The reuse title', readonly=True),
    'image': fields.ImageField(description='The reuse thumbnail'),
    'uri': fields.UrlFor('api.reuse', lambda o: {'reuse': o},
        description='The reuse API URI', readonly=True),
Exemplo n.º 12
0
        description='The topic last modification date', readonly=True),
    'deleted': fields.ISODateTime(
        description='The organization identifier', readonly=True),
    'owner': fields.Nested(
        user_ref_fields, description='The owner user', readonly=True,
        allow_null=True),
    'uri': fields.UrlFor(
        'api.topic', lambda o: {'topic': o},
        description='The topic API URI', readonly=True),
    'page': fields.UrlFor(
        'topics.display', lambda o: {'topic': o},
        description='The topic page URL', readonly=True),
}, mask='*,datasets{id,title,uri,page},reuses{id,title, image, image_thumbnail,uri,page}')


topic_page_fields = api.model('TopicPage', fields.pager(topic_fields))

parser = api.page_parser()


@ns.route('/', endpoint='topics')
class TopicsAPI(API):

    @api.doc('list_topics')
    @api.expect(parser)
    @api.marshal_with(topic_page_fields)
    def get(self):
        '''List all topics'''
        args = parser.parse_args()
        return (Topic.objects.order_by('-created')
                             .paginate(args['page'], args['page_size']))
Exemplo n.º 13
0
follow_fields = api.model(
    'Follow', {
        'id':
        fields.String(description='The follow object technical ID',
                      readonly=True),
        'follower':
        fields.Nested(
            user_ref_fields, description='The follower', readonly=True),
        'since':
        fields.ISODateTime(
            description='The date from which the user started following',
            readonly=True)
    })

follow_page_fields = api.model('FollowPage', fields.pager(follow_fields))

parser = api.parser()
parser.add_argument('page',
                    type=int,
                    default=1,
                    location='args',
                    help='The page to fetch')
parser.add_argument('page_size',
                    type=int,
                    default=20,
                    location='args',
                    help='The page size to fetch')

NOTE = 'Returns the number of followers left after the operation'
Exemplo n.º 14
0
        'dataset':
        fields.Nested(dataset_ref_fields,
                      allow_null=True,
                      description='Reference to the associated dataset'),
        'organization':
        fields.Nested(org_ref_fields,
                      allow_null=True,
                      description='The producer organization'),
        'owner':
        fields.Nested(user_ref_fields,
                      allow_null=True,
                      description='The user information')
    })

community_resource_page_fields = api.model(
    'CommunityResourcePage', fields.pager(community_resource_fields))

#: Default mask to make it lightweight by default
DEFAULT_MASK = ','.join(
    ('id', 'title', 'acronym', 'slug', 'description', 'created_at',
     'last_modified', 'deleted', 'private', 'tags', 'badges', 'resources',
     'frequency', 'frequency_date', 'extras', 'metrics', 'organization',
     'owner', 'temporal_coverage', 'spatial', 'license', 'uri', 'page',
     'last_update'))

dataset_fields = api.model('Dataset', {
    'id':
    fields.String(description='The dataset identifier', readonly=True),
    'title':
    fields.String(description='The dataset title', required=True),
    'acronym':
Exemplo n.º 15
0
        description='The activity target object class name', required=True),
    'related_to_url': fields.String(
        attribute='related_to.display_url',
        description='The activity target model', required=True),
    'created_at': fields.ISODateTime(
        description='When the action has been performed', readonly=True),
    'label': fields.String(
        description='The label of the activity', required=True),
    'key': fields.String(
        description='The key of the activity', required=True),
    'icon': fields.String(
        description='The icon of the activity', required=True),
    'kwargs': fields.Raw(description='Some action specific context'),
})

activity_page_fields = api.model('ActivityPage', fields.pager(activity_fields))

activity_parser = api.page_parser()
activity_parser.add_argument(
    'user', type=str, help='Filter activities for that particular user',
    location='args')
activity_parser.add_argument(
    'organization', type=str,
    help='Filter activities for that particular organization',
    location='args')


@api.route('/activity', endpoint='activity')
class SiteActivityAPI(API):
    @api.doc('activity', parser=activity_parser)
    @api.marshal_list_with(activity_page_fields)
Exemplo n.º 16
0
                             required=True),
    'subject': fields.Nested(api.model_reference,
                             description='The discussion target object',
                             required=True),
    'extras': fields.Raw(description='Extras attributes as key-value pairs'),
})

comment_discussion_fields = api.model('DiscussionResponse', {
    'comment': fields.String(
        description='The comment to submit', required=True),
    'close': fields.Boolean(
        description='Is this a closing response. Only subject owner can close')
})

discussion_page_fields = api.model('DiscussionPage',
                                   fields.pager(discussion_fields))

parser = api.parser()
parser.add_argument(
    'sort', type=str, default='-created', location='args',
    help='The sorting attribute')
parser.add_argument(
    'closed', type=boolean, location='args',
    help='Filters discussions on their closed status if specified')
parser.add_argument(
    'for', type=str, location='args', action='append',
    help='Filter discussions for a given subject')
parser.add_argument(
    'page', type=int, default=1, location='args', help='The page to fetch')
parser.add_argument(
    'page_size', type=int, default=20, location='args',
Exemplo n.º 17
0
            attribute="related_to.__class__.__name__",
            description="The activity target object class name",
            required=True,
        ),
        "related_to_url": fields.String(
            attribute="related_to.display_url", description="The activity target model", required=True
        ),
        "created_at": fields.ISODateTime(description="When the action has been performed", readonly=True),
        "label": fields.String(description="The label of the activity", required=True),
        "key": fields.String(description="The key of the activity", required=True),
        "icon": fields.String(description="The icon of the activity", required=True),
        "kwargs": fields.Raw(description="Some action specific context"),
    },
)

activity_page_fields = api.model("ActivityPage", fields.pager(activity_fields))

activity_parser = api.page_parser()
activity_parser.add_argument("user", type=unicode, help="Filter activities for that particular user", location="args")
activity_parser.add_argument(
    "organization", type=unicode, help="Filter activities for that particular organization", location="args"
)


@api.route("/activity", endpoint="activity")
class SiteActivityAPI(API):
    @api.doc("activity", parser=activity_parser)
    @api.marshal_list_with(activity_page_fields)
    def get(self):
        """Fetch site activity, optionally filterd by user of org."""
        args = activity_parser.parse_args()
Exemplo n.º 18
0
})

community_resource_fields = api.inherit('CommunityResource', resource_fields, {
    'dataset': fields.Nested(
        dataset_ref_fields, allow_null=True,
        description='Reference to the associated dataset'),
    'organization': fields.Nested(
        org_ref_fields, allow_null=True,
        description='The producer organization'),
    'owner': fields.Nested(
        user_ref_fields, allow_null=True,
        description='The user information')
})

community_resource_page_fields = api.model(
    'CommunityResourcePage', fields.pager(community_resource_fields))

dataset_fields = api.model('Dataset', {
    'id': fields.String(description='The dataset identifier', readonly=True),
    'title': fields.String(description='The dataset title', required=True),
    'slug': fields.String(
        description='The dataset permalink string', required=True),
    'description': fields.Markdown(
        description='The dataset description in markdown', required=True),
    'created_at': fields.ISODateTime(
        description='The dataset creation date', required=True),
    'last_modified': fields.ISODateTime(
        description='The dataset last modification date', required=True),
    'deleted': fields.ISODateTime(description='The deletion date if deleted'),
    'featured': fields.Boolean(description='Is the dataset featured'),
    'private': fields.Boolean(
Exemplo n.º 19
0
                           readonly=True),
        'closed':
        fields.ISODateTime(description='The issue closing date',
                           readonly=True),
        'closed_by':
        fields.String(attribute='closed_by.id',
                      description='The user who closed the issue',
                      readonly=True),
        'discussion':
        fields.Nested(message_fields),
        'url':
        fields.UrlFor(
            'api.issue', description='The issue API URI', readonly=True),
    })

issue_page_fields = api.model('IssuePage', fields.pager(issue_fields))

parser = api.parser()
parser.add_argument('closed',
                    type=bool,
                    default=False,
                    location='args',
                    help='Filter closed issues')
parser.add_argument('page',
                    type=int,
                    default=1,
                    location='args',
                    help='The page to fetch')
parser.add_argument('page_size',
                    type=int,
                    default=20,
Exemplo n.º 20
0
               readonly=True),
    'uri':
    fields.UrlFor('api.reuse',
                  lambda o: {'reuse': o},
                  description='The reuse API URI',
                  readonly=True),
    'page':
    fields.UrlFor('reuses.show',
                  lambda o: {'reuse': o},
                  description='The reuse page URL',
                  readonly=True,
                  fallback_endpoint='api.reuse'),
},
                         mask='*,datasets{title,uri,page}')

reuse_page_fields = api.model('ReusePage', fields.pager(reuse_fields))

reuse_suggestion_fields = api.model(
    'ReuseSuggestion', {
        'id':
        fields.String(description='The reuse identifier', readonly=True),
        'title':
        fields.String(description='The reuse title', readonly=True),
        'slug':
        fields.String(description='The reuse permalink string', readonly=True),
        'image_url':
        fields.String(description='The reuse thumbnail URL'),
        'page':
        fields.UrlFor('reuses.show_redirect',
                      lambda o: {'reuse': o['slug']},
                      description='The reuse page URL',
Exemplo n.º 21
0
    'since': fields.ISODateTime(
        attribute='created_at',
        description='The registeration date', required=True),
    'page': fields.UrlFor(
        'users.show', lambda u: {'user': u},
        description='The user profile page URL', readonly=True),
    'uri': fields.UrlFor(
        'api.user', lambda o: {'user': o},
        description='The user API URI', required=True),
})

me_fields = api.inherit('Me', user_fields, {
    'email': fields.String(description='The user email', required=True)
})

user_page_fields = api.model('UserPage', fields.pager(user_fields))

user_suggestion_fields = api.model('UserSuggestion', {
    'id': fields.String(description='The user identifier', required=True),
    'fullname': fields.String(description='The user fullname', required=True),
    'avatar_url': fields.String(description='The user avatar URL'),
    'slug': fields.String(
        description='The user permalink string', required=True),
    'score': fields.Float(
        description='The internal match score', required=True),
})


notifications_fields = api.model('Notification', {
    'type': fields.String(description='The notification type', readonly=True),
    'created_on': fields.ISODateTime(
Exemplo n.º 22
0
                      description='The user who performed the action',
                      readonly=True),
        'organization':
        fields.Nested(org_ref_fields,
                      allow_null=True,
                      readonly=True,
                      description='The organization who performed the action'),
        # 'related_to'
        # related_to = db.ReferenceField(db.DomainModel, required=True)
        'created_at':
        fields.ISODateTime(description='When the action has been performed',
                           readonly=True),
        'kwargs':
        fields.Raw(description='Some action specific context'),
    })

activity_page_fields = api.model('ActivityPage', fields.pager(activity_fields))

activity_parser = api.page_parser()


@api.route('/site/activity', endpoint='site_activity')
class SiteActivityAPI(API):
    @api.doc('site_activity', parser=activity_parser)
    @api.marshal_list_with(activity_page_fields)
    def get(self):
        '''Fetch site activity'''
        args = activity_parser.parse_args()
        return Activity.objects.order_by('-created').paginate(
            args['page'], args['page_size'])
Exemplo n.º 23
0
    'closed_by': fields.String(
        attribute='closed_by.id',
        description='The user who closed the issue', readonly=True),
    'discussion': fields.Nested(message_fields),
    'url': fields.UrlFor(
        'api.issue', description='The issue API URI', readonly=True),
})

comment_issue_fields = api.model('IssueResponse', {
    'comment': fields.String(
        description='The comment to submit', required=True),
    'close': fields.Boolean(
        description='Is this a closing response. Only subject owner can close')
})

issue_page_fields = api.model('IssuePage', fields.pager(issue_fields))

parser = api.parser()
parser.add_argument(
    'sort', type=str, default='-created', location='args',
    help='The sorting attribute')
parser.add_argument(
    'closed', type=boolean, location='args',
    help='Filter closed issues. Filters issues on their closed status'
    ' if specified')
parser.add_argument(
    'for', type=str, location='args', action='append',
    help='Filter issues for a given subject')
parser.add_argument(
    'page', type=int, default=1, location='args', help='The page to fetch')
parser.add_argument(
Exemplo n.º 24
0
        fields.String(attribute='license.id',
                      default=DEFAULT_LICENSE['id'],
                      description='The dataset license'),
        'uri':
        fields.UrlFor('api.dataset',
                      lambda o: {'dataset': o},
                      description='The dataset API URI',
                      required=True),
        'page':
        fields.UrlFor('datasets.show',
                      lambda o: {'dataset': o},
                      description='The dataset page URL',
                      required=True),
    })

dataset_page_fields = api.model('DatasetPage', fields.pager(dataset_fields))

dataset_suggestion_fields = api.model(
    'DatasetSuggestion', {
        'id':
        fields.String(description='The dataset identifier', required=True),
        'title':
        fields.String(description='The dataset title', required=True),
        'slug':
        fields.String(description='The dataset permalink string',
                      required=True),
        'image_url':
        fields.String(description='The dataset (organization) logo URL'),
        'page':
        fields.UrlFor('datasets.show_redirect',
                      lambda d: {'dataset': d['slug']},
Exemplo n.º 25
0
})

community_resource_fields = api.inherit('CommunityResource', resource_fields, {
    'dataset': fields.Nested(
        dataset_ref_fields, allow_null=True,
        description='Reference to the associated dataset'),
    'organization': fields.Nested(
        org_ref_fields, allow_null=True,
        description='The producer organization'),
    'owner': fields.Nested(
        user_ref_fields, allow_null=True,
        description='The user information')
})

community_resource_page_fields = api.model(
    'CommunityResourcePage', fields.pager(community_resource_fields))

#: Default mask to make it lightweight by default
DEFAULT_MASK = ','.join((
    'id', 'title', 'slug', 'description', 'created_at', 'last_modified', 'deleted',
    'private', 'tags', 'badges', 'resources', 'frequency', 'frequency_date', 'extras',
    'metrics', 'organization', 'owner', 'temporal_coverage', 'spatial', 'license',
    'uri', 'page', 'last_update'
))

dataset_fields = api.model('Dataset', {
    'id': fields.String(description='The dataset identifier', readonly=True),
    'title': fields.String(description='The dataset title', required=True),
    'slug': fields.String(
        description='The dataset permalink string', required=True),
    'description': fields.Markdown(
Exemplo n.º 26
0
                      description='The discussion target object',
                      required=True),
    })

comment_discussion_fields = api.model(
    'DiscussionResponse', {
        'comment':
        fields.String(description='The comment to submit', required=True),
        'close':
        fields.Boolean(
            description=
            'Is this a closing response. Only subject owner can close')
    })

discussion_page_fields = api.model('DiscussionPage',
                                   fields.pager(discussion_fields))

parser = api.parser()
parser.add_argument('sort',
                    type=str,
                    default='-created',
                    location='args',
                    help='The sorting attribute')
parser.add_argument(
    'closed',
    type=boolean,
    location='args',
    help='Filters discussions on their closed status if specified')
parser.add_argument('for',
                    type=str,
                    location='args',
Exemplo n.º 27
0
                          description='The dataset resources')),
        'next_page':
        fields.String(),
        'previous_page':
        fields.String(),
        'page':
        fields.Integer(),
        'page_size':
        fields.Integer(),
        'total':
        fields.Integer()
    })

dataset_page_fields = apiv2.model(
    'DatasetPage',
    fields.pager(dataset_fields),
    mask='data{{{0}}},*'.format(DEFAULT_MASK_APIV2))

specific_resource_fields = apiv2.model(
    'SpecificResource', {
        'resource':
        fields.Nested(resource_fields, description='The dataset resources'),
        'dataset_id':
        fields.String()
    })

apiv2.inherit('Badge', badge_fields)
apiv2.inherit('OrganizationReference', org_ref_fields)
apiv2.inherit('UserReference', user_ref_fields)
apiv2.inherit('Resource', resource_fields)
apiv2.inherit('SpatialCoverage', spatial_coverage_fields)