from myapi.model.kind import KindModel from myapi.model.enum import kind_status from myapi.common.util import itemStatus from myapi.common.decorator import jsonp parser = reqparse.RequestParser() parser.add_argument('id', dest='id', type=int, location='json') parser.add_argument('name', dest='name', type=str, location='json') #, required=True) parser.add_argument('parent_id', dest='parent_id', type=int, location='json') post_fields = { 'id': fields.Integer, 'name': fields.String, 'parent_id': fields.Integer, 'status': itemStatus(attribute='status') } class Kind(Resource): @jsonp @marshal_with(post_fields) def get(self, kindid): return KindModel.query.get(kindid) @jsonp @marshal_with(post_fields) def post(self): args = parser.parse_args() kind = KindModel(args.name)
#coding=utf-8 from flask import jsonify, url_for from flask.ext.restful import Resource, fields, marshal_with, marshal, reqparse from myapi import db from myapi.model.project import ProjectModel from myapi.model.user import UserModel from myapi.model.kind import KindModel from myapi.common.util import itemStatus parser = reqparse.RequestParser() parser.add_argument('name', type=str, location='json', required=True) parser.add_argument('description', type=str, location='json') parser.add_argument('owner_id', type=int, location='json', required=True) parser.add_argument('kind_id', type=int, location='json', required=True) resource_fields = {'project': itemStatus(attribute='status')} resource_fields['list'] = {} resource_fields['list']['sublist'] = {} user_fields = {'projectName': fields.String, 'projectKinds': fields.String} class ProjectView(): def __init__(self, projectName, projectKinds=None): self.projectName = projectName self.projectKinds = projectKinds data = {} from myapi.resources.smtp import send
#coding=utf-8 from flask import jsonify, url_for from flask.ext.restful import Resource, fields, marshal_with, marshal, reqparse from myapi import db from myapi.model.project import ProjectModel from myapi.model.user import UserModel from myapi.model.kind import KindModel from myapi.common.util import itemStatus parser = reqparse.RequestParser() parser.add_argument('name', type=str, location='json', required=True) parser.add_argument('description', type=str, location='json') parser.add_argument('owner_id', type=int, location='json', required=True) parser.add_argument('kind_id', type=int, location='json', required=True) resource_fields = {'project': itemStatus(attribute='status')} resource_fields['list']={} resource_fields['list']['sublist']={} user_fields = { 'projectName': fields.String, 'projectKinds':fields.String } class ProjectView(): def __init__(self, projectName, projectKinds=None): self.projectName = projectName self.projectKinds = projectKinds data = {}
from myapi import db from myapi.model.kind import KindModel from myapi.model.enum import kind_status from myapi.common.util import itemStatus from myapi.common.decorator import jsonp parser = reqparse.RequestParser() parser.add_argument('id', dest='id', type=int, location='json') parser.add_argument('name', dest='name', type=str, location='json')#, required=True) parser.add_argument('parent_id', dest='parent_id', type=int, location='json') post_fields = { 'id': fields.Integer, 'name': fields.String, 'parent_id': fields.Integer, 'status': itemStatus(attribute='status') } class Kind(Resource): @jsonp @marshal_with(post_fields) def get(self, kindid): return KindModel.query.get(kindid) @jsonp @marshal_with(post_fields) def post(self): args = parser.parse_args() kind = KindModel(args.name) if args.parent_id: