本文整理汇总了Python中udata.api.api.model函数的典型用法代码示例。如果您正苦于以下问题:Python model函数的具体用法?Python model怎么用?Python model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了model函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: parse_uploaded_image
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from werkzeug.datastructures import FileStorage
from udata.api import api, fields
uploaded_image_fields = api.model('UploadedImage', {
'success': fields.Boolean(
description='Whether the upload succeeded or not.',
readonly=True, default=True),
'image': fields.ImageField(),
})
image_parser = api.parser()
image_parser.add_argument('file', type=FileStorage, location='files')
image_parser.add_argument('bbox', type=str, location='form')
def parse_uploaded_image(field):
'''Parse an uploaded image and save into a db.ImageField()'''
args = image_parser.parse_args()
image = args['file']
bbox = args.get('bbox', None)
if bbox:
bbox = [int(float(c)) for c in bbox.split(',')]
field.save(image, bbox=bbox)
开发者ID:anukat2015,项目名称:udata,代码行数:30,代码来源:api.py
示例2:
from udata.core.reuse.api_fields import reuse_ref_fields
from udata.core.user.api_fields import user_ref_fields
from udata.models import User, Organization, Dataset, Reuse
from .actions import request_transfer, accept_transfer, refuse_transfer
from .models import TRANSFER_STATUS, Transfer
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}
开发者ID:ldolberg,项目名称:udata,代码行数:32,代码来源:api.py
示例3:
from udata.core.user.api_fields import user_ref_fields
from udata.models import User, Organization, Dataset, Reuse
from .actions import request_transfer, accept_transfer, refuse_transfer
from .models import TRANSFER_STATUS, Transfer
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 = {
开发者ID:javanna2000,项目名称:udata,代码行数:32,代码来源:api.py
示例4: schedulables
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'),
'task': fields.String(description='The task name', required=True, enum=[job.name for job in schedulables()]),
'crontab': fields.Nested(crontab_fields, allow_null=True),
开发者ID:guillo-w,项目名称:udata,代码行数:31,代码来源:api.py
示例5:
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, 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'
开发者ID:odtvince,项目名称:udata,代码行数:31,代码来源:api.py
示例6: SiteAPI
from flask import request
from udata.api import api, API, fields
from udata.auth import admin_permission
from udata.models import Dataset, Reuse
from udata.core.dataset.api_fields import dataset_fields
from udata.core.reuse.api_fields import reuse_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
开发者ID:odtvince,项目名称:udata,代码行数:28,代码来源:api.py
示例7: OrganizationReference
from __future__ import unicode_literals
from udata.api import api, pager, fields
from udata.core.organization.api_fields import OrganizationReference
from udata.core.dataset.api_fields import DatasetReference
from .models import REUSE_TYPES
reuse_fields = api.model('Reuse', {
'id': fields.String(description='The reuse identifier', required=True),
'title': fields.String(description='The reuse title', required=True),
'slug': fields.String(description='The reuse permalink string', required=True),
'type': fields.String(description='The reuse type', required=True, enum=REUSE_TYPES.keys()),
'featured': fields.Boolean(description='Is the reuse featured'),
'description': fields.String(description='The reuse description in Markdown', required=True),
'image_url': fields.String(description='The reuse thumbnail'),
'created_at': fields.ISODateTime(description='The reuse creation date', required=True),
'last_modified': fields.ISODateTime(description='The reuse last modification date', required=True),
'deleted': fields.ISODateTime(description='The organization identifier', required=True),
'datasets': fields.List(DatasetReference, description='The reused datasets'),
'organization': OrganizationReference(description='The publishing organization'),
'metrics': fields.Raw(description='The reuse metrics'),
'uri': fields.UrlFor('api.reuse', lambda o: {'reuse': o},
description='The reuse API URI', required=True),
'page': fields.UrlFor('reuses.show', lambda o: {'reuse': o},
description='The reuse page URL', required=True),
})
reuse_page_fields = api.model('ReusePage', pager(reuse_fields))
开发者ID:pombredanne,项目名称:udata,代码行数:30,代码来源:api_fields.py
示例8: SiteAPI
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
开发者ID:grouan,项目名称:udata,代码行数:28,代码来源:api.py
示例9:
from udata.core.organization.api_fields import org_ref_fields # noqa
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 user last name', required=True),
'avatar': fields.ImageField(description='The user avatar URL'),
'website': fields.String(description='The user website'),
'about': fields.Markdown(description='The user self description'),
'roles': fields.List(fields.String, description='Site wide user roles'),
'organizations': fields.List(
fields.Nested(org_ref_fields),
description='The organization the user belongs to'),
'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),
开发者ID:michelbl,项目名称:udata,代码行数:31,代码来源:api_fields.py
示例10: pager
from __future__ import unicode_literals
from flask import url_for
from udata.api import api, pager, fields
from .models import ORG_ROLES, MEMBERSHIP_STATUS
org_fields = api.model('Organization', {
'id': fields.String(description='The organization identifier', required=True),
'name': fields.String(description='The organization name', required=True),
'slug': fields.String(description='The organization string used as permalink', required=True),
'description': fields.String(description='The organization description in Markdown', required=True),
'created_at': fields.ISODateTime(description='The organization creation date', required=True),
'last_modified': fields.ISODateTime(description='The organization last modification date', required=True),
'deleted': fields.ISODateTime(description='The organization deletion date if deleted'),
'metrics': fields.Raw(description='The organization metrics'),
'uri': fields.UrlFor('api.organization', lambda o: {'org': o},
description='The organization API URI', required=True),
'page': fields.UrlFor('organizations.show', lambda o: {'org': o},
description='The organization page URL', required=True),
})
org_page_fields = api.model('OrganizationPage', pager(org_fields))
request_fields = api.model('MembershipRequest', {
'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),
})
开发者ID:pombredanne,项目名称:udata,代码行数:31,代码来源:api_fields.py
示例11: import
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'),
'alternate_urls': fields.List(
fields.String,
description='Same alternative known URLs (improve rematch)'
),
'alternate_titles': fields.List(
开发者ID:odtvince,项目名称:udata,代码行数:30,代码来源:api_fields.py
示例12: import
from . import actions
from .forms import HarvestSourceForm, HarvestSourceValidationForm
from .models import (
HARVEST_JOB_STATUS, HARVEST_ITEM_STATUS, HarvestJob,
VALIDATION_STATES, VALIDATION_ACCEPTED
)
ns = api.namespace('harvest', 'Harvest related operations')
backends_ids = [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',
required=True,
enum=HARVEST_ITEM_STATUS.keys()),
'created': fields.ISODateTime(description='The item creation date',
required=True),
开发者ID:anukat2015,项目名称:udata,代码行数:30,代码来源:api.py
示例13: URL
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, description='Some keywords to help in search'),
'featured': fields.Boolean(description='Is the reuse featured', readonly=True),
'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:guillo-w,项目名称:udata,代码行数:31,代码来源:api_fields.py
示例14:
from udata.api import api, API, fields
from udata.models import Dataset, DatasetIssue, Reuse, ReuseIssue
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.String(
attribute='subject.id',
description='The issue target object identifier', required=True),
'class': fields.ClassName(description='The object class',
discriminator=True, required=True),
'title': fields.String(description='The issue title', required=True),
'user': fields.Nested(
user_ref_fields, description='The issue author', required=True),
'created': fields.ISODateTime(
开发者ID:anukat2015,项目名称:udata,代码行数:30,代码来源:api.py
示例15:
'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),
'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),
'role': fields.String(
description='The member role in the organization', required=True,
enum=ORG_ROLES.keys(), default=DEFAULT_ROLE)
})
org_fields = api.model('Organization', {
'id': fields.String(
开发者ID:odtvince,项目名称:udata,代码行数:31,代码来源:api_fields.py
示例16: line
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': fields.String(description='An optionnal link associated to the credits'),
'tags': fields.List(fields.String, description='Some keywords to help in search'),
'datasets': fields.List(fields.Nested(dataset_ref_fields), description='The post datasets'),
'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))
开发者ID:guillo-w,项目名称:udata,代码行数:31,代码来源:api.py
示例17:
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', 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'),
})
开发者ID:michelbl,项目名称:udata,代码行数:29,代码来源:api.py
示例18: UserReference
from flask import request
from flask.ext.security import current_user
from udata.api import api, API, marshal, fields
from udata.core.user.api_fields import UserReference
from .forms import IssueCreateForm, IssueCommentForm
from .models import Issue, Message, ISSUE_TYPES
from .signals import on_new_issue, on_issue_closed
message_fields = api.model('IssueMessage', {
'content': fields.String(description='The message body', required=True),
'posted_by': UserReference(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', required=True),
'type': fields.String(description='The issue type', required=True, enum=ISSUE_TYPES.keys()),
'subject': fields.String(attribute='subject.id', description='The issue target object identifier', required=True),
'user': UserReference(description='The issue author', required=True),
'created': fields.ISODateTime(description='The issue creation date', required=True),
'closed': fields.ISODateTime(description='The issue closing date'),
'closed_by': fields.String(attribute='closed_by.id', description='The user who closed the issue'),
'discussion': fields.Nested(message_fields),
'url': fields.UrlFor('api.issue', description='The issue API URI', required=True),
})
开发者ID:pombredanne,项目名称:udata,代码行数:29,代码来源:api.py
示例19:
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", 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))
开发者ID:noirbizarre,项目名称:udata,代码行数:31,代码来源:api.py
示例20: import
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),
'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.Nested(user_ref_fields, allow_null=True,
开发者ID:opendatateam,项目名称:udata,代码行数:32,代码来源:api.py
注:本文中的udata.api.api.model函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论