Beispiel #1
0
    def get_links(self, mapped_object: dict) -> dict:
        links = super().get_links(mapped_object)

        if mapped_object.get('burgerservicenummer'):
            links['ingeschrevenPersoon'] = {
                'href': get_auth_url('brp_ingeschrevenpersonen_bsn', bsn=mapped_object['burgerservicenummer'])
            }
        return links
Beispiel #2
0
    def test_get_auth_url(self, mock_url_for):
        mock_request = MagicMock()

        with patch('gobstuf.auth.routes.request', mock_request):
            view_name = 'any view'
            mock_request.scheme = 'http(s)'
            mock_request.host = 'any host'
            mock_request.base_url = ''

            mock_url_for.return_value = '/any url'

            result = get_auth_url(view_name)
            self.assertEqual(result, "http(s)://any host/any url")
            mock_url_for.assert_called_with('any view')
Beispiel #3
0
    def get_links(self, mapped_object: dict):
        """
        Return the HAL links that correspond with the mapped and filtered object (data)

        :param data: the mapped and filtered object
        :return:
        """
        links = super().get_links(mapped_object)

        if mapped_object.get('verblijfplaats', {}).get('woonadres', {}).get('identificatiecodeNummeraanduiding'):
            nummeraanduiding = mapped_object['verblijfplaats']['woonadres']['identificatiecodeNummeraanduiding']
            links['verblijfplaatsNummeraanduiding'] = {
                'href': f"https://api.data.amsterdam.nl/gob/bag/nummeraanduidingen/{nummeraanduiding}/"
            }

        if mapped_object.get('burgerservicenummer'):
            links['self'] = {
                'href': get_auth_url('brp_ingeschrevenpersonen_bsn', bsn=mapped_object['burgerservicenummer'])
            }

        self._add_related_object_links(
            mapped_object,
            links,
            'partners',
            'brp_ingeschrevenpersonen_bsn_partners_detail'
        )

        self._add_related_object_links(
            mapped_object,
            links,
            'ouders',
            'brp_ingeschrevenpersonen_bsn_ouders_detail'
        )

        self._add_related_object_links(
            mapped_object,
            links,
            'kinderen',
            'brp_ingeschrevenpersonen_bsn_kinderen_detail'
        )

        return links
Beispiel #4
0
 def url_for_object(index):
     return get_auth_url(route,
                         bsn=mapped_object['burgerservicenummer'],
                         **{url_param: index}
                         )