Skip to content

Commit c150c7f

Browse files
Merge pull request #159 from abnamro/2568373-rule-pack-traceability
2568373 rule pack traceability
2 parents 330764e + d75d545 commit c150c7f

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""rulepack traceability
2+
3+
Revision ID: 70fd7051e03a
4+
Revises: 44ac9602612b
5+
Create Date: 2023-08-15 10:44:17.483160
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '70fd7051e03a'
14+
down_revision = '44ac9602612b'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
op.add_column('rule_pack', sa.Column('created', sa.DateTime(), nullable=False, server_default=sa.func.now()))
21+
22+
23+
def downgrade():
24+
op.drop_column('rule_pack', 'created')

components/resc-backend/src/resc_backend/db/model/rule_pack.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Standard Library
2+
from datetime import datetime
3+
14
# Third Party
2-
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
5+
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
36

47
# First Party
58
from resc_backend.db.model import Base
@@ -11,17 +14,21 @@ class DBrulePack(Base):
1114
version = Column("version", String(100), primary_key=True)
1215
global_allow_list = Column(Integer, ForeignKey(DBruleAllowList.id_), nullable=True)
1316
active = Column(Boolean, nullable=False, default=False)
17+
created = Column(DateTime, nullable=False, default=datetime.utcnow)
1418

15-
def __init__(self, version: str, global_allow_list: int = None, active: bool = False):
19+
def __init__(self, version: str, global_allow_list: int = None, active: bool = False,
20+
created: datetime = datetime.utcnow()):
1621
self.version = version
1722
self.global_allow_list = global_allow_list
1823
self.active = active
24+
self.created = created
1925

2026
@staticmethod
21-
def create_from_metadata(version: str, global_allow_list: int, active: bool):
27+
def create_from_metadata(version: str, global_allow_list: int, active: bool, created):
2228
db_rule_pack = DBrulePack(
2329
version=version,
2430
global_allow_list=global_allow_list,
2531
active=active,
32+
created=created
2633
)
2734
return db_rule_pack

components/resc-backend/src/resc_backend/resc_web_service/schema/rule_pack.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint: disable=no-name-in-module
22
# Standard Library
3+
import datetime
34
from typing import Optional
45

56
# Third Party
@@ -29,6 +30,7 @@ class RulePack(RulePackBase):
2930

3031
class RulePackRead(RulePackBase):
3132
version: constr(regex=RULE_PACK_VERSION_REGEX)
33+
created: datetime.datetime
3234

3335
class Config:
3436
orm_mode = True

components/resc-frontend/src/views/RulePacks.vue

+13
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<script>
8787
import AxiosConfig from '@/configuration/axios-config.js';
8888
import Config from '@/configuration/config';
89+
import DateUtils from '@/utils/date-utils';
8990
import Spinner from '@/components/Common/Spinner.vue';
9091
import RulePackUploadModal from '@/components/RulePack/RulePackUploadModal.vue';
9192
import Pagination from '@/components/Common/Pagination.vue';
@@ -119,6 +120,14 @@ export default {
119120
class: 'text-left position-sticky',
120121
thStyle: { borderTop: '0px' },
121122
},
123+
{
124+
key: 'created',
125+
sortable: true,
126+
label: 'Created',
127+
class: 'text-left position-sticky',
128+
thStyle: { borderTop: '0px' },
129+
formatter: 'formatDate',
130+
},
122131
{
123132
key: 'download',
124133
sortable: false,
@@ -182,6 +191,10 @@ export default {
182191
AxiosConfig.handleError(error);
183192
});
184193
},
194+
formatDate(timestamp) {
195+
const date = DateUtils.formatDate(timestamp);
196+
return timestamp ? date : 'Not Scanned';
197+
},
185198
},
186199
187200
created() {

0 commit comments

Comments
 (0)