• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.validate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中udata.api.api.validate函数的典型用法代码示例。如果您正苦于以下问题:Python validate函数的具体用法?Python validate怎么用?Python validate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了validate函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: post

 def post(self):
     '''Create a new scheduled job'''
     if 'crontab' in request.json and 'interval' in request.json:
         api.abort(400, 'Cannot define both interval and crontab schedule')
     if 'crontab' in request.json:
         form = api.validate(CrontabTaskForm)
     else:
         form = api.validate(IntervalTaskForm)
     return form.save(), 201
开发者ID:guillo-w,项目名称:udata,代码行数:9,代码来源:api.py


示例2: put

 def put(self, id):
     '''Update a single scheduled job'''
     task = self.get_or_404(id)
     if 'crontab' in request.json:
         task.interval = None
         task.crontab = PeriodicTask.Crontab()
         form = api.validate(CrontabTaskForm, task)
     else:
         task.crontab = None
         task.interval = PeriodicTask.Interval()
         form = api.validate(IntervalTaskForm, task)
     return form.save()
开发者ID:guillo-w,项目名称:udata,代码行数:12,代码来源:api.py


示例3: put

 def put(self, org):
     """Update a organization given its identifier"""
     if org.deleted:
         api.abort(410, "Organization has been deleted")
     EditOrganizationPermission(org).test()
     form = api.validate(OrganizationForm, org)
     return form.save()
开发者ID:javanna2000,项目名称:udata,代码行数:7,代码来源:api.py


示例4: put

 def put(self, reuse):
     '''Update a given reuse'''
     if reuse.deleted:
         api.abort(410, 'This reuse has been deleted')
     ReuseEditPermission(reuse).test()
     form = api.validate(ReuseForm, reuse)
     return form.save()
开发者ID:anukat2015,项目名称:udata,代码行数:7,代码来源:api.py


示例5: post

 def post(self, ident):
     '''Validate or reject an harvest source'''
     form = api.validate(HarvestSourceValidationForm)
     if form.state.data == VALIDATION_ACCEPTED:
         return actions.validate_source(ident, form.comment.data)
     else:
         return actions.reject_source(ident, form.comment.data)
开发者ID:anukat2015,项目名称:udata,代码行数:7,代码来源:api.py


示例6: put

 def put(self, reuse):
     '''Update a given reuse'''
     request_deleted = request.json.get('deleted', True) 
     if reuse.deleted and request_deleted is not None: 
         api.abort(410, 'This reuse has been deleted')
     ReuseEditPermission(reuse).test()
     form = api.validate(ReuseForm, reuse)
     return form.save()
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:api.py


示例7: put

    def put(self, org, user):
        '''Update member status into a given organization.'''
        EditOrganizationPermission(org).test()
        member = org.member(user)
        form = api.validate(MemberForm, member)
        form.populate_obj(member)
        org.save()

        return member
开发者ID:opendatateam,项目名称:udata,代码行数:9,代码来源:api.py


示例8: put

 def put(self, community):
     '''Update a given community resource'''
     form = api.validate(CommunityResourceForm, community)
     form.populate_obj(community)
     if not community.organization:
         community.owner = current_user._get_current_object()
     community.modified = datetime.now()
     community.save()
     return community
开发者ID:vinyll,项目名称:udata,代码行数:9,代码来源:api.py


示例9: post

 def post(self, dataset):
     '''Create a new resource for a given dataset'''
     ResourceEditPermission(dataset).test()
     form = api.validate(ResourceForm)
     resource = Resource()
     form.populate_obj(resource)
     dataset.add_resource(resource)
     dataset.last_modified = datetime.now()
     dataset.save()
     return resource, 201
开发者ID:opendatateam,项目名称:udata,代码行数:10,代码来源:api.py


示例10: post

 def post(self, reuse):
     '''Create a new badge for a given reuse'''
     form = api.validate(BadgeForm)
     badge = ReuseBadge(created=datetime.now(),
                        created_by=current_user.id)
     form.populate_obj(badge)
     for existing_badge in reuse.badges:
         if existing_badge.kind == badge.kind:
             return existing_badge
     reuse.add_badge(badge)
     return badge, 201
开发者ID:grouan,项目名称:udata,代码行数:11,代码来源:api.py


示例11: post

 def post(self, org):
     """Create a new badge for a given organization"""
     Form = badge_form(Organization)
     form = api.validate(Form)
     badge = Badge(created=datetime.now(), created_by=current_user.id)
     form.populate_obj(badge)
     for existing_badge in org.badges:
         if existing_badge.kind == badge.kind:
             return existing_badge
     org.add_badge(badge)
     return badge, 201
开发者ID:javanna2000,项目名称:udata,代码行数:11,代码来源:api.py


示例12: post

    def post(self, org, id):
        '''Refuse user membership to a given organization.'''
        membership_request = self.get_or_404(org, id)
        form = api.validate(MembershipRefuseForm)

        membership_request.status = 'refused'
        membership_request.handled_by = current_user._get_current_object()
        membership_request.handled_on = datetime.now()
        membership_request.refusal_comment = form.comment.data

        org.save()

        return {}, 200
开发者ID:pombredanne,项目名称:udata,代码行数:13,代码来源:api.py


示例13: add

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
开发者ID:anukat2015,项目名称:udata,代码行数:17,代码来源:api.py


示例14: post

 def post(self, id):
     '''Add comment and optionnaly close an issue given its ID'''
     issue = Issue.objects.get_or_404(id=id)
     form = api.validate(IssueCommentForm)
     message = Message(
         content=form.comment.data,
         posted_by=current_user.id
     )
     issue.discussion.append(message)
     close = form.close.data
     if close:
         CloseIssuePermission(issue).test()
         issue.closed_by = current_user._get_current_object()
         issue.closed = datetime.now()
     issue.save()
     if close:
         on_issue_closed.send(issue, message=message)
     else:
         on_new_issue_comment.send(issue, message=message)
     return issue
开发者ID:anukat2015,项目名称:udata,代码行数:20,代码来源:api.py



注:本文中的udata.api.api.validate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python auth.login_user函数代码示例发布时间:2022-05-27
下一篇:
Python api.parser函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap