Skip to content

Commit

Permalink
[CHG #4942172] Modify firm_info tag
Browse files Browse the repository at this point in the history
- Add address parts as context variables in simple_tag
- Rename `address` context variable to `fill_address`
  • Loading branch information
sam-b0t committed Sep 21, 2023
1 parent 5e4cdc8 commit a4fef4c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
12 changes: 10 additions & 2 deletions firm_info/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ def serialize_firm_info(queryset):
{
"email": "[email protected]",
"phone": "003369856321",
"address": "1 avenue Charles de Gaulle, 99999 Paris"
"full_address": "1 avenue Charles de Gaulle, 99999 Paris France",
"address": "1 avenue Charles de Gaulle",
"postal_code": "99999",
"city": "Paris",
"country": "France",
}
```
"""
Expand All @@ -45,7 +49,11 @@ def serialize_firm_info(queryset):
return {
"email": firm_info.get("email"),
"phone": firm_info.get("phone_number"),
"address": _format_address(firm_info),
"full_address": _format_address(firm_info),
"address": firm_info.get("address"),
"postal_code": firm_info.get("postal_code"),
"city": firm_info.get("city"),
"country": firm_info.get("country"),
}
except Exception as err:
raise SerializeFirmError from err
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p>Email: {{ email }}</p>
<p>Phone: {{ phone }}</p>
<p>Address: {{ address }}</p>
<p>Full address: {{ full_address }}</p>
<p>Address: {{ address }}</p>
<p>city: {{ city }}</p>
<p>postal code: {{ postal_code }}</p>
<p>country: {{ country }}</p>
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def serialized_contact():
return {
"email": "[email protected]",
"phone": "1234567890",
"address": "1234 Main St, 12345 Anytown USA"
'address': '1234 Main St',
'city': 'Anytown',
'country': 'USA',
'full_address': '1234 Main St, 12345 Anytown USA',
'postal_code': '12345',
}


Expand Down
6 changes: 5 additions & 1 deletion tests/templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ def test_firm_contact_tag(db, firm_contact_obj, serialized_contact):
expected_output = "\n".join([
f"<p>Email: {serialized_contact['email']}</p>",
f"<p>Phone: {serialized_contact['phone']}</p>",
f"<p>Address: {serialized_contact['address']}</p>"
f"<p>Full address: {serialized_contact['full_address']}</p>",
f"<p>Address: {serialized_contact['address']}</p>",
f"<p>city: {serialized_contact['city']}</p>",
f"<p>postal code: {serialized_contact['postal_code']}</p>",
f"<p>country: {serialized_contact['country']}</p>"
])
assert rendered == expected_output

Expand Down

0 comments on commit a4fef4c

Please sign in to comment.