Ejemplo n.º 1
0
        'product':
        fields.String(
            required=True, description='Product name', example='prod1'),
        'args':
        CustomField.Json(required=True,
                         description='Product arguments in JSON format',
                         example={"foo": "bar"}),
        'request_origin':
        fields.String(
            required=True, description='Request Origin', example='127.0.0.1'),
        'request_callback':
        fields.Url(required=True,
                   description='Request callback url',
                   example='http://origin.com/callback_uri'),
        'created_at':
        fields.DateTime(readOnly=True, description='Product creation date'),
        'updated_at':
        fields.DateTime(readOnly=True, description='product last update date'),
    })

pagination = api.model(
    'A page of results', {
        'page':
        fields.Integer(description='Number of this page of results'),
        'pages':
        fields.Integer(description='Total number of pages of results'),
        'per_page':
        fields.Integer(description='Number of items per page of results'),
        'total':
        fields.Integer(description='Total number of results'),
    })
Ejemplo n.º 2
0
# coding=utf-8
from flask_restplus import fields

from file_management.api import api

user_res = {
    'email': fields.String(description='user email address'),
    'username': fields.String(description='user username'),
    'fullname': fields.String(description='fullname of user'),
    'avatar_url': fields.String(description='avatar url of user'),
}

pending_register_res = {
    'username': fields.String(description="Username"),
    'email': fields.String(description="Email"),
    'fullname': fields.String(description="User full name"),
}

log_field = api.model(
    'log', {
        'message': fields.String(description="Message"),
        'created_at': fields.DateTime(description="Created at")
    })

notification_field = api.model(
    'notification', {
        'message': fields.String(description="Message"),
        'created_at': fields.DateTime(description="Create at")
    })
Ejemplo n.º 3
0
from ..service.auth_service import requires_authentication


api = Namespace('User', description='User-related operations')

user_profile_response_dto = api.model('user_profile_response', {
    'error': fields.Boolean(description="True on error, false on success"),
    'message': fields.String(description="Some error or success message"),
    'details': fields.Nested(
        api.model('user_profile_response_details', {
            'ids': fields.String,
            'username': fields.String,
            'first_name': fields.String,
            'last_name': fields.String,
            'email': fields.String,
            'updated_at': fields.DateTime(description="May be updated if LDAP details or email change")
        }), skip_none=True
    )
})

user_profile_update_dto = api.model('user_profile_update', {
    'email': fields.String(required=True, description='New user email')
})

user_profile_update_response_dto = api.model('user_profile_update_response', {
    'error': fields.Boolean(description="True on error, false on success"),
    'message': fields.String(description="Some error or success message"),
    'details': fields.Nested(api.model('user_profile_update_response_details', {}))
})

user_header_token_dto = api.parser()
Ejemplo n.º 4
0
        fields.Integer(description='Number of items per page of results'),
        'total':
        fields.Integer(description='Total number of results'),
    })

proposal_log = api.model(
    'proposal_log', {
        'id': fields.Integer(description='log id'),
        'proposal_id': fields.Integer(description='proposal id'),
        'event': fields.Integer(description='event id'),
        'event_key': fields.String(description='event key'),
        'from_value': fields.String(description='event from value'),
        'to_value': fields.String(description='event from value'),
        'operator': user_fields,
        'creator': user_fields,
        'op_time': fields.DateTime(description='created timestamp'),
        'created': fields.DateTime(description='created timestamp'),
    })

proposal_category = api.model(
    'category', {
        'id':
        fields.Integer(description='proposal category id'),
        'name':
        fields.String(required=True, description='proposal category name'),
        'name_en':
        fields.String(description='proposal category name(en)'),
        'order':
        fields.Integer(description='proposal category order index', default=0),
        'proposals_count':
        fields.Integer(description='related proposal count'),
Ejemplo n.º 5
0
##### TASKS MODELS #####
get_tasks_response_model = {
    "total":
    fields.Integer(
        required=True,
        decription="total de wordcloud tasks encontradas para esse arquivo"),
    "failed":
    fields.Integer(
        required=True,
        description=
        "total de wordcloud tasks que apresentam falhas para esse arquivo")
}
get_tasks_response_model = make_response_model(get_tasks_response_model)

tasks_model = {
    "id":
    fields.String(required=True, description="id da task"),
    "created_at":
    fields.DateTime(required=True, description="data de criação da task"),
    "status":
    fields.String(required=True, decription="Status da task"),
    "total":
    fields.Integer(
        required=True,
        description="Total de passos necessários para concluir a tarefa"),
    "progress":
    fields.Integer(required=True, description="Passo atual da tarefa"),
    "error":
    fields.String(required=False,
                  description="identifica se ocorreu algum erro")
}
Ejemplo n.º 6
0
        fields.Integer(attribute='wa_number'),
        'well_name':
        fields.String,
        'dormant_status':
        fields.String(attribute='well_dormant_status'),
        'current_status':
        fields.String(attribute='current_status'),
        'well_dormancy_date':
        fields.DateTime,
        'site_dormancy_date':
        fields.DateTime,
        'site_dormancy_type':
        fields.String,
        'site_dormant_status':
        fields.String,
        'surface_location':
        fields.String,
        'field':
        fields.String,
        'abandonment_date':
        fields.DateTime,
        'last_spud_date':
        fields.DateTime,
        'last_active_production_year':
        fields.DateTime(attribute='last_active_production_yr'),
        'wellsite_dormancy_declaration_date':
        fields.DateTime,
        'multi_well':
        fields.String
    })
Ejemplo n.º 7
0
from flask_cors import CORS
CORS(reviews_bp)
GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY')

review_model = api.model(
    'Review', {
        'title': fields.String,
        'description': fields.String,
        'isbn': fields.String,
        'id': fields.Integer,
        'author_name': fields.String(attribute='author.name'),
        'author_username': fields.String(attribute='author.username'),
        'author_profile': fields.String(attribute='author.profile'),
        'user_id': fields.Integer,
        'created': fields.DateTime(dt_format='rfc822')
    })

create_model = api.model('Create', {
    'title': fields.String,
    'description': fields.String,
    'isbn': fields.String
})

book_model = api.model(
    'Book', {
        'title': fields.String,
        'subtitle': fields.String,
        'authors': fields.String,
        'description': fields.String,
        'pageCount': fields.String,
Ejemplo n.º 8
0
 def test_max_exclusive(self):
     field = fields.DateTime(max='1984-06-07T00:00:00', exclusiveMax=True)
     assert 'maximum' in field.__schema__
     assert field.__schema__['maximum'] == '1984-06-07T00:00:00'
     assert 'exclusiveMaximum' in field.__schema__
     assert field.__schema__['exclusiveMaximum'] is True
Ejemplo n.º 9
0
 def test_rfc822_value(self, value, expected):
     self.assert_field(fields.DateTime(dt_format='rfc822'), value, expected)
Ejemplo n.º 10
0
 def test_max(self):
     field = fields.DateTime(max='1984-06-07T00:00:00')
     assert 'maximum' in field.__schema__
     assert field.__schema__['maximum'] == '1984-06-07T00:00:00'
     assert 'exclusiveMaximum' not in field.__schema__
Ejemplo n.º 11
0
 def test_max_as_datetime(self):
     field = fields.DateTime(max=datetime(1984, 6, 7, 1, 2, 0))
     assert 'maximum' in field.__schema__
     assert field.__schema__['maximum'] == '1984-06-07T01:02:00'
     assert 'exclusiveMaximum' not in field.__schema__
Ejemplo n.º 12
0
 def test_min_as_date(self):
     field = fields.DateTime(min=date(1984, 6, 7))
     assert 'minimum' in field.__schema__
     assert field.__schema__['minimum'] == '1984-06-07T00:00:00'
     assert 'exclusiveMinimum' not in field.__schema__
Ejemplo n.º 13
0
 def test_with_default_as_date(self):
     field = fields.DateTime(default=date(2014, 8, 25))
     assert field.__schema__ == {'type': 'string', 'format': 'date-time', 'default': '2014-08-25T00:00:00'}
     self.assert_field(field, None, '2014-08-25T00:00:00')
Ejemplo n.º 14
0
 def test_defaults(self):
     field = fields.DateTime()
     assert not field.required
     assert field.__schema__ == {'type': 'string', 'format': 'date-time'}
     self.assert_field(field, None, None)
Ejemplo n.º 15
0
create_parser.add_argument('first_name', type=str)
create_parser.add_argument('last_name', type=str)
create_parser.add_argument('email', type=str)
create_parser.add_argument('password', type=str)

update_parser = reqparse.RequestParser()
update_parser.add_argument('new_first_name', type=str)
update_parser.add_argument('new_last_name', type=str)
update_parser.add_argument('new_password', type=str)
update_parser.add_argument('new_email', type=str)
update_parser.add_argument('password', type=str)

delete_parser = reqparse.RequestParser()
delete_parser.add_argument('password', type=str)

book_create_parser = reqparse.RequestParser()
book_create_parser.add_argument('title', type=str)
book_create_parser.add_argument('author', type=str)
book_create_parser.add_argument('isbn', type=str)
book_create_parser.add_argument('date_of_publication', type=fields.DateTime(dt_format='rfc822'), help='example: 2002-10-02')

wishlist_parser = reqparse.RequestParser()
wishlist_parser.add_argument('book_id', type=str)
wishlist_parser.add_argument('password', type=str)

book_update_parser = reqparse.RequestParser()
book_update_parser.add_argument('new_title', type=str)
book_update_parser.add_argument('new_author', type=str)
book_update_parser.add_argument('new_isbn', type=str)
book_update_parser.add_argument('new_date_of_publication', type=fields.DateTime(dt_format='rfc822'), help='example: 2002-10-02')
Ejemplo n.º 16
0
 def test_iso8601_value(self, value, expected):
     self.assert_field(fields.DateTime(dt_format='iso8601'), value, expected)
Ejemplo n.º 17
0
        'id':
        fields.Integer(description="用户ID"),
        'name':
        fields.String(description="群组名"),
        'nickname':
        fields.String(description="群组昵称"),
        'creator':
        fields.Nested(model=group_user_simple, description="创建人"),
        'space_mine':
        fields.Nested(model=space_simple, as_list=True, description="群组空间"),
        'permission':
        fields.Integer(description="权限码"),
        'is_enable':
        fields.Boolean(description="是否可用"),
        'join_time':
        fields.DateTime(description="创建时间"),
        'disable_time':
        fields.String(description="禁用时间")
    })

come_out_group_list_success = api.model(
    'come_out_group_list_success', {
        'code':
        fields.Integer(description="状态码"),
        'success':
        fields.Boolean(description="是否成功"),
        'data':
        fields.Nested(
            model=come_out_group_item, description="内容数据", as_list=True)
    })
Ejemplo n.º 18
0
 def test_unsupported_format(self):
     field = fields.DateTime(dt_format='raw')
     self.assert_field_raises(field, datetime.now())
Ejemplo n.º 19
0
    'Due to JWT token is required, to test this api, please follow under instruction.\n'
    '1. Get  your access token which you can get /users/signin with registered user email. \n'
    '2. Copy your access token, and click Authorize button which located in right bottom of this description \n'
    '3. Input your access token with this format: "Bearer <copied jwt token>", into value box.'
    '4. click Authorize, and close the popup. now you can start your test.',
    version='0.1',
    security='Bearer Auth',
    authorizations=authorizations)

photo_info = api.model(
    'New_photo', {
        'tags': fields.String,
        'desc': fields.String,
        'geotag_lat': fields.Float,
        'geotag_lng': fields.Float,
        'taken_date': fields.DateTime("%Y:%m:%d %H:%M:%S"),
        'make': fields.String,
        'model': fields.String,
        'width': fields.String,
        'height': fields.String,
        'city': fields.String,
        'nation': fields.String,
        'address': fields.String
    })

photo_get_parser = api.parser()
photo_get_parser.add_argument('mode', type=str, location='args')

file_upload_parser = api.parser()
file_upload_parser.add_argument('file',
                                location='files',
Ejemplo n.º 20
0
 def test_unsupported_value_format(self):
     field = fields.DateTime(dt_format='raw')
     self.assert_field_raises(field, 'xxx')
Ejemplo n.º 21
0
area_parser.add_argument('area',
                         type=str,
                         required=True,
                         help='Text of the area')
area_parser.add_argument('zonecode',
                         type=str,
                         required=True,
                         help='3 characters of the State')

model = {
    'id': fields.Integer(),
    'username': fields.String(),
    'areacode': fields.String(),
    'area': fields.String(),
    'zonecode': fields.String(),
    'timestamp': fields.DateTime(),
}
area_model = api_namespace.model('Area', model)


@api_namespace.route('/me/areas/')
class MeAreaListCreate(Resource):
    @api_namespace.doc('list_areas')
    @api_namespace.expect(authentication_parser)
    @api_namespace.marshal_with(area_model, as_list=True)
    def get(self):
        '''
        Retrieves all the areas
        '''
        args = authentication_parser.parse_args()
        username = authentication_header_parser(args['Authorization'])
Ejemplo n.º 22
0
        fields.Integer(description="文件大小"),
        'object_uuid':
        fields.String(description="文件UUID"),
        'folder':
        fields.Nested(model=folder_simple, description="所属文件夹"),
        'creator':
        fields.Nested(model=user_simple, description="创建人"),
        'bucket':
        fields.Nested(model=bucket_simple, description="所属桶"),
        'tags':
        fields.Nested(model=tag_simple, description="所有标签", as_list=True),
        'share_files':
        fields.Nested(
            model=share_files_simple, description="所有标签", as_list=True),
        'join_time':
        fields.DateTime(description="创建时间"),
        'open_time':
        fields.DateTime(description="开放时间"),
        'edit_time':
        fields.DateTime(description="修改时间")
    })

come_out_resource_list_success = api.model(
    'come_out_resource_list_success', {
        'code': fields.Integer(description="状态码"),
        'success': fields.Boolean(description="是否成功"),
        'data': fields.Nested(model=file_all, description="内容数据", as_list=True)
    })

come_out_resource_item_success = api.model(
    'come_out_resource_item_success', {
from ngsapp.models import User
from ngsapp.tasks.mail import send_mail_rq
from ngsapp.utils import roles_required, img_upload

ns_user = Namespace('user', 'User management users/admin/client/team members')
user_schema = ns_user.model(
    'User', {
        'id': fields.Integer(),
        'username': fields.String(min_length=4, max_length=3),
        'email': fields.String(),
        'status': fields.Boolean(),
        'full_name': fields.String(),
        'gender': fields.String(),
        'role': fields.String(),
        'confirmed': fields.Boolean(),
        'created': fields.DateTime('rfc822'),
    })
schema = UserSchema()

parser = RequestParser(trim=True, bundle_errors=True)
parser.add_argument('full_name', required=True, type=string, location='json')
parser.add_argument('username', required=True, type=string, location='json')
parser.add_argument('email',
                    required=True,
                    type=inputs.email(),
                    help='Email address is required',
                    location='json')
parser.add_argument('gender',
                    required=True,
                    type=str,
                    choices=['Male', 'Female', 'Others'],
Ejemplo n.º 24
0
'''
   * Author : see AUTHORS
   * Licence: MIT, see LICENSE
'''

from flask_restplus import fields

from src.api.apiConfig import api
from src.api.fitcrack.endpoints.job.responseModels import workunit_model
from src.api.fitcrack.responseModels import pagination, host_short_model, job_short_model, boincHost_model, \
    user_model

hashes_model = api.model(
    'Hashes model', {
        'id': fields.Integer(readOnly=True, required=False),
        'password': fields.String(),
        'hash_type_name': fields.String(),
        'hash': fields.String(attribute='hashText'),
        'added': fields.DateTime(),
        'job': fields.Nested(job_short_model)
    })

page_of_hashes_model = api.inherit(
    'Page of hashes', pagination,
    {'items': fields.List(fields.Nested(hashes_model))})
Ejemplo n.º 25
0
PublicTransportPathResponse = api.model(
    'PublicTransportPathResponse', {
        'start':
        fields.String(required=True, example='Zürich Oerlikon'),
        'destination':
        fields.String(required=True, example='Zürich Hardbrück'),
        'line_type':
        fields.String(required=True, example='strain'),
        'line':
        fields.String(required=True, example='S6'),
        'track':
        fields.String(example='7'),
        'terminal':
        fields.String(required=True, example='Zürich Stadelhofen'),
        'departure':
        fields.DateTime(required=True, example='2017-11-18 14:51:00'),
        'arrival':
        fields.DateTime(required=True, example='2017-11-18 14:54:00'),
        'start_position':
        fields.List(fields.Float, required=True, example=[8.81716, 47.22372]),
        'exit_position':
        fields.List(fields.Float, required=True, example=[8.81716, 47.22372]),
        'stopovers':
        fields.List(fields.List(fields.Float),
                    required=True,
                    default=[],
                    example=[[8.81716, 47.22372], [8.81814, 47.22398]])
    })

PublicTransportConnectionResponse = api.model(
    'PublicTransportConnectionResponse', {
Ejemplo n.º 26
0
        'taUniqueId':
        fields.String(required=True, attribute='ta_unique_id.value'),
        'equipmentCategory':
        fields.String(required=False, attribute='equipment_category'),
        'equipmentModel':
        fields.String(required=False, attribute='equipment_model'),
        'equipmentName':
        fields.String(required=False, attribute='equipment_name'),
        'equipmentDesc':
        fields.String(required=False, attribute='equipment_desc'),
        'statusApproved':
        fields.Boolean(attribute='status_approved'),
        'applicableStandards':
        fields.String(required=False, attribute='applicable_standards'),
        'approvalRejectionDate':
        fields.DateTime(required=False, attribute='approval_rejection_date'),
        'applicant':
        fields.String(required=False, attribute='applicant.name'),
        'assessedBy':
        fields.String(required=False,
                      attribute='assessed_by.contact_person.person.full_name'),
        'report':
        fields.String(required=False, attribute='report.full_name'),
        'taCertificate':
        fields.String(required=False, attribute='ta_certificate.full_name'),
        'date_created':
        fields.DateTime(required=False, attribute='date_created'),
        'date_modified':
        fields.DateTime(required=False, attribute='date_modified'),
    })
Ejemplo n.º 27
0
        'gender': fields.String("The user's gender"),
        'is_under_18': fields.Boolean("If the user is over 18")
    })
a_order = api.model(
    'Order', {
        'item_selected':
        fields.String('The item of the order selected '
                      '(clothing, shoes, accessories)'),
        'vendor':
        fields.String('The vendor of the item in the order'),
        'brand':
        fields.String('The brand of the item ordered'),
        'size':
        fields.String('Size of the item'),
        'order_date':
        fields.DateTime('Date of the order'),
        'complete':
        fields.Boolean('Whether the order '
                       'has been completed or not'),
        'delivered':
        fields.Boolean('Whether the item has been'
                       '  delivered'),
        'delivery_date':
        fields.DateTime('Date of delivery'),
        'user_id':
        fields.String('Reference to the user')
    })


class UserSchema(ma.ModelSchema):
    class Meta:
Ejemplo n.º 28
0
    if (re.search(regex, email)):
        return True
    else:
        return False


api = Namespace(name='Manage Users API', path='/api/users')

user_dto = api.model(
    'User', {
        'email': fields.String(required=True, description='Email'),
        'first_name': fields.String(required=True, description='First Name'),
        'last_name': fields.String(required=True, description='Last Name'),
        'password': fields.String(required=True, description='Password'),
        'admin': fields.Boolean(required=True, description='Admin'),
        'created': fields.DateTime(required=True, description='Created'),
        'updated': fields.DateTime(required=True, description='Updated')
    })

user_signup_dto = api.model(
    'UserSignup', {
        'email': fields.String(required=True, description='Email'),
        'first_name': fields.String(required=True, description='First Name'),
        'last_name': fields.String(required=True, description='Last Name'),
        'password': fields.String(required=True, description='Password')
    })

user_update_dto = api.model(
    'UserUpdate', {
        'first_name': fields.String(required=False, description='First Name'),
        'last_name': fields.String(required=False, description='Last Name')
Ejemplo n.º 29
0
from flask_restplus import fields
from students.middleware.restplus import api

student = api.model('Student', {
    'studentname': fields.String(required=True),
    'cgpa': fields.Integer(required=True),
    'dob': fields.Date(required=True),
    'college_code': fields.Integer(required=True),
    'location': fields.String(required=True),
    'start_dt': fields.DateTime(required=True),
    'end_dt': fields.DateTime(required=True)   
    })
Ejemplo n.º 30
0
from flask_restplus import Resource, fields
from flask_jwt_extended import decode_token
from ducttapp import repositories, models
from flask import request
from . import ns

user_model = ns.model(name='user_res',
                      model={
                          'id': fields.Integer(),
                          'email': fields.String(),
                          'username': fields.String(),
                          'is_admin': fields.Boolean(),
                          'is_active': fields.Boolean(),
                          'updated_at': fields.DateTime(),
                          'fullname': fields.String(),
                          'phone_number': fields.String(),
                          'gender': fields.Boolean(),
                          'birthday': fields.DateTime(),
                          'avatar': fields.String(),
                          'roles': fields.List(fields.Integer())
                      })


@ns.route('/currentUser')
class CurrentUser(Resource):
    @ns.marshal_with(user_model)
    def get(self):
        if 'access_token_cookie' not in request.cookies:
            return None
        try:
            raw_token = decode_token(request.cookies['access_token_cookie'])