Skip to content

Commit

Permalink
Merge pull request #60 from turb0c0w/tyler/registrations_pagination
Browse files Browse the repository at this point in the history
Tyler/registrations pagination
  • Loading branch information
turb0c0w authored Jul 19, 2024
2 parents 34806da + 0d8eaac commit f2ddfe6
Show file tree
Hide file tree
Showing 16 changed files with 1,285 additions and 56 deletions.
36 changes: 36 additions & 0 deletions strr-api/migrations/versions/20240714_269514c7d861_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""empty message
Revision ID: 269514c7d861
Revises: ed33e07431ea
Create Date: 2024-07-14 22:20:59.662520
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '269514c7d861'
down_revision = 'ed33e07431ea'
branch_labels = None
depends_on = None


def upgrade():
op.create_table('certificates',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('registration_id', sa.INTEGER(), nullable=False),
sa.Column('registration_number', sa.VARCHAR(), nullable=False, unique=True),
sa.Column('creation_date', postgresql.TIMESTAMP(
), nullable=False, server_default=sa.text('(NOW())')),
sa.Column('expiry_date', postgresql.TIMESTAMP(
), nullable=False, server_default=sa.text("(NOW() + interval '1 year')")),
sa.Column('certificate', postgresql.BYTEA(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.ForeignKeyConstraint(['registration_id'], [
'registrations.id'], name='certificates_registration_id_fkey')
)


def downgrade():
op.drop_table('certificates')
572 changes: 571 additions & 1 deletion strr-api/poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions strr-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pydantic = "^2.7.1"
google-auth = "^2.29.0"
google-cloud-storage = "^2.16.0"
geoalchemy2 = "^0.15.1"
weasyprint = "^62.3"

[tool.poetry.group.test.dependencies]
freezegun = "^1.2.2"
Expand Down
15 changes: 15 additions & 0 deletions strr-api/src/strr_api/enums/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,25 @@ class RegistrationStatus(Enum):

PENDING = "pending"
APPROVED = "approved"
ISSUED = "issued"
UNDER_REVIEW = "under review"
MORE_INFO_NEEDED = "more info needed"
PROVISIONAL = "provisional"
DENIED = "denied"


class RegistrationSortBy(Enum):
"""STRR Registration Sort By Columns."""

ID = 0
USER_ID = 1
SBC_ACCOUNT_ID = 2
RENTAL_PROPERTY_ID = 3
SUBMISSION_DATE = 4
UPDATED_DATE = 5
STATUS = 6


class PropertyType(Enum):
"""STRR Property Type."""

Expand Down Expand Up @@ -106,6 +119,8 @@ class EventRecordType(Enum):
AUTO_APPROVAL_FULL_REVIEW = "automatically marked for full review"
AUTO_APPROVAL_PROVISIONAL = "automatically marked as provisionally approved"
AUTO_APPROVAL_APPROVED = "automatically marked as approved"
MANUALLY_APPROVED = "marked as approved by examiner"
CERTIFICATE_ISSUED = "certificate issued by examiner"


class PaymentStatus(Enum):
Expand Down
3 changes: 2 additions & 1 deletion strr-api/src/strr_api/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class ExternalServiceException(BaseExceptionE):

def __post_init__(self):
"""Return a valid ExternalServiceException."""
self.message = "3rd party service error while processing request."
if not self.message:
self.message = "3rd party service error while processing request."
self.error = f"{repr(self.error)}, {self.status_code}"
if not self.status_code:
self.status_code = HTTPStatus.BAD_GATEWAY
1 change: 1 addition & 0 deletions strr-api/src/strr_api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# POSSIBILITY OF SUCH DAMAGE.
"""This exports all of the models and schemas used by the application."""
from .auto_approval_record import AutoApprovalRecord
from .certificate import Certificate
from .db import db # noqa: I001
from .dss import DSSOrganization
from .event_record import EventRecord
Expand Down
21 changes: 21 additions & 0 deletions strr-api/src/strr_api/models/certificate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
ORM Mapping for Certificate Records
"""
from __future__ import annotations

from sqlalchemy.sql import text

from .db import db


class Certificate(db.Model):
"""Certificate Record"""

__tablename__ = "certificates"

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
registration_id = db.Column(db.Integer, db.ForeignKey("registrations.id"), nullable=False)
registration_number = db.Column(db.String, nullable=False)
creation_date = db.Column(db.DateTime, nullable=False, server_default=text("(NOW())"))
expiry_date = db.Column(db.DateTime, nullable=False, server_default=text("(NOW() + interval '1 year')"))
certificate = db.Column(db.LargeBinary, nullable=False)
5 changes: 2 additions & 3 deletions strr-api/src/strr_api/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ def find_by_id(cls, submitter_id: int = None) -> User | None:
"""Return a User if they exist and match the provided submitter id."""
return cls.query.filter_by(id=submitter_id).one_or_none()

@classmethod
def is_examiner(cls) -> bool:
def is_examiner(self) -> bool:
"""Return True if User is an examiner."""
return False
return self.login_source == "IDIR"

@classmethod
def find_by_jwt_token(cls, token: dict) -> User | None:
Expand Down
Loading

0 comments on commit f2ddfe6

Please sign in to comment.