コード例 #1
0
    def test_push_facilities_with_locations(self):
        # create dummy data
        self._create_state()
        self._create_municipality()

        municipality = Municipality.newest()
        state = State.newest()
        municipality.parent = state
        municipality.save()

        clinic1 = Clinic(id=1,
                         name=u"Clinic A",
                         code="1A2B",
                         municipality=municipality)
        clinic1.save()

        # test push_facilities service
        response = push_facilities(self.request)

        self.assertEqual(1, len(response['rows']))
コード例 #2
0
    def handle_submission(self):
        from whoahqa.models import User

        map_data = ClinicRegistrationHandler.parse_data(
            self.submission.raw_data)
        clinic = Clinic(name=map_data['clinic_name'],
                        code=map_data['clinic_code'])

        # check is user exists
        user = None
        try:
            user = User.get(User.id == map_data['user_id'])
        except NoResultFound:
            pass
        else:
            clinic.user = user
        finally:
            clinic.save()

        # if no user, raise UserNotFound
        if user is None:
            raise UserNotFound("User with id {} was not found".format(
                map_data['user_id']))