Ejemplo n.º 1
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields, base_reference

from udata.core.organization.api_fields import org_ref_fields
from udata.core.dataset.api_fields import dataset_ref_fields
from udata.core.user.api_fields import user_ref_fields

from .models import REUSE_TYPES

reuse_fields = api.model(
    'Reuse', {
        'id':
        fields.String(description='The reuse identifier', readonly=True),
        'title':
        fields.String(description='The reuse title', required=True),
        'slug':
        fields.String(description='The reuse permalink string', readonly=True),
        'type':
        fields.String(description='The reuse type',
                      required=True,
                      enum=REUSE_TYPES.keys()),
        'url':
        fields.String(description='The reuse remote URL (website)',
                      required=True),
        'description':
        fields.Markdown(description='The reuse description in Markdown',
                        required=True),
        'tags':
        fields.List(fields.String,
Ejemplo n.º 2
0
from udata.api import api, fields, API
from udata.auth import admin_permission

from udata.core.dataset.api_fields import dataset_ref_fields
from udata.core.reuse.api_fields import reuse_ref_fields
from udata.core.user.api_fields import user_ref_fields

from .models import Post
from .forms import PostForm

ns = api.namespace('posts', 'Posts related operations')

post_fields = api.model(
    'Post', {
        'id':
        fields.String(description='The post identifier'),
        'name':
        fields.String(description='The post name', required=True),
        'slug':
        fields.String(description='The post permalink string', readonly=True),
        'headline':
        fields.String(description='The post headline', required=True),
        'content':
        fields.Markdown(description='The post content in Markdown',
                        required=True),
        'image':
        fields.ImageField(description='The post image'),
        'credit_to':
        fields.String(
            description='An optionnal credit line (associated to the image)'),
        'credit_url':
Ejemplo n.º 3
0
                     VALIDATION_STATES, VALIDATION_ACCEPTED)

ns = api.namespace('harvest', 'Harvest related operations')


def backends_ids():
    return [b.name for b in actions.list_backends()]


error_fields = api.model(
    'HarvestError', {
        'created_at':
        fields.ISODateTime(description='The error creation date',
                           required=True),
        'message':
        fields.String(description='The error short message', required=True),
        'details':
        fields.String(description='Optionnal details (ie. stacktrace)'),
    })

item_fields = api.model(
    'HarvestItem', {
        'remote_id':
        fields.String(description='The item remote ID to process',
                      required=True),
        'dataset':
        fields.Nested(dataset_ref_fields,
                      description='The processed dataset',
                      allow_null=True),
        'status':
        fields.String(description='The item status',
Ejemplo n.º 4
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),
Ejemplo n.º 5
0
from udata.api import api, fields, base_reference

from udata.core.badges.api import badge_fields
from udata.core.dataset.api_fields import dataset_fields
from udata.core.organization.api_fields import org_ref_fields
from udata.core.user.api_fields import user_ref_fields

from .models import REUSE_TOPICS, REUSE_TYPES, IMAGE_SIZES

BIGGEST_IMAGE_SIZE = IMAGE_SIZES[0]

reuse_fields = api.model('Reuse', {
    'id':
    fields.String(description='The reuse identifier', readonly=True),
    'title':
    fields.String(description='The reuse title', required=True),
    'slug':
    fields.String(description='The reuse permalink string', readonly=True),
    'type':
    fields.String(
        description='The reuse type', required=True, enum=list(REUSE_TYPES)),
    'url':
    fields.String(description='The reuse remote URL (website)', required=True),
    'description':
    fields.Markdown(description='The reuse description in Markdown',
                    required=True),
    'tags':
    fields.List(fields.String, description='Some keywords to help in search'),
    'badges':
    fields.List(fields.Nested(badge_fields),
                description='The reuse badges',
Ejemplo n.º 6
0
from udata.api import api, fields, base_reference
from udata.core.badges.api import badge_fields
from udata.core.organization.api_fields import org_ref_fields
from udata.core.spatial.api_fields import spatial_coverage_fields
from udata.core.user.api_fields import user_ref_fields

from .models import (UPDATE_FREQUENCIES, RESOURCE_FILETYPES, DEFAULT_FREQUENCY,
                     CHECKSUM_TYPES, DEFAULT_CHECKSUM_TYPE, DEFAULT_LICENSE,
                     RESOURCE_TYPES)

checksum_fields = api.model(
    'Checksum', {
        'type':
        fields.String(
            description='The hashing algorithm used to compute the checksum',
            default=DEFAULT_CHECKSUM_TYPE,
            enum=CHECKSUM_TYPES),
        'value':
        fields.String(description="The resulting checksum/hash", required=True)
    })

license_fields = api.model(
    'License', {
        'id': fields.String(description='The license identifier',
                            required=True),
        'title': fields.String(description='The resource title',
                               required=True),
        'maintainer':
        fields.String(description='The license official maintainer'),
        'url': fields.String(description='The license official URL'),
        'flags': fields.List(fields.String, description='Some arbitry flags'),
Ejemplo n.º 7
0
from bson import ObjectId
from datetime import date

from flask_restful.inputs import boolean

from udata.api import api, API, marshal, fields
from udata.models import Metrics

from udata.core.site.views import current_site

metrics_fields = api.model(
    'Metric', {
        'object_id':
        fields.String(
            description='The object identifier which metrics belongs to',
            required=True),
        'date':
        fields.String(description='The metrics sampling date', required=True),
        'level':
        fields.String(description='The metrics granularity level',
                      required=True,
                      enum=['daily', 'monthly']),
        'values':
        fields.Raw(description='The metrics as key-value pairs',
                   required=True),
    })


def isodate(value):
    return date(*(int(p) for p in value.split('-'))).isoformat()
Ejemplo n.º 8
0
from udata.api import api, fields, API
from udata.auth import admin_permission

from udata.core.dataset.api_fields import dataset_fields
from udata.core.reuse.api_fields import reuse_fields
from udata.core.user.api_fields import user_ref_fields

from .models import Topic
from .forms import TopicForm

ns = api.namespace('topics', 'Topics related operations')

topic_fields = api.model(
    'Topic', {
        'id':
        fields.String(description='The topic identifier'),
        'name':
        fields.String(description='The topic name', required=True),
        'slug':
        fields.String(description='The topic permalink string', readonly=True),
        'description':
        fields.Markdown(description='The topic description in Markdown',
                        required=True),
        'tags':
        fields.List(fields.String,
                    description='Some keywords to help in search',
                    required=True),
        'datasets':
        fields.List(fields.Nested(dataset_fields),
                    description='The topic datasets'),
        'reuses':
Ejemplo n.º 9
0
from udata.api import api, fields

from .forms import badge_form

badge_fields = api.model(
    'Badge', {
        'kind':
        fields.String(description=('Kind of badge (certified, etc), '
                                   'specific to each model'),
                      required=True),
    })


def add(obj):
    '''
    Handle a badge add API.

    - Expecting badge_fieds as payload
    - Return the badge as payload
    - Return 200 if the badge is already
    - Return 201 if the badge is added
    '''
    Form = badge_form(obj.__class__)
    form = api.validate(Form)
    kind = form.kind.data
    badge = obj.get_badge(kind)
    if badge:
        return badge
    else:
        return obj.add_badge(kind), 201
Ejemplo n.º 10
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, API, fields
from udata.auth import admin_permission

from . import actions
from .models import HARVEST_JOB_STATUS, HARVEST_ITEM_STATUS, HarvestJob

ns = api.namespace('harvest', 'Harvest related operations')

error_fields = api.model('HarvestError', {
    'created_at': fields.ISODateTime(description='The error creation date', required=True),
    'message': fields.String(description='The error short message', required=True),
    'details': fields.String(description='Optionnal details (ie. stacktrace)'),
})

item_fields = api.model('HarvestItem', {
    'remote_id': fields.String(description='The item remote ID to process', required=True),
    'status': fields.String(description='The item status', required=True, enum=HARVEST_ITEM_STATUS.keys()),
    'created': fields.ISODateTime(description='The item creation date', required=True),
    'started': fields.ISODateTime(description='The item start date'),
    'ended': fields.ISODateTime(description='The item end date'),
    'errors': api.as_list(fields.Nested(error_fields, description='The item errors')),
    'args': fields.List(fields.String, description='The item positional arguments', default=[]),
    'kwargs': fields.Raw(description='The item keyword arguments', default={}),
})

source_fields = api.model('HarvestSource', {
    'id': fields.String(description='The source unique identifier', required=True),
    'name': fields.String(description='The source display name', required=True),
Ejemplo n.º 11
0
from . import LEVELS
from udata import search
from udata.models import SPATIAL_GRANULARITIES, Territory, Dataset

GEOM_TYPES = ('Point', 'LineString', 'Polygon', 'MultiPoint',
              'MultiLineString', 'MultiPolygon')

ns = api.namespace('spatial', 'Spatial references')


@api.model(
    fields={
        'type':
        fields.String(description='The GeoJSON Type',
                      required=True,
                      enum=GEOM_TYPES),
        'coordinates':
        fields.List(fields.Raw(),
                    description='The geometry as coordinates lists',
                    required=True),
    })
class GeoJSON(fields.Raw):
    pass


feature_fields = api.model(
    'GeoJSONFeature', {
        'id': fields.String,
        'type': fields.String(required=True, enum=['Feature']),
        'geometry': GeoJSON(required=True),
Ejemplo n.º 12
0
from udata.api import api, fields, API
from udata.auth import current_user

from .actions import get_notifications

notifs = api.namespace('notifications', 'Notifications API')

notifications_fields = api.model(
    'Notification', {
        'type':
        fields.String(description='The notification type', readonly=True),
        'created_on':
        fields.ISODateTime(description='The notification creation datetime',
                           readonly=True),
        'details':
        fields.Raw(
            description='Key-Value details depending on notification type',
            readonly=True)
    })


@notifs.route('/', endpoint='notifications')
class NotificationsAPI(API):
    @api.secure
    @api.doc('get_notifications')
    @api.marshal_list_with(notifications_fields)
    def get(self):
        '''List all current user pending notifications'''
        user = current_user._get_current_object()
        return get_notifications(user)
Ejemplo n.º 13
0
from datetime import datetime

from flask import current_app, request
from flask_security import current_user

from udata import tracking
from udata.api import api, API, fields
from udata.models import Follow
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,
Ejemplo n.º 14
0
from udata.api import api, API, fields
from udata.models import Dataset, DatasetDiscussion, Reuse, ReuseDiscussion
from udata.core.user.api_fields import user_ref_fields

from .forms import DiscussionCreateForm, DiscussionCommentForm
from .models import Message, Discussion
from .permissions import CloseDiscussionPermission
from .signals import (on_new_discussion, on_new_discussion_comment,
                      on_discussion_closed, on_discussion_deleted)

ns = api.namespace('discussions', 'Discussion related operations')

message_fields = api.model(
    'DiscussionMessage', {
        'content':
        fields.String(description='The message body', required=True),
        'posted_by':
        fields.Nested(
            user_ref_fields, description='The message author', required=True),
        'posted_on':
        fields.ISODateTime(description='The message posting date',
                           required=True),
    })

discussion_fields = api.model(
    'Discussion', {
        'id':
        fields.String(description='The discussion identifier', readonly=True),
        'subject':
        fields.String(attribute='subject.id',
                      description='The discussion target object identifier',
Ejemplo n.º 15
0
RESPONSE_TYPES = ['accept', 'refuse']

transfer_request_fields = api.model(
    'TransferRequest', {
        'subject':
        fields.Nested(base_reference,
                      required=True,
                      description='The transfered subject'),
        'recipient':
        fields.Nested(base_reference,
                      required=True,
                      description=('The transfer recipient, '
                                   'either an user or an organization')),
        'comment':
        fields.String(description='An explanation about the transfer request',
                      required=True),
    })

transfer_response_fields = api.model(
    'TransferResponse', {
        'response':
        fields.String(
            description='The response', required=True, enum=RESPONSE_TYPES),
        'comment':
        fields.String(
            description='An optionnal comment about the transfer response'),
    })

person_mapping = {
    User: user_ref_fields,
    Organization: org_ref_fields,
Ejemplo n.º 16
0
from udata.auth.helpers import current_user_is_admin_or_self
from udata.api import api, fields, base_reference

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',
Ejemplo n.º 17
0
Archivo: api.py Proyecto: taniki/udata
from udata.core.organization.api_fields import org_ref_fields

activity_fields = api.model(
    'Activity', {
        'actor':
        fields.Nested(user_ref_fields,
                      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':
        fields.String(attribute='related_to',
                      description='The activity target name',
                      required=True),
        'related_to_id':
        fields.String(attribute='related_to.id',
                      description='The activity target object identifier',
                      required=True),
        'related_to_kind':
        fields.String(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',
Ejemplo n.º 18
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),
Ejemplo n.º 19
0
from udata.auth import admin_permission
from udata.api import api, API, fields
from udata.core.user.api_fields import user_ref_fields

from .forms import DiscussionCreateForm, DiscussionCommentForm
from .models import Message, Discussion
from .permissions import CloseDiscussionPermission
from .signals import (on_new_discussion, on_new_discussion_comment,
                      on_discussion_closed, on_discussion_deleted)

ns = api.namespace('discussions', 'Discussion related operations')

message_fields = api.model(
    'DiscussionMessage', {
        'content':
        fields.String(description='The message body'),
        'posted_by':
        fields.Nested(user_ref_fields, description='The message author'),
        'posted_on':
        fields.ISODateTime(description='The message posting date'),
    })

discussion_fields = api.model(
    'Discussion', {
        'id':
        fields.String(description='The discussion identifier'),
        'subject':
        fields.Nested(api.model_reference,
                      description='The discussion target object'),
        'class':
        fields.ClassName(description='The object class', discriminator=True),
Ejemplo n.º 20
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(
Ejemplo n.º 21
0
from .models import (
    HARVEST_JOB_STATUS, HARVEST_ITEM_STATUS, HarvestJob,
    VALIDATION_STATES, VALIDATION_ACCEPTED
)

ns = api.namespace('harvest', 'Harvest related operations')


def backends_ids():
    return [b.name for b in actions.list_backends()]


error_fields = api.model('HarvestError', {
    'created_at': fields.ISODateTime(description='The error creation date',
                                     required=True),
    'message': fields.String(description='The error short message',
                             required=True),
    'details': fields.String(description='Optional details (ie. stacktrace)'),
})

item_fields = api.model('HarvestItem', {
    'remote_id': fields.String(description='The item remote ID to process',
                               required=True),
    'dataset': fields.Nested(dataset_ref_fields,
                             description='The processed dataset',
                             allow_null=True),
    'status': fields.String(description='The item status',
                            required=True,
                            enum=list(HARVEST_ITEM_STATUS)),
    'created': fields.ISODateTime(description='The item creation date',
                                  required=True),
    'started': fields.ISODateTime(description='The item start date'),
Ejemplo n.º 22
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),
        'logo':
        fields.ImageField(original=True,
                          description='The organization logo URL'),
        'logo_thumbnail':
        fields.ImageField(
Ejemplo n.º 23
0
from celery.result import AsyncResult
from celery.utils import get_full_cls_name
from celery.utils.encoding import safe_repr
from flask import request

from udata.api import api, API, fields
from udata.auth import admin_permission
from udata.tasks import schedulables, celery

from .forms import CrontabTaskForm, IntervalTaskForm
from .models import PeriodicTask, PERIODS

ns = api.namespace('workers', 'Asynchronous workers related operations', path='')

crontab_fields = api.model('Crontab', {
    'minute': fields.String(description='Cron expression for minute', required=True, default='*'),
    'hour': fields.String(description='Cron expression for hour', required=True, default='*'),
    'day_of_week': fields.String(description='Cron expression for day of week', required=True, default='*'),
    'day_of_month': fields.String(description='Cron expression for day of month', required=True, default='*'),
    'month_of_year': fields.String(description='Cron expression for month of year', required=True, default='*'),
})

interval_fields = api.model('Interval', {
    'every': fields.Integer(description='The interval without unit', required=True),
    'period': fields.String(description='The period/interval type', required=True, enum=PERIODS),
})

job_fields = api.model('Job', {
    'id': fields.String(description='The job unique identifier', readonly=True),
    'name': fields.String(description='The job unique name', required=True),
    'description': fields.String(description='The job description'),
Ejemplo n.º 24
0
from flask.ext.security import current_user

from udata.api import api, API, marshal, fields

from udata.core.user.api_fields import user_ref_fields

from .forms import IssueCreateForm, IssueCommentForm
from .models import Issue, Message, ISSUE_TYPES
from .signals import on_new_issue, on_new_issue_comment, on_issue_closed

ns = api.namespace('issues', 'Issue related operations')

message_fields = api.model(
    'IssueMessage', {
        'content':
        fields.String(description='The message body', required=True),
        'posted_by':
        fields.Nested(
            user_ref_fields, description='The message author', required=True),
        'posted_on':
        fields.ISODateTime(description='The message posting date',
                           required=True),
    })

issue_fields = api.model(
    'Issue', {
        'id':
        fields.String(description='The issue identifier', readonly=True),
        'type':
        fields.String(description='The issue type',
                      required=True,
Ejemplo n.º 25
0
from udata.api import api, API, fields
from udata.auth import admin_permission
from udata.models import Dataset, Reuse, Site, Activity

from udata.core.dataset.api_fields import dataset_ref_fields
from udata.core.reuse.api_fields import reuse_ref_fields
from udata.core.user.api_fields import user_ref_fields
from udata.core.organization.api_fields import org_ref_fields

from .views import current_site

site_fields = api.model(
    'Site', {
        'id':
        fields.String(description='The Site unique identifier', required=True),
        'title':
        fields.String(description='The site display title', required=True),
        'metrics':
        fields.Raw(description='The associated metrics', default={}),
    })


@api.route('/site/', endpoint='site')
class SiteAPI(API):
    @api.doc(id='get_site')
    @api.marshal_with(site_fields)
    def get(self):
        '''Site-wide variables'''
        return current_site
Ejemplo n.º 26
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields


GEOM_TYPES = (
    'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString',
    'MultiPolygon'
)


geojson = api.model('GeoJSON', {
    'type': fields.String(
        description='The GeoJSON Type', required=True, enum=GEOM_TYPES),
    'coordinates': fields.List(
        fields.Raw(), description='The geometry as coordinates lists',
        required=True),
})

feature_fields = api.model('GeoJSONFeature', {
    'id': fields.String,
    'type': fields.String(required=True, enum=['Feature']),
    'geometry': fields.Nested(geojson, required=True),
    'properties': fields.Raw,
})

feature_collection_fields = api.model('GeoJSONFeatureCollection', {
    'type': fields.String(required=True, enum=['FeatureCollection']),
    'features': fields.List(fields.Nested(feature_fields), required=True)
})
Ejemplo n.º 27
0
from __future__ import unicode_literals

from udata.api import api, fields, base_reference
from udata.core.organization.api_fields import org_ref_fields
from udata.core.spatial.api_fields import spatial_coverage_fields
from udata.core.user.api_fields import user_ref_fields

from .models import (DATASET_BADGE_KINDS, UPDATE_FREQUENCIES, RESOURCE_TYPES,
                     DEFAULT_FREQUENCY, CHECKSUM_TYPES, DEFAULT_CHECKSUM_TYPE,
                     DEFAULT_LICENSE)

checksum_fields = api.model(
    'Checksum', {
        'type':
        fields.String(
            description='The hashing algorithm used to compute the checksum',
            default=DEFAULT_CHECKSUM_TYPE,
            enum=CHECKSUM_TYPES),
        'value':
        fields.String(description="The resulting checksum/hash", required=True)
    })

license_fields = api.model(
    'License', {
        'id': fields.String(description='The license identifier',
                            required=True),
        'title': fields.String(description='The resource title',
                               required=True),
        'maintainer':
        fields.String(description='The license official maintainer'),
        'url': fields.String(description='The license official URL'),
        'flags': fields.List(fields.String, description='Some arbitry flags'),
Ejemplo n.º 28
0
    'page_size', type=int, default=DEFAULT_PAGE_SIZE, location='args',
    help='The page size to fetch')
resources_parser.add_argument(
    'type', type=str, location='args',
    help='The type of resources to fetch')
resources_parser.add_argument(
    'q', type=str, location='args',
    help='query string to search through resources titles')

common_doc = {
    'params': {'dataset': 'The dataset ID or slug'}
}


dataset_fields = apiv2.model('Dataset', {
    'id': fields.String(description='The dataset identifier', readonly=True),
    'title': fields.String(description='The dataset title', required=True),
    'acronym': fields.String(description='An optional dataset acronym'),
    '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'),
    'archived': fields.ISODateTime(description='The archival date if archived'),
    'featured': fields.Boolean(description='Is the dataset featured'),
    'private': fields.Boolean(
        description='Is the dataset private to the owner or the organization'),
Ejemplo n.º 29
0
from udata.auth import admin_permission
from udata.api import api, API, fields
from udata.core.user.api_fields import user_ref_fields

from .forms import DiscussionCreateForm, DiscussionCommentForm
from .models import Message, Discussion
from .permissions import CloseDiscussionPermission
from .signals import (on_new_discussion, on_new_discussion_comment,
                      on_discussion_closed, on_discussion_deleted)

ns = api.namespace('discussions', 'Discussion related operations')

message_fields = api.model(
    'DiscussionMessage', {
        'content':
        fields.String(description='The message body'),
        'posted_by':
        fields.Nested(user_ref_fields, description='The message author'),
        'posted_on':
        fields.ISODateTime(description='The message posting date'),
    })

discussion_fields = api.model(
    'Discussion', {
        'id':
        fields.String(description='The discussion identifier'),
        'subject':
        fields.Nested(api.model_reference,
                      description='The discussion target object'),
        'class':
        fields.ClassName(description='The object class', discriminator=True),
Ejemplo n.º 30
0
from flask_restplus.inputs import boolean

from udata.api import api, API, fields
from udata.core.user.api_fields import user_ref_fields

from .forms import IssueCommentForm, IssueCreateForm
from .models import Message, Issue
from .permissions import CloseIssuePermission
from .signals import on_new_issue, on_new_issue_comment, on_issue_closed

ns = api.namespace('issues', 'Issue related operations')

message_fields = api.model(
    'IssueMessage', {
        'content':
        fields.String(description='The message body', required=True),
        'posted_by':
        fields.Nested(
            user_ref_fields, description='The message author', required=True),
        'posted_on':
        fields.ISODateTime(description='The message posting date',
                           required=True),
    })

issue_fields = api.model(
    'Issue', {
        'id':
        fields.String(description='The issue identifier', readonly=True),
        'subject':
        fields.Nested(api.model_reference,
                      description='The issue target object',