def _register_user():
    session, reg_obj = fetch_registration()
    ulapd_api = UlapdAPI()

    current_app.logger.info("!!!!!: " + str(reg_obj))

    data_dict = {
        'user_type': 'organisation-uk',
        'email': reg_obj['email'],
        'title': reg_obj['title'],
        'first_name': reg_obj['first_name'],
        'last_name': reg_obj['last_name'],
        'contact_preferences': reg_obj.get('contact_preferences', []),
        'telephone_number': reg_obj['uk_org_phone'],
        'organisation_name': reg_obj['uk_org_name'],
        'organisation_type': reg_obj['uk_org_type'],
        'registration_number': reg_obj.get('uk_org_reg_no', None),
        'address_line_1': reg_obj['uk_org_street_line_1'],
        'address_line_2': reg_obj['uk_org_street_line_2'],
        'city': reg_obj['uk_org_city'],
        'county': reg_obj['uk_org_county'],
        'postcode': reg_obj['uk_org_postcode'],
        'country': 'UK'
    }

    print(data_dict)

    user_response = ulapd_api.create_user(data_dict)
    session.pop('registration', None)
    dps_session.commit()
    return user_response
Exemplo n.º 2
0
def _register_user():
    session, reg_obj = fetch_registration()
    ulapd_api = UlapdAPI()

    user_type = 'personal-' + ('uk'
                               if reg_obj['country'] == 'UK' else 'overseas')
    data_dict = {
        'user_type': user_type,
        'email': reg_obj['email'],
        'title': reg_obj['title'],
        'first_name': reg_obj['first_name'],
        'last_name': reg_obj['last_name'],
        # 'contactable': True if reg_obj['research'] == 'yes' else False,
        'contact_preferences': reg_obj.get('contact_preferences', []),
        'telephone_number': reg_obj['phone'],
        'address_line_1': reg_obj['street_line_1'],
        'address_line_2': reg_obj['street_line_2'],
        'city': reg_obj['city'],
        'postcode': reg_obj['postcode'],
        'county': reg_obj['county'],
        'country': reg_obj['country']
    }

    user_response = ulapd_api.create_user(data_dict)
    session.pop('registration', None)
    dps_session.commit()
    return user_response
Exemplo n.º 3
0
def _register_user():
    session, reg_obj = fetch_registration()
    ulapd_api = UlapdAPI()

    data_dict = {
        'user_type': 'organisation-overseas',
        'email': reg_obj['email'],
        'title': reg_obj['title'],
        'first_name': reg_obj['first_name'],
        'last_name': reg_obj['last_name'],
        'contact_preferences': reg_obj.get('contact_preferences', []),
        'telephone_number': reg_obj['overseas_org_phone'],
        'organisation_name': reg_obj['overseas_org_name'],
        'country_of_incorporation': reg_obj['overseas_org_country_incorp'],
        'country': reg_obj['overseas_org_country'],
        'address_line_1': reg_obj['overseas_org_street_line_1'],
        'address_line_2': reg_obj['overseas_org_street_line_2'],
        'city': reg_obj['overseas_org_city'],
        'postcode': reg_obj['overseas_org_postcode']
    }

    user_response = ulapd_api.create_user(data_dict)
    session.pop('registration', None)
    dps_session.commit()
    return user_response
    def test_create_user(self, mock_post):
        data = {"email": "*****@*****.**", "name": "testy"}
        mock_post.return_value.json.return_value = data
        mock_post.return_value.status_code = 201

        ulapd_api = UlapdAPI()
        response = ulapd_api.create_user(data)

        self.assertEqual(response, data)
        args, kwargs = mock_post.call_args_list[0]
        self.assertEqual(kwargs['data'], json.dumps(data))