Beispiel #1
0
    'major':
    fields.String,
    'headline':
    fields.String,
    'about_me':
    fields.String,
    'about_me_html':
    fields.String,
    'avatar':
    fields.String(attribute=lambda x: x.avatar_url(_external=True)),
    'uri':
    fields.String(
        attribute=lambda x: url_for('api.user', user_id=x.id, _external=True)),
}
user_list = {
    'items': fields.List(fields.Nested(user_fields)),
    'next': fields.String,
    'prev': fields.String,
    'total': fields.Integer,
    'pages_count': fields.Integer,
    'current_page': fields.Integer,
    'per_page': fields.Integer,
}

tag_fields = {
    'id':
    fields.Integer,
    'name':
    fields.String,
    'books_count':
    fields.Integer(attribute=lambda x: x.books.count()),
Beispiel #2
0
from flask.ext.restful import Resource, fields, marshal, reqparse
from server import db
from server.models.person import Person

company_fields = {
    'id': fields.Integer,
    'name': fields.String,
}

person_fields = {
    'id': fields.Integer,
    'name': fields.String,
    'company': fields.Nested(company_fields),
    'job_title': fields.String,
    'location': fields.String,
    'photo': fields.String,
    'summary': fields.String,
}


class PeopleResource(Resource):
    def __init__(self):
        self.reqparse = reqparse.RequestParser()
        self.reqparse.add_argument('name', location='json')
        self.reqparse.add_argument('job_title', location='json')
        self.reqparse.add_argument('location', location='json')
        self.reqparse.add_argument('photo', location='json')
        self.reqparse.add_argument('summary', location='json')
        super().__init__()

Beispiel #3
0
project_full_resource_fields.pop('region')
project_full_resource_fields["description"] = fields.String
project_full_resource_fields["motivation"] = fields.String
project_full_resource_fields["goal"] = fields.String
project_full_resource_fields["about"] = fields.String
project_full_resource_fields["currency"] = fields.String
project_full_resource_fields["currency_rate"] = fields.Float
project_full_resource_fields["scope"] = fields.String
project_full_resource_fields["date_created"] = DateTime
project_full_resource_fields["date_published"] = DateTime
project_full_resource_fields["date_updated"] = DateTime
project_full_resource_fields["date_succeeded"] = DateTime
project_full_resource_fields["date_closed"] = DateTime
project_full_resource_fields["date_passed"] = DateTime
project_full_resource_fields["location"] = fields.List(
    fields.Nested(location_resource_fields))
project_full_resource_fields["user"] = fields.Nested(user_resource_fields)
project_full_resource_fields["widget_url"] = fields.String
project_full_resource_fields["image_url_big"] = fields.String
project_full_resource_fields["image_gallery"] = fields.List(
    fields.Nested(project_gallery_resource_fields))
project_full_resource_fields["video_url"] = fields.String
project_full_resource_fields["rewards"] = fields.List(
    fields.Nested(project_reward_resource_fields))
project_full_resource_fields["costs"] = fields.List(
    fields.Nested(project_cost_resource_fields))
project_full_resource_fields["needs"] = fields.List(
    fields.Nested(project_need_resource_fields))
project_full_resource_fields["categories"] = fields.List(
    fields.Nested(categories_resource_fields))
project_full_resource_fields["social_commitment_description"] = fields.String
Beispiel #4
0
wordcount_plot_fields = {
    'title': fields.String,
    'ylabel': fields.String,
    'start_dates': fields.List(fields.Raw),
    'end_dates': fields.List(fields.Raw),
    'subgroup_a_counts': fields.List(fields.Raw),
    'subgroup_b_counts': fields.List(fields.Raw)
}

analysis_fields = {
    'id': fields.Integer,
    'frame': fields.Integer,
    'phrase': fields.String,
    'start_date': fields.Raw,  #DateTime
    'end_date': fields.Raw,  #DateTime
    'topic_plot': fields.Nested(topic_plot_fields),
    'frame_plot': fields.Nested(frame_plot_fields),
    'wordcount_plot': fields.Nested(wordcount_plot_fields),
    'speech_windows': fields.Raw
}

analysis_marshall = {
    'meta': fields.Raw,
    'data': fields.Nested(analysis_fields)
}


class AnalysisListController(Resource):
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('page',
Beispiel #5
0
from flask.globals import g
from datetime import datetime
import six


line_report = {
    "line": PbField(line),
    "pt_objects": NonNullList(NonNullNested(pt_object)),
}

line_reports = {
    "line_reports": NonNullList(NonNullNested(line_report)),
    "error": PbField(error, attribute='error'),
    "pagination": NonNullNested(pagination),
    "disruptions": fields.List(NonNullNested(disruption_marshaller), attribute="impacts"),
    "warnings": ListLit([fields.Nested(beta_endpoint)]),
}


class LineReports(ResourceUri, ResourceUtc):
    def __init__(self):
        ResourceUri.__init__(self, output_type_serializer=api.LineReportsSerializer)
        ResourceUtc.__init__(self)
        parser_get = self.parsers["get"]
        parser_get.add_argument("depth", type=int, default=1, help="The depth of your object")
        parser_get.add_argument("count", type=default_count_arg_type, default=25,
                                help="Number of objects per page")
        parser_get.add_argument("start_page", type=int, default=0,
                                help="The current page")
        parser_get.add_argument("_current_datetime", type=DateTimeFormat(),
                                schema_metadata={'default': 'now'}, hidden=True,
Beispiel #6
0
from jormungandr.interfaces.v1.StatedResource import StatedResource
from make_links import add_coverage_link, add_coverage_link, add_collection_links, clean_links
from converters_collection_type import collections_to_resource_type
from collections import OrderedDict
from fields import NonNullNested

region_fields = {
    "id": fields.String(attribute="region_id"),
    "start_production_date": fields.String,
    "end_production_date": fields.String,
    "status": fields.String,
    "shape": fields.String,
    "error": NonNullNested({
        "code": fields.String,
        "value": fields.String
    })
}
regions_fields = OrderedDict([("regions",
                               fields.List(fields.Nested(region_fields)))])

collections = collections_to_resource_type.keys()


class Coverage(StatedResource):
    @clean_links()
    @add_coverage_link()
    @add_collection_links(collections)
    @marshal_with(regions_fields)
    def get(self, region=None, lon=None, lat=None):
        return i_manager.regions(region, lon, lat), 200
Beispiel #7
0
class InstituteStudentList(AuthorizedResource):

    student_obj = {
        'id': fields.Integer,
        'name': fields.String,
        'email': fields.String,
        'target_year': fields.Integer,
        'institute': fields.Integer,
        'type': fields.Integer,
        'mobile_no': fields.String,
        'city': fields.String,
        'area': fields.String,
        'pin': fields.String,
        'school': fields.String,
        'ntse_score': fields.Float,
        'branches': fields.List(fields.String),
        'target_exams': fields.List(fields.String),
        'roll_no': fields.String,
        'father_name': fields.String,
        'father_mobile_no': fields.String,
        'father_email': fields.String,
        'payment_plan_id': fields.String,
        'registered_from': fields.String,
        'batches': fields.List(fields.Nested({
            'id': fields.Integer,
            'name': fields.String
        }))
    }

    get_response = {
        'error': fields.Boolean(default=False),
        'students': fields.List(fields.Nested(student_obj)),
        'total': fields.Integer
    }

    post_response = {
        'error': fields.Boolean(default=False),
        'student': fields.Nested(student_obj)
    }

    @marshal_with(get_response)
    def get(self, *args, **kwargs):
        parser = reqparse.RequestParser()
        parser.add_argument('batch_id', type=int)
        parser.add_argument('batch_type', type=str, choices=app.config['BATCH_TYPE'].keys())
        parser.add_argument('target_year', type=int)
        parser.add_argument('target_exam', type=str, choices=app.config['TARGET_EXAMS'].keys())
        parser.add_argument('branches', type=comma_separated_ints_type)
        parser.add_argument('query', type=str)
        parser.add_argument('offset', type=int, default=0)
        parser.add_argument('limit', type=int, default=20)
        args = parser.parse_args()
        
        if args['branches'] is not None:
            args['branches'] = map(str, args['branches'])

        if args['batch_id'] is not None:
            batch = Batch.get(args['batch_id'])
            if args['batch_type'] is not None and batch.type != args['batch_type']:
                return {'students': []}
            if args['target_year'] is not None and batch.target_year != args['target_year']:
                return {'students': []}
            if args['target_exam'] is not None and batch.target_exam != args['target_exam']:
                return {'students': []}
            student_ids = [sb.student_id for sb in StudentBatches.query.filter(StudentBatches.batch_id == batch.id,
                                                                               StudentBatches.left_at == None).all()]
        else:
            batches = {b.id: b for b in Batch.get_filtered(type=args['batch_type'], target_year=args['target_year'],
                                                           target_exam=args['target_exam'], institute_id=kwargs['user'].id, branches=args['branches'])}
            student_ids = list({sb.student_id for sb in StudentBatches.query.filter(StudentBatches.batch_id.in_(batches.keys()),
                                                                               StudentBatches.left_at == None).all()})

        # for pagination
        if args['query'] is not None:
            students = Student.query.filter(Student.id.in_(student_ids), Student.name.ilike('%' + args['query'] + '%')).all()
            total = len(students)
            student_ids = [s.id for s in students][args['offset']:args['offset']+args['limit']]
        else:
            total = len(student_ids)
            student_ids = sorted(student_ids)[args['offset']:args['offset']+args['limit']]
            students = Student.query.filter(Student.id.in_(student_ids)).all()
        student_batches = {}
        # get all students whose id is present `student_ids` and have not left the batch and all their batches too
        for sb in StudentBatches.query.filter(StudentBatches.student_id.in_(student_ids), StudentBatches.left_at == None).all():
            if sb.student_id not in student_batches:
                student_batches[sb.student_id] = [sb.batch_id]
            else:
                student_batches[sb.student_id].append(sb.batch_id)

        # need to make one more batch query because i need all the batches that any student in the result set is part of
        batches = {b.id: b for b in Batch.get_filtered(include_ids=list(itertools.chain(*student_batches.values())))}
        for student in students:
            student.batches = [{'id': b_id, 'name': batches[b_id].name} for b_id in student_batches.get(student.id, [])]
        return {'students': students, 'total': total}

    @marshal_with(post_response)
    def post(self, *args, **kwargs):
        parser = reqparse.RequestParser()
        parser.add_argument('name', type=str, required=True)
        parser.add_argument('email', type=str, required=True)
        parser.add_argument('password', type=str, required=True)
        parser.add_argument('mobile_no', type=str, required=True)
        parser.add_argument('city', type=str)
        parser.add_argument('area', type=str)
        parser.add_argument('pin', type=str)
        parser.add_argument('school', type=str)
        parser.add_argument('ntse_score', type=float)
        parser.add_argument('roll_no', type=str, required=True)
        parser.add_argument('father_name', type=str)
        parser.add_argument('father_mobile_no', type=str)
        parser.add_argument('father_email', type=str)
        parser.add_argument('batch_ids', type=comma_separated_ints_type, required=True)
        args = parser.parse_args()
        student = Student.create(name=args['name'], email=args['email'], password=md5(args['password']).hexdigest(),
                                 mobile_no=args['mobile_no'], city=args['city'], area=args['area'], pin=args['pin'],
                                 school=args['school'], ntse_score=args['ntse_score'], roll_no=args['roll_no'],
                                 father_name=args['father_name'], father_mobile_no=args['father_mobile_no'],
                                 father_email=args['father_email'], registered_from='institute')
        target_exams = set()
        target_year = None
        batches = Batch.get_filtered(include_ids=args['batch_ids'])

        engineering_exams = {'1', '2', '3'}
        medical_exams = {'4', '5'}
        for batch in batches:
            if batch.target_exam in engineering_exams:
                target_exams.update(engineering_exams)
            if batch.target_exam in medical_exams:
                target_exams.update(medical_exams)
            if target_year is None or target_year > batch.target_year:
                target_year = batch.target_year
            sb = StudentBatches(batch_id=batch.id, student_id=student.id, joined_at=datetime.datetime.utcnow())
            db.session.add(sb)

        branches = []
        if len(target_exams.intersection(engineering_exams)) > 0:
            branches.append('1')
        if len(target_exams.intersection(medical_exams)) > 0:
            branches.append('2')

        student.target_year = target_year
        student.target_exams = list(target_exams)
        student.branches = branches
        db.session.commit()
        student.batches = [{'id': b.id, 'name': b.name} for b in batches]
        return {'student': student}
Beispiel #8
0
    'rating': fields.String,
    'short_description': fields.String,
    'description': fields.String,
    'genres': fields.List(fields.String),
    'actors': fields.List(fields.String),
    'cover_thumbnail': fields.String,
    'tvchannel': fields.String,
    'short_credits': fields.List(fields.String)
}

tvchannel_resource_fields = {
    'id': fields.Integer,
    'title': fields.String,
    'logo': fields.String,
    'logo_thumbnail': fields.String,
    'popular_tvseries': fields.Nested(tvseries_resource_fields)
}

upcoming_episode_resource_fields = {
    'id': fields.Integer,
    'title': fields.String,
    'episode_number': fields.Integer,
    'season_number': fields.Integer,
    'showed_at': Date,
    'tvseries': fields.Nested(tvseries_resource_fields)
}

episode_resource_fields = {
    'id': fields.Integer,
    'title': fields.String,
    'episode_number': fields.Integer,
Beispiel #9
0
        self._register_interpreted_parameters(args)
        return i_manager.dispatch(args,
                                  self.endpoint,
                                  instance_name=self.region)


date_time = {
    "date_time": SplitDateTime(date='date', time='time'),
    "additional_informations": additional_informations(),
    "links": stop_time_properties_links()
}

row = {
    "stop_point": PbField(stop_point),
    "date_times": fields.List(fields.Nested(date_time))
}

header = {
    "display_informations":
    PbField(display_informations_vj, attribute='pt_display_informations'),
    "additional_informations":
    NonNullList(PbEnum(response_pb2.SectionAdditionalInformationType)),
    "links":
    UrisToLinks()
}
table_field = {
    "rows": fields.List(fields.Nested(row)),
    "headers": fields.List(fields.Nested(header))
}
class MockTest(AuthorizedResource):

    response = {
        'error': fields.Boolean(default=False),
        'mock_test': fields.Nested(MockTestList.mock_test_obj)
    }

    @marshal_with(response)
    def get(self, *args, **kwargs):
        mock_test = MockTestModel.query.get(kwargs['id'])
        if mock_test is None:
            raise InvalidMockTestId
        return {'mock_test': mock_test}

    @marshal_with(response)
    def put(self, *args, **kwargs):
        parser = reqparse.RequestParser()
        parser.add_argument('name', type=str)
        parser.add_argument('is_locked', type=int, choices=[0, 1])
        parser.add_argument('question_ids',
                            type=MockTestList.question_ids_json_type)
        args = parser.parse_args()

        mock_test = MockTestModel.query.get(kwargs['id'])
        if mock_test is None:
            raise InvalidMockTestId

        if args['name'] is not None:
            mock_test.name = args['name']

        if args['question_ids'] is not None:
            args['question_ids'] = json.loads(args['question_ids'])

            for subject_id, data in args['question_ids'].items():
                seen_comprehensions = OrderedDict()
                comp_ques_ids = []
                q_ids = data['q_ids']
                question_data = Question.get_filtertered_list(
                    include_question_ids=q_ids)
                questions = question_data['questions']
                total = question_data['total']

                if total != len(q_ids):
                    raise InvalidQuestionId

                # sort questions in the order in which they appear in `q_ids`
                questions = sorted(questions, key=lambda q: q_ids.index(q.id))

                for question in questions:
                    if question.comprehension_id is not None:
                        # if comprehension not encountered before
                        if question.comprehension_id not in seen_comprehensions:
                            comp_ques_ids.append(question.id)
                            # comprehension questions in order of their ids, i.e order of their addition
                            comprehension_ques_ids = [
                                q.id for q in sorted(
                                    question.comprehension.questions.all(),
                                    key=lambda q: q.id)
                            ]
                            seen_comprehensions[
                                question.comprehension_id] = sorted(
                                    comprehension_ques_ids)

                i = 0
                for comp_id, ques_ids in seen_comprehensions.items():
                    ques_id_set = set(ques_ids)
                    ques_id_set.remove(comp_ques_ids[i])
                    # questions ids other than the first encountered question of this comprehension
                    other_comp_ques_ids = ques_id_set
                    # remove qny question ids from `other_comp_ques_ids` if present in `q_ids`
                    for id in other_comp_ques_ids:
                        try:
                            q_ids.remove(id)
                        except:
                            continue
                    # index of first encountered question of this comprehension
                    comp_ques_index = q_ids.index(comp_ques_ids[i])
                    # add all questions of this comprehension to `q_ids` starting from `comp_ques_index`
                    for index, id in enumerate(ques_ids):
                        q_ids.insert(comp_ques_index + index, id)
                    # finally remove the first encountered question of this comprehension from `q_ids`
                    q_ids.remove(q_ids[comp_ques_index + index + 1])
                    i += 1

            mock_test.question_ids = json.dumps(args['question_ids'])

        if args['is_locked'] is not None:
            mock_test.is_locked = args['is_locked'] == 1

        db.session.commit()

        return {'mock_test': mock_test}
Beispiel #11
0
    "projects_discarded": fields.Integer,
    "projects_accepted": fields.Integer,
    "projects_succeeded": fields.Integer,
    "date_created": DateTime,
    "active": fields.Boolean
}

matcher_full_resource_fields = matcher_resource_fields.copy()
matcher_full_resource_fields.pop('latitude')
matcher_full_resource_fields.pop('region')
matcher_full_resource_fields.pop('longitude')
matcher_full_resource_fields.pop('radius')
matcher_full_resource_fields["terms"] = fields.String
matcher_full_resource_fields["date_created"] = DateTime
matcher_full_resource_fields["logo_url_big"] = fields.String
matcher_full_resource_fields["user"] = fields.Nested(user_resource_fields)
matcher_full_resource_fields["location"] = fields.List(
    fields.Nested(location_resource_fields))
matcher_full_resource_fields['users'] = fields.List(
    fields.Nested(matcher_users_resource_fields))
matcher_project_resource_fields = project_resource_fields.copy()
matcher_project_resource_fields['amount_matcher'] = fields.Float
# Add radius
location_resource_fields['radius'] = fields.Integer


class MatchersListAPI(BaseList):
    """Matcher list"""
    @requires_auth()
    @ratelimit()
    @swag_from('swagger_specs/matcher_list.yml')
Beispiel #12
0
from utils import super_required, success, pagination_get
from ...models.cs_models import Building, BuildingTemplate, TagType
from .. import auth
from ..errors import *

node_fields = {
    'name': fields.String,
    'value': fields.String,
}

tags_fields = {
    'name': fields.String,
    'value': fields.String,
    'metadata': fields.Raw,
    'users': fields.List(fields.String),
    'parents': fields.List(fields.Nested(node_fields)),
    'ancestors': fields.List(fields.Nested(node_fields)),
}

building_fields = {
    'name': fields.String,
    'template': fields.String,
    'description': fields.String,
    'metadata': fields.Raw,
}


class BuildingAPI(Resource):
    decorators = [auth.login_required]

    def get(self, name):
Beispiel #13
0
#!/usr/bin/env python
# encoding: utf-8
"""
    File name: vip.py
    Function Des: ...
    ~~~~~~~~~~
    
    author: Jerry <*****@*****.**> <http://www.skyduy.com>
    
"""
from flask.ext.restful import fields

vip_fields = {
    'id': fields.String,
    'username': fields.String,
    'nickname': fields.String,
    'phone': fields.String,
}

# for get /vips
vips_fields = {'vips': fields.List(fields.Nested(vip_fields))}
Beispiel #14
0
    comment_get_parser,
    comment_delete_parser,
    comment_post_parser
)

nested_tag_fields = {
    'id': fields.Integer(),
    'title': fields.String()
}

post_fields = {
    'id': fields.Integer(),
    'author': fields.String(attribute=lambda x: x.user.username),
    'title': fields.String(),
    'text': HTMLField(),
    'tags': fields.List(fields.Nested(nested_tag_fields)),
    'publish_date': fields.DateTime(dt_format='iso8601')
}

comment_fields = {
    'id': fields.Integer(),
    'name': fields.String(),
    'text': HTMLField(),
    'date': fields.DateTime(dt_format='iso8601'),
    'post_id': fields.Integer()
}


class CommentApi(Resource):
    @marshal_with(comment_fields)
    def get(self, comment_id=None):
Beispiel #15
0
TABLE_ROW_FIELDS = {
    "index": fields.Integer,
    "offset": fields.Integer,
    "address": fields.String,
    "label": fields.String,
    "error": fields.Integer,
    "opcode": fields.String,
    "mnemonic": fields.String,
    "comment": fields.String,
    "in_use": fields.Boolean,
    "targets": fields.List(fields.Integer),
    "is_call_or_branch": fields.Boolean,
    "is_a_data_defintion_inst": fields.Boolean
}

TABLE_ROW_LIST_FIELDS = {"rows": fields.List(fields.Nested(TABLE_ROW_FIELDS))}


class TableRowList(Resource):
    """
    Simple API to retrieve all rows as JSON.
    """
    @marshal_with(TABLE_ROW_LIST_FIELDS)
    def get(self):
        """
        Get all of the rows in the store.
        """
        row_data = [row.ToDict() for row in ASSEMBLY_STORE.GetRows()]
        return {"rows": row_data}

Beispiel #16
0
    'bss_speed': fields.Raw,
    'car_speed': fields.Raw,
    'min_bike': fields.Raw,
    'min_car': fields.Raw,
    'min_bss': fields.Raw,
    'min_tc_with_bike': fields.Raw,
    'min_tc_with_car': fields.Raw,
    'min_tc_with_bss': fields.Raw,
    'factor_too_long_journey': fields.Raw,
    'min_duration_too_long_journey': fields.Raw,
    'max_duration_criteria': fields.Raw,
    'max_duration_fallback_mode': fields.Raw,
}

instance_status_with_parameters = deepcopy(instance_status)
instance_status_with_parameters['parameters'] = fields.Nested(
    instance_parameters, allow_null=True)

instance_traveler_types = {
    'traveler_type': fields.String,
    'walking_speed': fields.Raw,
    'bike_speed': fields.Raw,
    'bss_speed': fields.Raw,
    'car_speed': fields.Raw,
    'wheelchair': fields.Boolean(),
    'max_walking_duration_to_pt': fields.Raw,
    'max_bike_duration_to_pt': fields.Raw,
    'max_bss_duration_to_pt': fields.Raw,
    'max_car_duration_to_pt': fields.Raw,
    'first_section_mode': fields.List(fields.String),
    'last_section_mode': fields.List(fields.String),
    'is_from_db': fields.Boolean(),
class TeacherList(AuthorizedResource):
    teacher_obj = {
        'id': fields.Integer,
        'name': fields.String,
        'email': fields.String,
        'subject_expert': fields.String,
        'specialization': fields.String,
        'qualification': fields.String,
        'joined_at': fields.DateTime,
        'last_activity': fields.DateTime,
        'type': fields.Integer
    }

    get_response = {
        'error':
        fields.Boolean(default=False),
        'teachers':
        fields.List(
            fields.Nested({
                'teacher': fields.Nested(teacher_obj),
                'questions_categorized': fields.Integer,
                'questions_approved': fields.Integer,
                'text_solutions_submitted': fields.Integer,
                'text_solutions_approved': fields.Integer,
                'video_solutions_submitted': fields.Integer,
                'video_solutions_approved': fields.Integer,
                'reported_resolved': fields.Integer
            })),
        'total':
        fields.Integer
    }

    post_response = {
        'error': fields.Boolean(default=False),
        'teacher': fields.Nested(teacher_obj)
    }

    @marshal_with(get_response)
    def get(self, *args, **kwargs):
        parser = reqparse.RequestParser()
        parser.add_argument('page', type=int, default=1)
        parser.add_argument('limit',
                            type=int,
                            default=app.config['TEACHER_LIST_LIMIT'])
        args = parser.parse_args()
        teachers, total = Teacher.get_list(args['page'], args['limit'])
        return {'teachers': teachers, 'total': total}

    @marshal_with(post_response)
    def post(self, *args, **kwargs):
        parser = reqparse.RequestParser()
        parser.add_argument('name', type=str, required=True)
        parser.add_argument('email', type=str, required=True)
        parser.add_argument('password', type=str, required=True)
        parser.add_argument('subject_expert', type=str, required=True)
        parser.add_argument('specialization', type=str, required=True)
        parser.add_argument('qualification', type=str, required=True)
        args = parser.parse_args()
        teacher = Teacher.create(name=args['name'],
                                 email=args['email'],
                                 password=md5(args['password']).hexdigest(),
                                 subject_expert=args['subject_expert'],
                                 specialization=args['specialization'],
                                 qualification=args['qualification'])
        data = {
            'name': args['name'],
            'email': args['email'],
            'password': args['password']
        }
        welcome_admin_email_task.delay(data)
        return {'teacher': teacher}
Beispiel #18
0
committee_fields = {
    'committee_id': fields.String,
    'name': fields.String,
    'designation_full': fields.String,
    'designation': fields.String,
    'treasurer_name': fields.String,
    'organization_type_full': fields.String,
    'organization_type': fields.String,
    'state': fields.String,
    'party_full': fields.String,
    'party': fields.String,
    'committee_type_full': fields.String,
    'committee_type': fields.String,
    'expire_date': fields.String,
    'original_registration_date': fields.String,
    'candidates': fields.Nested(candidate_commitee_fields),
}
committee_detail_fields = {
    'committee_id': fields.String,
    'name': fields.String,
    'designation_full': fields.String,
    'designation': fields.String,
    'treasurer_name': fields.String,
    'organization_type_full': fields.String,
    'organization_type': fields.String,
    'state': fields.String,
    'party_full': fields.String,
    'party': fields.String,
    'committee_type_full': fields.String,
    'committee_type': fields.String,
    'expire_date': fields.String,
Beispiel #19
0
from flask.ext.restful import fields
from app.utils.gis_json_fields import PointToLatLng
from copy import copy

success_fields = dict(status=fields.String, message=fields.String)

photo_fields = dict(id=fields.Integer,
                    filename=fields.String,
                    type=fields.String,
                    caption=fields.String,
                    src=fields.String)

photo_create_fields = dict(status=fields.String,
                           message=fields.String,
                           photo=fields.Nested(photo_fields, allow_null=False))

department_fields = dict(id=fields.Integer,
                         name=fields.String,
                         head_user_id=fields.Integer)

employee_fields = dict(id=fields.Integer,
                       first_name=fields.String,
                       last_name=fields.String,
                       middle_name=fields.String,
                       fullname=fields.String,
                       address=fields.String,
                       contact_no=fields.String,
                       designation=fields.String,
                       department=fields.Nested(department_fields,
                                                allow_null=False))
Beispiel #20
0
def query_blueprint(blueprint_id):
    return Blueprint.query.filter_by(id=blueprint_id).first()


blueprint_fields = {

    'name': fields.String,
    'users': fields.Integer,
    'launched_instances': fields.Integer,
    'running_instances': fields.Integer,
}

result_fields = {

    'blueprints': fields.List(fields.Nested(blueprint_fields)),
    'overall_running_instances': fields.Integer

}


class StatsList(restful.Resource):
    @auth.login_required
    @requires_admin
    @marshal_with(result_fields)
    def get(self):
        instances = Instance.query.all()
        overall_running_instances = Instance.query.filter(Instance.state != Instance.STATE_DELETED).count()

        get_blueprint = memoize(query_blueprint)
        per_blueprint_results = defaultdict(lambda: {'users': 0, 'launched_instances': 0, 'running_instances': 0})
Beispiel #21
0
    'url': fields.String,
    'summary': fields.String,
    'html_url': fields.String,
    'comment_url': fields.String,
    'shortened_url': fields.String,
    'address': fields.String,
    'lat': fields.Raw,
    'lng': fields.Raw,
    'closed_at': fields.Raw,  #DateTime,
    'acknowledged_at': fields.Raw,  #DateTime,
    'created_at': fields.Raw,  #DateTime,
    'updated_at': fields.Raw,  #DateTime,
    'reporter_id': fields.String,
}

issue_marshall = {'meta': fields.Raw, 'data': fields.Nested(issue_fields)}

parser = reqparse.RequestParser()


class IssueController(Resource):
    @marshal_with(issue_marshall)
    def get(self, id):
        issue = Issue.query.get(id)
        return {'meta': None, 'data': issue.to_dict()}

    @marshal_with(issue_marshall)
    def put(self, id):
        issue = Issue.query.get(id)
        return {'meta': None, 'data': issue.to_dict()}