Skip to content

Commit

Permalink
Merge pull request #5439 from bcgov/dev-NK-FOIMOD-3199
Browse files Browse the repository at this point in the history
add missing model file for historical records.py
  • Loading branch information
nkan-aot2 authored Nov 15, 2024
2 parents cfcf826 + d846a06 commit 44593f0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions request-management-api/request_api/models/HistoricalRecords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from flask.app import Flask
from sqlalchemy.sql.schema import ForeignKey, ForeignKeyConstraint
from .db import db, ma
from datetime import datetime
from sqlalchemy.orm import relationship,backref
from .default_method_result import DefaultMethodResult
from sqlalchemy.sql.expression import distinct
from sqlalchemy import or_,and_,text

class HistoricalRecords(db.Model):
# Name of the table in our database
__tablename__ = 'HistoricalRecords'

# Defining the columns
historicalrecordid = db.Column(db.Integer, primary_key=True,autoincrement=True)
recordfilename = db.Column(db.String(500), unique=False, nullable=False)
description = db.Column(db.String(500), unique=False, nullable=True)
axisrequestid = db.Column(db.String(120), unique=False, nullable=False)
s3uripath = db.Column(db.Text, unique=False, nullable=False)
attributes = db.Column(db.Text, unique=False, nullable=True)
iscorresponcedocument = db.Column(db.Boolean, unique=False, nullable=False)
displayfilename = db.Column(db.String(500), unique=False, nullable=True)

created_at = db.Column(db.DateTime, default=datetime.now)
createdby = db.Column(db.String(120), unique=False, nullable=True)

@classmethod
def getdocuments(cls,axisrequestid):
comment_schema = HistoricalRecordschema(many=True)
query = db.session.query(HistoricalRecords).filter_by(axisrequestid=axisrequestid).order_by(HistoricalRecords.attributes.desc(), HistoricalRecords.historicalrecordid.asc()).all()
return comment_schema.dump(query)



class HistoricalRecordschema(ma.Schema):
class Meta:
fields = ('historicalrecordid', 'recordfilename', 'description', 'axisrequestid', 's3uripath', 'attributes', 'iscorresponcedocument', 'displayfilename', 'created_at', 'createdby')

0 comments on commit 44593f0

Please sign in to comment.