Skip to content

Commit

Permalink
Add the country_code property in the addressComponent.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobslee committed Jul 28, 2023
1 parent 7d97acb commit 4a9d392
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.3

Add the country_code property in the addressComponent.

## 1.0.2

Refactor builder component path properties, to store objects, with key and label getters.
Expand Down
7 changes: 7 additions & 0 deletions formiodata/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@ def country(self):
else:
return None

@property
def country_code(self):
if self.provider == self.PROVIDER_GOOGLE:
return self._address_google('country', 'short_name')
else:
return None


class datetimeComponent(Component):

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "formio-data"
version = "1.0.2"
version = "1.0.3"
homepage = "https://github.com/novacode-nl/python-formio-data"
description = "formio.js JSON-data API"
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions tests/test_component_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_get_form_address(self):
self.assertEqual(address.street_number, '33')
self.assertEqual(address.city, 'Amsterdam')
self.assertEqual(address.country, 'Netherlands')
self.assertEqual(address.country_code, 'NL')

# i18n translations
def test_get_label_i18n_nl(self):
Expand Down

0 comments on commit 4a9d392

Please sign in to comment.