Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

25328 - Support Update and Save NoW Draft for Bootstrap Filing #3183

Conversation

meawong
Copy link
Collaborator

@meawong meawong commented Jan 24, 2025

Issue #: /bcgov/entity#25328

Description of changes:

Post new NoW DRAFT:

  • withdrawn filing id = 156853
  • notice of withdrawal id = 156943
    image

Get NoW DRAFT (156943):
image

Update and Save NoW DRAFT:
Params:
image
Body (updating certifiedBy field):
image
Response:
image

Get NoW DRAFT to confirm update was saved:
image

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the lear license (Apache 2.0).

@meawong meawong self-assigned this Jan 24, 2025
@meawong meawong marked this pull request as ready for review January 24, 2025 02:35
Copy link
Collaborator

@ArwenQin ArwenQin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Megan! LGTM

Copy link
Collaborator

@eason-pan-bc eason-pan-bc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation works.
Just thoughts, the method can be optimized a bit to reduce the amount of 'if statements' and use more sqlAlchemy features.

My idea is:

def get_temp_reg_filing(temp_reg_id: str, filing_id: str = None):
    """Return a filing by the temp id and filing id (if applicable)."""
    if not filing_id:
        return db.session.query(Filing).filter(Filing.temp_reg == temp_reg_id).one_or_none()
            
    return (
        db.session.query(Filing).filter(
            db.or_(
                db.and_(
                    Filing.id == filing_id,
                    Filing.temp_reg == temp_reg_id
                ),
                db.and_(  # special case for NoW
                    Filing.id == filing_id,
                    Filing._filing_type == 'noticeOfWithdrawal',
                    Filing.withdrawn_filing_id == db.session.query(Filing.id)
                        .filter(Filing.temp_reg == temp_reg_id)
                        .scalar_subquery()
                )
            )
        ).one_or_none())

eason-pan-bc

This comment was marked as duplicate.

@meawong meawong requested a review from argush3 January 27, 2025 18:01
@meawong meawong merged commit f7a217b into bcgov:main Jan 28, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants