Skip to content

Commit

Permalink
21953 Update Address model for furnishings job (bcgov#2820)
Browse files Browse the repository at this point in the history
* Update dissolutions to use legislation datetime

* Undo refactor

* Add furnishing address type

* Add Address.find_by method
  • Loading branch information
leodube-aot authored Jul 10, 2024
1 parent e8cbdc9 commit 1e5e962
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion legal-api/src/legal_api/models/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class Address(db.Model): # pylint: disable=too-many-instance-attributes

MAILING = 'mailing'
DELIVERY = 'delivery'
ADDRESS_TYPES = [MAILING, DELIVERY]
FURNISHING = 'furnishing'
ADDRESS_TYPES = [MAILING, DELIVERY, FURNISHING]
JSON_MAILING = 'mailingAddress'
JSON_DELIVERY = 'deliveryAddress'
JSON_ADDRESS_TYPES = [JSON_MAILING, JSON_DELIVERY]
Expand Down Expand Up @@ -101,3 +102,24 @@ def find_by_id(cls, internal_id: int = None):
if internal_id:
address = cls.query.filter_by(id=internal_id).one_or_none()
return address

@classmethod
def find_by(cls,
business_id: int = None,
furnishings_id: int = None,
office_id: int = None) -> dict:
"""Return the address matching."""
query = db.session.query(Address)
addresses = []

if business_id:
query = query.filter(Address.business_id == business_id)

if furnishings_id:
query = query.filter(Address.furnishings_id == furnishings_id)

if office_id:
query = query.filter(Address.office_id == office_id)

addresses = query.order_by(Address.id).all()
return addresses

0 comments on commit 1e5e962

Please sign in to comment.