Beispiel #1
0
                                   '(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',
                      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':
Beispiel #2
0
    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(attribute=lambda o: o.get_metrics(),
               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,
                  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':
Beispiel #3
0
        '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):
Beispiel #4
0
        fields.Nested(dataset_fields), description='The post datasets'),
    'reuses': fields.List(
        fields.Nested(reuse_fields), description='The post reuses'),

    'owner': fields.Nested(
        user_ref_fields, description='The owner user',
        readonly=True, allow_null=True),
    'created_at': fields.ISODateTime(
        description='The post creation date', readonly=True),
    'last_modified': fields.ISODateTime(
        description='The post last modification date', readonly=True),
    'published': fields.ISODateTime(
        description='The post publication 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, fallback_endpoint='api.post'),
}, mask='*,datasets{id,title,acronym,uri,page},reuses{id,title,image,image_thumbnail,uri,page}')

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

parser = api.page_parser()

parser.add_argument('sort', type=str, default='-created_at', location='args',
                    help='The sorting attribute')


@ns.route('/', endpoint='posts')
Beispiel #5
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields, base_reference
from udata.core.badges.api import badge_fields

from .models import ORG_ROLES, MEMBERSHIP_STATUS


org_ref_fields = api.inherit('OrganizationReference', base_reference, {
    'name': fields.String(description='The organization name', readonly=True),
    'acronym': fields.String(description='The organization acronym'),
    'uri': fields.UrlFor(
        'api.organization', lambda o: {'org': o},
        description='The organization API URI', readonly=True),
    'slug': fields.String(
        description='The organization string used as permalink',
        required=True),
    'page': fields.UrlFor(
        'organizations.show', lambda o: {'org': o},
        description='The organization web page URL', readonly=True),
    'logo': fields.ImageField(
        size=100, description='The organization logo URL'),
})


from udata.core.user.api_fields import user_ref_fields  # noqa: required

request_fields = api.model('MembershipRequest', {
    'id': fields.String(readonly=True),
    'user': fields.Nested(user_ref_fields),
Beispiel #6
0
                    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':
Beispiel #7
0
    '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'),
    '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',
                             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, fallback_endpoint='api.dataset'),
    'quality': fields.Raw(description='The dataset quality', readonly=True),
    'last_update': fields.ISODateTime(
        description='The resources last modification date', required=True),
}, mask=DEFAULT_MASK_APIV2)


resource_page_fields = apiv2.model('ResourcePage', {
    'data': fields.List(
        fields.Nested(resource_fields, description='The dataset resources')
    ),
    'next_page': fields.String(),
Beispiel #8
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields, base_reference

from .models import ORG_ROLES, MEMBERSHIP_STATUS

org_ref_fields = api.inherit(
    'OrganizationReference', base_reference, {
        'name':
        fields.String(description='The organization name', 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 web page URL',
                      readonly=True),
        'logo':
        fields.ImageField(size=100, description='The organization logo URL'),
    })

from udata.core.user.api_fields import user_ref_fields

request_fields = api.model(
    'MembershipRequest', {
        'id':
        fields.String(readonly=True),
Beispiel #9
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields, base_reference


user_ref_fields = api.inherit('UserReference', base_reference, {
    'first_name': fields.String(
        description='The user first name', readonly=True),
    'last_name': fields.String(
        description='The user larst name', readonly=True),
    'slug': fields.String(
        description='The user permalink string', 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),
    'avatar': fields.ImageField(size=100, description='The user avatar URL'),
})


from udata.core.organization.api_fields import org_ref_fields

user_fields = api.model('User', {
    'id': fields.String(
        description='The user identifier', required=True),
    'slug': fields.String(
        description='The user permalink string', required=True),
    'first_name': fields.String(
Beispiel #10
0
        fields.ISODateTime(description='The topic creation date',
                           readonly=True),
        'last_modified':
        fields.ISODateTime(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()
Beispiel #11
0
from .models import AVATAR_SIZES

BIGGEST_AVATAR_SIZE = AVATAR_SIZES[0]

user_ref_fields = api.inherit(
    'UserReference', base_reference, {
        'first_name':
        fields.String(description='The user first name', readonly=True),
        'last_name':
        fields.String(description='The user larst name', readonly=True),
        'slug':
        fields.String(description='The user permalink string', required=True),
        'page':
        fields.UrlFor('users.show',
                      lambda u: {'user': u},
                      description='The user profile page URL',
                      readonly=True,
                      fallback_endpoint='api.user'),
        'uri':
        fields.UrlFor('api.user',
                      lambda o: {'user': o},
                      description='The user API URI',
                      required=True),
        'avatar':
        fields.ImageField(original=True, description='The user avatar URL'),
        'avatar_thumbnail':
        fields.ImageField(
            attribute='avatar',
            size=BIGGEST_AVATAR_SIZE,
            description='The user avatar thumbnail URL. This is the square '
            '({0}x{0}) and cropped version.'.format(BIGGEST_AVATAR_SIZE)),
Beispiel #12
0
from udata.api import api, fields, base_reference
from udata.core.badges.api import badge_fields

from .models import ORG_ROLES, DEFAULT_ROLE, MEMBERSHIP_STATUS, LOGO_SIZES

BIGGEST_LOGO_SIZE = LOGO_SIZES[0]

org_ref_fields = api.inherit(
    'OrganizationReference', base_reference, {
        'name':
        fields.String(description='The organization name', readonly=True),
        'acronym':
        fields.String(description='The organization acronym'),
        'uri':
        fields.UrlFor('api.organization',
                      lambda o: {'org': o},
                      description='The organization API URI',
                      readonly=True),
        'slug':
        fields.String(description='The organization string used as permalink',
                      required=True),
        'page':
        fields.UrlFor('organizations.show',
                      lambda o: {'org': o},
                      description='The organization web page URL',
                      readonly=True,
                      fallback_endpoint='api.organization'),
        'logo':
        fields.ImageField(original=True,
                          description='The organization logo URL'),
        'logo_thumbnail':
        fields.ImageField(
Beispiel #13
0
        fields.Nested(dataset_fields), description='The topic datasets'),
    'reuses': fields.List(
        fields.Nested(reuse_fields), description='The topic reuses'),
    'featured': fields.Boolean(description='Is the topic featured'),
    'private': fields.Boolean(description='Is the topic private'),
    'created_at': fields.ISODateTime(
        description='The topic creation date', readonly=True),
    'last_modified': fields.ISODateTime(
        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, fallback_endpoint='api.topic'),
}, 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):
Beispiel #14
0
                      required=True),
        'created':
        fields.ISODateTime(description='The discussion creation date',
                           readonly=True),
        'closed':
        fields.ISODateTime(description='The discussion closing date',
                           readonly=True),
        'closed_by':
        fields.String(attribute='closed_by.id',
                      description='The user who closed the discussion',
                      readonly=True),
        'discussion':
        fields.Nested(message_fields),
        'url':
        fields.UrlFor('api.discussion',
                      description='The discussion API URI',
                      readonly=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))
Beispiel #15
0
    })

source_page_fields = api.model('HarvestSourcePage',
                               fields.pager(source_fields))

backend_fields = api.model(
    'HarvestBackend', {
        'id': fields.String(description='The backend identifier'),
        'label': fields.String(description='The backend display name')
    })

preview_dataset_fields = api.clone(
    'DatasetPreview', dataset_fields, {
        'uri':
        fields.UrlFor('api.dataset',
                      lambda o: {'dataset': 'not-available'},
                      description='The dataset API URI (fake)'),
        'page':
        fields.UrlFor('datasets.show',
                      lambda o: {'dataset': 'not-available'},
                      description='The dataset page URL (fake)'),
    })

preview_item_fields = api.clone(
    'HarvestItemPreview', item_fields, {
        'dataset':
        fields.Nested(preview_dataset_fields,
                      description='The processed dataset',
                      allow_null=True),
    })
Beispiel #16
0
        fields.Nested(
            user_ref_fields, description='The issue author', required=True),
        'created':
        fields.ISODateTime(description='The issue creation date',
                           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')
Beispiel #17
0
        fields.ClassName(description='The object class', discriminator=True),
        'title':
        fields.String(description='The discussion title'),
        'user':
        fields.Nested(user_ref_fields, description='The discussion author'),
        'created':
        fields.ISODateTime(description='The discussion creation date'),
        'closed':
        fields.ISODateTime(description='The discussion closing date'),
        'closed_by':
        fields.String(attribute='closed_by.id',
                      description='The user who closed the discussion'),
        'discussion':
        fields.Nested(message_fields),
        'url':
        fields.UrlFor('api.discussion', description='The discussion API URI'),
    })

start_discussion_fields = api.model(
    'DiscussionStart', {
        'title':
        fields.String(description='The title of the discussion to open',
                      required=True),
        'comment':
        fields.String(description='The content of the initial comment',
                      required=True),
        'subject':
        fields.Nested(api.model_reference,
                      description='The discussion target object',
                      required=True),
    })
Beispiel #18
0
        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'),
    'page': fields.UrlFor(