コード例 #1
0
class OfficeSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Office
        include_relationships = True
        load_instance = True
        jit = toastedmarshmallow.Jit
        # exclude = ('citizens', 'csrs', 'deleted', 'exams', 'rooms', 'services',)

    office_id = fields.Int()
    office_name = fields.Str()
    office_number = fields.Int()
    sb_id = fields.Int()
    deleted = fields.DateTime()
    exams_enabled_ind = fields.Int()
    appointments_enabled_ind = fields.Int()
    max_person_appointment_per_day = fields.Int()
    telephone = fields.Str()
    appointments_days_limit = fields.Int()
    appointment_duration = fields.Int()

    sb = fields.Nested(SmartBoardSchema())
    counters = fields.Nested(CounterSchema(), many=True)
    quick_list = fields.Nested(ServiceSchema(), many=True)
    back_office_list = fields.Nested(ServiceSchema(), many=True)
    timezone = fields.Nested(TimezoneSchema())
    timeslots = fields.Nested(TimeslotSchema(), many=True)

    latitude = fields.Float()
    longitude = fields.Float()
    office_appointment_message = fields.Str()
    civic_address = fields.Str()
    online_status = fields.Str()
コード例 #2
0
class OfficeSchema(ma.ModelSchema):

    class Meta:
        model = Office
        jit = toastedmarshmallow.Jit
        exclude = ('citizens', 'csrs', 'deleted', 'exams', 'rooms', 'services',)

    office_id = fields.Int()
    office_name = fields.Str()
    office_number = fields.Int()
    sb_id = fields.Int()
    deleted = fields.DateTime()
    exams_enabled_ind = fields.Int()
    appointments_enabled_ind = fields.Int()

    sb = fields.Nested(SmartBoardSchema())
    counters = fields.Nested(CounterSchema(), many=True)
    quick_list = fields.Nested(ServiceSchema(), many=True)
    back_office_list = fields.Nested(ServiceSchema(), many=True)
    timezone = fields.Nested(TimezoneSchema())
    timeslots = fields.Nested(TimeslotSchema(), many=True)

    latitude = fields.Float()
    longitude = fields.Float()
    office_appointment_message = fields.Str()
    civic_address = fields.Str()
    online_status = fields.Str()
コード例 #3
0
class Services(Resource):

    service_schema = ServiceSchema(many=True)
    services_schema = ServiceSchema(many=True)

    @classmethod
    def sort_services(cls, a, b):
        if a.parent is None and b.parent is not None:
            return -1
        elif a.parent is not None and b.parent is None:
            return 1
        elif (a.parent is None and b.parent is None) or (a.parent == b.parent):
            if a.service_name.lower() < b.service_name.lower():
                return -1
            else:
                return 1
        else:
            if a.parent.service_name.lower() < b.parent.service_name.lower():
                return -1
            else:
                return 1

    @oidc.accept_token(require_token=False)
    def get(self):
        if request.args.get('office_id'):
            try:
                office_id = int(request.args['office_id'])
                office = Office.query.get(office_id)
                services = sorted(office.services, key=cmp_to_key(self.sort_services))
                filtered_services = [s for s in services if s.deleted is None]
                result = self.service_schema.dump(filtered_services)
                
                return {'services': result.data,
                        'errors': result.errors}

            except exc.SQLAlchemyError as e:
                print(e)
                return {'message': 'API is down'}, 500

            except ValueError as e:
                return {'message': 'office_id must be an integer.'}, 400
        else:
            try:
                services = Service.query.filter_by(actual_service_ind=1).all()
                result = self.services_schema.dump(services)
                return {'services': result.data,
                        'errors': result.errors}

            except exc.SQLAlchemyError as e:
                print(e)
                return {'message': 'api is down'}, 500
コード例 #4
0
class ServiceReqSchema(ma.ModelSchema):
    class Meta:
        model = ServiceReq
        jit = toastedmarshmallow.Jit

    citizen_id = fields.Int()
    channel_id = fields.Int()
    service_id = fields.Int()
    quantity = fields.Int()
    sr_number = fields.Int()
    periods = fields.Nested(PeriodSchema(exclude=(
        'request_periods',
        'reception_csr_ind',
        'sr',
        'sr_id',
        'state_periods',
    )),
                            many=True)
    sr_state = fields.Nested(
        SRStateSchema(exclude=(
            'sr_state_id',
            'sr_state_desc',
        )))
    service = fields.Nested(
        ServiceSchema(exclude=(
            'actual_service_ind',
            'deleted',
            'display_dashboard_ind',
            'prefix',
            'service_code',
            'service_desc',
            'service_id',
        )))
    channel = fields.Nested(ChannelSchema(exclude=('channel_id', )))
    citizen = fields.Nested('CitizenSchema', exclude=('service_reqs', ))
コード例 #5
0
class AppointmentSchema(ma.SQLAlchemySchema):
    class Meta:
        model = Appointment
        include_relationships = True
        load_instance = True
        jit = toastedmarshmallow.Jit

    appointment_id = fields.Int(dump_only=True)
    office_id = fields.Int()
    service_id = fields.Int(allow_none=True)
    citizen_id = fields.Int()
    start_time = fields.DateTime()
    end_time = fields.DateTime()
    checked_in_time = fields.DateTime()
    comments = fields.String(allow_none=True)
    citizen_name = fields.String()
    contact_information = fields.String(allow_none=True)
    blackout_flag = fields.String(allow_none=True)
    recurring_uuid = fields.String(allow_none=True)
    online_flag = fields.Boolean(allow_none=True)
    is_draft = fields.Boolean(allow_none=True)
    # office = fields.Int(attribute="office_id")
    # service = fields.Int(attribute="service_id")
    office = fields.Nested(OfficeSchema())
    service = fields.Nested(ServiceSchema())
コード例 #6
0
class OfficeSchema(BaseSchema):
    class Meta(BaseSchema.Meta):
        model = Office
        include_relationships = True
        # exclude = ('citizens', 'csrs', 'deleted', 'exams', 'rooms', 'services',)

    office_id = fields.Int()
    office_name = fields.Str()
    office_number = fields.Int()
    sb_id = fields.Int()
    deleted = fields.DateTime()
    exams_enabled_ind = fields.Int()
    appointments_enabled_ind = fields.Int()
    max_person_appointment_per_day = fields.Int()
    telephone = fields.Str()
    appointments_days_limit = fields.Int()
    appointment_duration = fields.Int()

    sb = fields.Nested(SmartBoardSchema())
    counters = fields.Nested(CounterSchema(), many=True)
    quick_list = fields.Nested(ServiceSchema(), many=True)
    back_office_list = fields.Nested(ServiceSchema(), many=True)
    timezone = fields.Nested(TimezoneSchema())
    timeslots = fields.Nested(TimeslotSchema(), many=True)

    latitude = fields.Float()
    longitude = fields.Float()
    office_appointment_message = fields.Str()
    civic_address = fields.Str()
    online_status = fields.Str()
    external_map_link = fields.Str()

    # for walk-in notifications
    check_in_notification = fields.Int()
    check_in_reminder_msg = fields.Str()
    automatic_reminder_at = fields.Int()

    # for Digital Signage
    currently_waiting = fields.Int()
    digital_signage_message = fields.Int()
    digital_signage_message_1 = fields.Str()
    digital_signage_message_2 = fields.Str()
    digital_signage_message_3 = fields.Str()
    show_currently_waiting_bottom = fields.Int()
コード例 #7
0
class Categories(Resource):

    categories_schema = ServiceSchema(many=True)

    @oidc.accept_token(require_token=True)
    def get(self):
        try:
            services = Service.query.filter_by(actual_service_ind=0).order_by(
                Service.service_name).all()
            result = self.categories_schema.dump(services)
            return {'categories': result.data, 'errors': result.errors}, 200

        except exc.SQLAlchemyError as e:
            print(e)
            return {"message": "API is down"}, 500
コード例 #8
0
class ServiceReqSchema(BaseSchema):

    class Meta(BaseSchema.Meta):
        model = ServiceReq
        include_relationships = True

    sr_id = fields.Int()
    citizen_id = fields.Int()
    channel_id = fields.Int()
    service_id = fields.Int()
    quantity = fields.Int()
    sr_number = fields.Int()
    periods = fields.Nested(PeriodSchema(exclude=('reception_csr_ind', 'sr', 'sr_id',)), many=True)
    sr_state = fields.Nested(SRStateSchema(exclude=('sr_state_id', 'sr_state_desc',)))
    service = fields.Nested(ServiceSchema(exclude=('actual_service_ind', 'deleted', 'display_dashboard_ind', 'prefix',
                                                   'service_code', 'service_desc', 'service_id',)))
    channel = fields.Nested(ChannelSchema(exclude=('channel_id',)))
    citizen = fields.Nested('CitizenSchema', exclude=('service_reqs',))
コード例 #9
0
class AppointmentSchema(BaseSchema):
    class Meta(BaseSchema.Meta):
        model = Appointment
        include_relationships = True

    appointment_id = fields.Int(dump_only=True)
    office_id = fields.Int()
    service_id = fields.Int(allow_none=True)
    citizen_id = fields.Int()
    start_time = fields.DateTime()
    end_time = fields.DateTime()
    checked_in_time = fields.DateTime()
    comments = fields.String(allow_none=True)
    citizen_name = fields.String()
    contact_information = fields.String(allow_none=True)
    blackout_flag = fields.String(allow_none=True)
    recurring_uuid = fields.String(allow_none=True)
    online_flag = fields.Boolean(allow_none=True)
    is_draft = fields.Boolean(allow_none=True)
    stat_flag = fields.Boolean(allow_none=True)
    office = fields.Nested(
        OfficeSchema(exclude=('sb', 'counters', 'quick_list',
                              'back_office_list', 'timeslots')))
    service = fields.Nested(ServiceSchema())