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), 'created': fields.ISODateTime(
# -*- 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), '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( description='The user first name', required=True), 'last_name': fields.String(
description='The resource last modification date'), 'metrics': fields.Raw(description='The resource metrics', readonly=True), 'extras': fields.Raw(description='Extra attributes as key-value pairs'), 'preview_url': fields.String(description='An optionnal preview URL to be ' 'loaded as a standalone page (ie. iframe or ' 'new page)', readonly=True), }) upload_fields = api.inherit( 'UploadedResource', resource_fields, { 'success': fields.Boolean(description='Whether the upload succeeded or not.', readonly=True, default=True), }) resources_order = api.as_list(fields.String(description='Resource ID')) temporal_coverage_fields = api.model( 'TemporalCoverage', { 'start': fields.ISODateTime(description='The temporal coverage start date', required=True), 'end': fields.ISODateTime(description='The temporal coverage end date', required=True), })
# -*- 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(
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(original=True, description='The organization logo URL'), 'logo_thumbnail': fields.ImageField( attribute='logo', size=BIGGEST_LOGO_SIZE, description= 'The organization logo thumbnail URL. This is the square ' '({0}x{0}) and cropped version.'.format(BIGGEST_LOGO_SIZE)), })
# -*- 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), 'user': fields.Nested(user_ref_fields), 'created': fields.ISODateTime(description='The request creation date', readonly=True), 'status': fields.String(description='The current request status', required=True, enum=MEMBERSHIP_STATUS.keys()), 'comment': fields.String(description='A request comment from the user', required=True), }) member_fields = api.model('Member', { 'user': fields.Nested(user_ref_fields),
'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', readonly=True), '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 thumbnail (cropped) URL'), 'image_thumbnail': fields.ImageField(attribute='image', size=BIGGEST_IMAGE_SIZE, description='The reuse thumbnail thumbnail URL. This is the square ' '({0}x{0}) and cropped version.'.format(BIGGEST_IMAGE_SIZE)), '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_type_fields = api.model('ReuseType', { 'id': fields.String(description='The reuse type identifier'), 'label': fields.String(description='The reuse type display name') })
'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), 'page': fields.UrlFor('reuses.show', lambda o: {'reuse': o}, description='The reuse page URL', readonly=True), }) image_fields = api.model('UploadedImage', { 'success': fields.Boolean(description='Whether the upload succeeded or not.', readonly=True, default=True), 'image': fields.ImageField(), })
'published': fields.ISODateTime( description='The resource publication date'), 'last_modified': fields.ISODateTime( attribute='modified', readonly=True, description='The resource last modification date'), 'metrics': fields.Raw(description='The resource metrics', readonly=True), 'extras': fields.Raw(description='Extra attributes as key-value pairs'), 'preview_url': fields.String(description='An optionnal preview URL to be ' 'loaded as a standalone page (ie. iframe or ' 'new page)', readonly=True), }) upload_fields = api.inherit('UploadedResource', resource_fields, { 'success': fields.Boolean( description='Whether the upload succeeded or not.', readonly=True, default=True), }) resources_order = api.as_list(fields.String(description='Resource ID')) temporal_coverage_fields = api.model('TemporalCoverage', { 'start': fields.ISODateTime(description='The temporal coverage start date', required=True), 'end': fields.ISODateTime(description='The temporal coverage end date', required=True), }) dataset_ref_fields = api.inherit('DatasetReference', base_reference, { 'title': fields.String(description='The dataset title', readonly=True), 'acronym': fields.String(description='An optionnal dataset acronym',
lambda o: {'reuse': o['slug']}, description='The reuse page URL', readonly=True), '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), 'page': fields.UrlFor('reuses.show', lambda o: {'reuse': o}, description='The reuse page URL', readonly=True), }) reuse_type_fields = api.model( 'ReuseType', { 'id': fields.String(description='The reuse type identifier'), 'label': fields.String(description='The reuse type display name') })
from udata.api import api, fields, base_reference from udata.core.badges.api import badge_fields from udata.i18n import lazy_gettext as _ 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), 'created': fields.ISODateTime(
'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), })
'start': fields.ISODateTime(description='The temporal coverage start date', required=True), 'end': fields.ISODateTime(description='The temporal coverage end date', 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), }) community_resource_fields = api.inherit( 'CommunityResource', resource_fields, { 'dataset': fields.Nested(dataset_ref_fields, allow_null=True, description='Reference to the associated dataset'), 'organization':
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), '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)), }) from udata.core.organization.api_fields import org_ref_fields # noqa user_fields = api.model('User', { 'id': fields.String(
}) resources_order = api.as_list(fields.String(description='Resource ID')) temporal_coverage_fields = api.model('TemporalCoverage', { 'start': fields.ISODateTime(description='The temporal coverage start date', required=True), 'end': fields.ISODateTime(description='The temporal coverage end date', 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), }) 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')
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)), }) from udata.core.organization.api_fields import org_ref_fields # noqa
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 thumbnail (cropped) URL'), 'image_thumbnail': fields.ImageField( attribute='image', size=BIGGEST_IMAGE_SIZE, description='The reuse thumbnail thumbnail URL. This is the square ' '({0}x{0}) and cropped version.'.format(BIGGEST_IMAGE_SIZE)), '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'), }) reuse_type_fields = api.model( 'ReuseType', {
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), 'logo': fields.ImageField(original=True, description='The organization logo URL'), 'logo_thumbnail': fields.ImageField(attribute='logo', size=BIGGEST_LOGO_SIZE, description='The organization logo thumbnail URL. This is the square ' '({0}x{0}) and cropped version.'.format(BIGGEST_LOGO_SIZE)), }) 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),
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']}, description='The web page URL for this dataset', readonly=True), '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), })
temporal_coverage_fields = api.model( "TemporalCoverage", { "start": fields.ISODateTime(description="The temporal coverage start date", required=True), "end": fields.ISODateTime(description="The temporal coverage end date", 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 ), }, ) 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"),