Skip to content

Commit

Permalink
Merge branch 'release-skip-nro-decom-clean' into release-skip-nro-dec…
Browse files Browse the repository at this point in the history
…om-clean
  • Loading branch information
eve-git authored Sep 27, 2024
2 parents 7e3fd91 + 3d943df commit 11cb8ff
Show file tree
Hide file tree
Showing 457 changed files with 857 additions and 29,329 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ api - the core API service
solr - solr is used as a search service providing advanced semantic support
solr-feeder
solr-synonyms-api
nro-update - updates the legacy database, used as an integration point for downstream systems
nro-extractor - pulling incoming requests from the legacy systems
nro-legacy - scripts to manage integration objects with the legacy Oracle DB
```

## Deployment (Local Development)
Expand Down
1 change: 0 additions & 1 deletion api/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ MRAS_SVC_URL=
MRAS_SVC_API_KEY=

# Local development only
DISABLE_NAMEREQUEST_NRO_UPDATES=1
DISABLE_NAMEREQUEST_SOLR_UPDATES=1
26 changes: 5 additions & 21 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class Config(object):

ENTITY_SVC_URL = f'{os.getenv("LEGAL_API_URL", None)}{os.getenv("LEGAL_API_VERSION", "/api/v1")}'

NRO_EXTRACTOR_URI = f'{os.getenv("NAMEX_API_URL", None)}{os.getenv("NAMEX_API_VERSION", None)}/nro-extract/nro-requests'


NAME_REQUEST_URL = os.getenv('NAME_REQUEST_URL', '')
NAMES_INFORMATION_URL = os.getenv('NAMES_INFORMATION_URL',
'https://www2.gov.bc.ca/gov/content/employment-business/business/managing-a-business/\
Expand All @@ -72,13 +69,6 @@ class Config(object):
DB_PORT = os.getenv('NAMEX_DATABASE_PORT', '5432')
SQLALCHEMY_DATABASE_URI = f'postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}'

# ORACLE - LEGACY NRO NAMESDB
NRO_USER = os.getenv('NRO_USER', '')
NRO_PASSWORD = os.getenv('NRO_PASSWORD', '')
NRO_DB_NAME = os.getenv('NRO_DB_NAME', '')
NRO_HOST = os.getenv('ORACLE_HOST', '')
NRO_PORT = int(os.getenv('ORACLE_PORT', '1521'))

# KEYCLOAK & JWT_OIDC Settings
JWT_OIDC_WELL_KNOWN_CONFIG = os.getenv('JWT_OIDC_WELL_KNOWN_CONFIG')
JWT_OIDC_ALGORITHMS = os.getenv('JWT_OIDC_ALGORITHMS')
Expand All @@ -89,22 +79,20 @@ class Config(object):

JWT_OIDC_AUDIENCE = os.getenv('JWT_OIDC_AUDIENCE')

SBC_SVC_AUTH_URL = os.getenv('KEYCLOAK_AUTH_TOKEN_URL', '')
SBC_SVC_AUTH_CLIENT_ID = os.getenv('NAMEX_SBC_SERVICE_ACCOUNT_CLIENT_ID', '')
SBC_SVC_CLIENT_SECRET = os.getenv('NAMEX_SBC_SERVICE_ACCOUNT_CLIENT_SECRET', '')
COLIN_SVC_AUTH_URL = os.getenv('KEYCLOAK_AUTH_TOKEN_URL', '')
COLIN_SVC_AUTH_CLIENT_ID = os.getenv('NAME_REQUEST_SERVICE_ACCOUNT_CLIENT_ID', '')
COLIN_SVC_CLIENT_SECRET = os.getenv('NAME_REQUEST_SERVICE_ACCOUNT_CLIENT_SECRET', '')

ENTITY_SVC_AUTH_URL = os.getenv('KEYCLOAK_AUTH_TOKEN_URL', '')
ENTITY_SERVICE_ACCOUNT_CLIENT_ID = os.getenv('ENTITY_SERVICE_ACCOUNT_CLIENT_ID', '')
ENTITY_SERVICE_ACCOUNT_CLIENT_SECRET = os.getenv('ENTITY_SERVICE_ACCOUNT_CLIENT_SECRET', '')

PAYMENT_SVC_AUTH_URL = os.getenv('KEYCLOAK_AUTH_TOKEN_URL', '')
PAYMENT_SVC_AUTH_CLIENT_ID = os.getenv('NAME_REQUEST_SERVICE_ACCOUNT_CLIENT_ID', '')
PAYMENT_SVC_CLIENT_SECRET = os.getenv('NAME_REQUEST_SERVICE_ACCOUNT_CLIENT_SECRET', '')

# You can disable NRO updates for Name Requests by setting the variable in your .env / OpenShift configuration
DISABLE_NAMEREQUEST_NRO_UPDATES = int(os.getenv('DISABLE_NAMEREQUEST_NRO_UPDATES', 0))
DISABLE_NAMEREQUEST_SOLR_UPDATES = int(os.getenv('DISABLE_NAMEREQUEST_SOLR_UPDATES', 0))


GCP_AUTH_KEY = os.getenv('BUSINESS_GCP_AUTH_KEY', None)
NAMEX_NR_STATE_TOPIC = os.getenv('NAMEX_NR_STATE_TOPIC', '')
EMAILER_TOPIC = os.getenv('NAMEX_MAILER_TOPIC', '')
Expand All @@ -129,8 +117,6 @@ class DevConfig(Config):
TESTING = False,
DEBUG = True

# We can't run NRO locally unless you're provisioned, you can disable NRO updates for Name Requests by setting the variable in your .env
DISABLE_NAMEREQUEST_NRO_UPDATES = int(os.getenv('DISABLE_NAMEREQUEST_NRO_UPDATES', 0))
DISABLE_NAMEREQUEST_SOLR_UPDATES = int(os.getenv('DISABLE_NAMEREQUEST_SOLR_UPDATES', 0))


Expand All @@ -145,7 +131,7 @@ class TestConfig(Config):
DB_NAME = os.getenv('DATABASE_TEST_NAME', '')
DB_HOST = os.getenv('DATABASE_TEST_HOST', '')
DB_PORT = os.getenv('DATABASE_TEST_PORT', '5432')
# Allows for NRO add / update bypass if necessary (for local development)

LOCAL_DEV_MODE = os.getenv('LOCAL_DEV_MODE', False)
# Set this in your .env to debug SQL Alchemy queries (for local development)
SQLALCHEMY_ECHO = 'debug' if os.getenv('DEBUG_SQL_QUERIES', False) else False
Expand All @@ -158,8 +144,6 @@ class TestConfig(Config):
)
EMAILER_TOPIC = os.getenv('NAMEX_MAILER_TOPIC', '')

# We can't run NRO locally for running our tests
DISABLE_NAMEREQUEST_NRO_UPDATES = int(os.getenv('DISABLE_NAMEREQUEST_NRO_UPDATES', 1))
DISABLE_NAMEREQUEST_SOLR_UPDATES = int(os.getenv('DISABLE_NAMEREQUEST_SOLR_UPDATES', 0))

# JWT OIDC settings
Expand Down
37 changes: 37 additions & 0 deletions api/migrations/versions/179a7b0089ce_payment_societies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""payment-societies
Revision ID: 179a7b0089ce
Revises: 6be595afb9ba
Create Date: 2024-08-27 16:45:02.229938
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
revision = '179a7b0089ce'
down_revision = '6be595afb9ba'
branch_labels = None
depends_on = None

def upgrade():
# ### commands auto generated by Alembic - please adjust!! ###
op.create_table('payment_societies',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('nr_num', sa.String(length=10), nullable=True),
sa.Column('corp_num', sa.String(20), nullable=True),
sa.Column('request_state', sa.String(length=40), nullable=True),
sa.Column('payment_status', sa.String(length=50), nullable=True),
sa.Column('payment_date', sa.DateTime(), nullable=True),
sa.Column('payment_json', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('payment_societies')
# ### end Alembic commands ###
3 changes: 1 addition & 2 deletions api/namex/VERSION.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__version__ = '1.1.61'

__version__ = '1.1.61'
4 changes: 0 additions & 4 deletions api/namex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@

from namex.services.cache import cache
from namex.services.lookup import nr_filing_actions
from namex.services.nro import NROServices

from .services import queue

nro = NROServices()
from namex import models
from namex.models import db, ma
from namex.resources import api
Expand Down Expand Up @@ -65,7 +62,6 @@ def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
api.init_app(app)
setup_jwt_manager(app, jwt)

nro.init_app(app)
cache.init_app(app)
nr_filing_actions.init_app(app)

Expand Down
1 change: 0 additions & 1 deletion api/namex/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class ValidLocations(AbstractEnum):
class ValidSources(AbstractEnum):
NAMEX = 'NAMEX'
NAMEREQUEST = 'NAMEREQUEST'
NRO = 'NRO'
SO = 'SO'


Expand Down
2 changes: 1 addition & 1 deletion api/namex/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from .user import User, UserSchema

from .decision_reason import DecisionReason
from .nro_sync_tables import NRONamesSyncJob, NRONamesSyncJobDetail, NRONamesSyncJobStatus
from .admin_tables import DecisionReasonAudit, RestrictedConditionAudit
from .word_classification import WordClassification, WordClassificationSchema
from .virtual_word_condition import VirtualWordCondition
Expand All @@ -29,3 +28,4 @@
from .nr_number_lifespan import NRNumberLifespan
from .payment import Payment
from .hotjar_tracking import HotjarTracking
from .payment_society import PaymentSociety
1 change: 1 addition & 0 deletions api/namex/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Event(db.Model):
DELETE = 'DELETE'
UPDATE_FROM_NRO = 'update_from_nro'
NRO_UPDATE = 'nro_update'
NR_DAY_JOB = 'nr_day_job'
MARKED_ON_HOLD = 'marked_on_hold'
SET_TO_DRAFT = 'set_to_draft'
NAMEX_PAY = 'namex_pay'
Expand Down
29 changes: 0 additions & 29 deletions api/namex/models/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Name(db.Model):
commentId = db.Column('comment_id', db.Integer, db.ForeignKey('comments.id'))
# nameRequest = db.relationship('Request')

# if a comment is added during decision, link it to the name record to be sent back to NRO
comment = db.relationship("Comment", backref=backref("related_name", uselist=False), foreign_keys=[commentId])

# Required for name request name analysis
Expand Down Expand Up @@ -131,34 +130,6 @@ def update_nr_name_search(mapper, connection, target):
('(' + name_search + ')', nr.id)
)

# set nr state to consumed
name_consume_history = get_history(name, 'consumptionDate')
current_app.logger\
.debug('name_consume_history check - nrNum: {}, consumptionDate: {}, corpNum: {}, state: {}'
.format(nr.nrNum, name.consumptionDate, name.corpNum, name.state))
# Note: we cannot just check for a corpNum addition due to some Society change of name NRs coming over from
# NRO extractor providing a value for the corpNum field.
if len(name_consume_history.added) \
and name.consumptionDate \
and name.corpNum \
and name.state in ['APPROVED', 'CONDITION']:
# Adding an after_flush_postexec to avoid connection and transaction closed issue's
# Creating one time execution event when ever corpNum is added to a name
# corpNum sets from nro-extractor job
@event.listens_for(db.session, 'after_flush_postexec', once=True)
def receive_after_flush_postexec(session, flush_context):
nr = Request.find_by_id(name.nrId)
nr.stateCd = State.CONSUMED
nr.add_to_db()
current_app.logger.debug('moved to CONSUMED state {}'.format(name.corpNum))
EventRecorder.record_as_system(Event.UPDATE_FROM_NRO, nr, {
'id': nr.id,
'nrNum': nr.nrNum,
'stateCd': nr.stateCd
}, True)
current_app.logger.debug('moved to CONSUMED state event logged {}'.format(nr.nrNum))


class NameSchema(ma.SQLAlchemySchema):
class Meta:
model = Name
Expand Down
37 changes: 0 additions & 37 deletions api/namex/models/nro_sync_tables.py

This file was deleted.

16 changes: 0 additions & 16 deletions api/namex/models/nwpta.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,6 @@ def save_to_db(self):
def delete_from_db(self):
pass

# used by NRO extractor
def set_requested_flag(self):
try:
# NAS (Numbered Assumed) types have blank data but are not requested
if self.partnerNameTypeCd == 'NAS':
self.requested = False

# if all data is blank (except type and jurisdiction) then the customer has requested nwpta
elif self.partnerNameNumber in ['', None] and self.partnerName in ['', None] and self.partnerNameDate in ['', None]:
self.requested = True

else:
self.requested = False
except:
pass


class PartnerNameSystemSchema(ma.SQLAlchemySchema):
class Meta:
Expand Down
34 changes: 34 additions & 0 deletions api/namex/models/payment_society.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Payment_societies keep data for society from home legancy app
"""
from . import db
from datetime import datetime
from sqlalchemy.dialects.postgresql import JSONB
from datetime import datetime

class PaymentSociety(db.Model):
__tablename__ = 'payment_societies'

id = db.Column(db.Integer, primary_key=True)
nrNum = db.Column('nr_num', db.String(10), unique=True)
corpNum = db.Column('corp_num', db.String(20), unique=True)
requestState = db.Column('request_state', db.String(40), unique=True)
paymentState = db.Column('payment_status', db.String(50), unique=True)
paymentDate = db.Column('payment_date', db.DateTime(timezone=True), default=datetime.utcnow)
paymentJson = db.Column('payment_json', JSONB)

def json(self):
return {"id": self.id,
"nrNum": self.nrNum,
"corpNum": self.corpNum,
"requestState": self.requestState,
"paymentState": self.paymentState,
"paymentDate": self.paymentDate,
"paymentJson": self.paymentJson
}

def save_to_db(self):
db.session.add(self)
db.session.commit()

def save_to_session(self):
db.session.add(self)
6 changes: 3 additions & 3 deletions api/namex/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Request(db.Model):
_request_action_cd = db.Column('request_action_cd', db.String(10))
_entity_type_cd = db.Column('entity_type_cd', db.String(10))
consent_dt = db.Column('consent_dt', db.DateTime(timezone=True))
_source = db.Column('source', db.String(15), default=ValidSources.NRO.value)
_source = db.Column('source', db.String(15))
tradeMark = db.Column('trade_mark', db.String(100))

# Check-In / Check-Out (for INPROGRESS)
Expand Down Expand Up @@ -265,7 +265,7 @@ def get_queued_oldest(cls, userObj, priority_queue):

if existing_nr:
current_app.logger.info('Existing NR found, returning: {}'.format(existing_nr.nrNum))
return existing_nr, False
return existing_nr

# this will error if there's nothing in the queue - likelihood ~ 0
result = None
Expand Down Expand Up @@ -293,7 +293,7 @@ def get_queued_oldest(cls, userObj, priority_queue):

db.session.add(result)
db.session.commit()
return result, True
return result

@classmethod
def get_oldest_draft(cls):
Expand Down
2 changes: 2 additions & 0 deletions api/namex/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .statistics.wait_time_statistics import api as wait_time_stats_api

from .user_settings import api as user_settings_api
from .payment_societies import api as payment_societies_api


# This will add the Authorize button to the swagger docs
Expand Down Expand Up @@ -54,3 +55,4 @@
api.add_namespace(entity_api, path='/businesses')
api.add_namespace(wait_time_stats_api, path='/statistics')
api.add_namespace(user_settings_api, path='/usersettings')
api.add_namespace(payment_societies_api, path='/payment-societies')
Loading

0 comments on commit 11cb8ff

Please sign in to comment.