Skip to content

Commit

Permalink
feat: add options and preferences assistants (#432)
Browse files Browse the repository at this point in the history
* Add module enable fields to site info table
* Add active module fields for all modules
* Use panel for options assistant
  • Loading branch information
weibullguy authored Jan 14, 2021
1 parent 254d4b2 commit d854cf4
Show file tree
Hide file tree
Showing 24 changed files with 883 additions and 398 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
- id: docformatter
args: [-c]
- repo: https://github.com/weibullguy/pycodestyle
rev: 2.6.1
rev: '2.6.1'
hooks:
- id: pycodestyle
args: [--config, ./setup.cfg]
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ RADON = $(shell which radon)
YAPF = $(shell which yapf)
WORKBRANCH = $(shell git rev-parse --abbrev-ref HEAD)
RSTCHECK = $(shell which rstcheck)
RSTLINT = $(shell which rst-link)
CHKMANI = $(shell which check-manifest)
PYROMA = $(shell which pyroma)

Expand Down Expand Up @@ -266,7 +265,6 @@ dupcheck:

lintdocs:
$(RSTCHECK) -r docs/api docs/user
$(RSTLINT) -r docs/api docs/user

apidocs:
sphinx-apidoc -f -o docs/api src/ramstk
Expand Down
43 changes: 26 additions & 17 deletions data/postgres_common_db.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
DROP DATABASE IF EXISTS ramstk_common_ramstk;
CREATE DATABASE ramstk_common_ramstk;
\c ramstk_common_ramstk;

CREATE TABLE IF NOT EXISTS ramstk_user (
fld_user_id INTEGER NOT NULL,
fld_user_lname VARCHAR ( 256 ),
fld_user_fname VARCHAR ( 256 ),
fld_user_email VARCHAR ( 256 ),
fld_user_phone VARCHAR ( 256 ),
fld_user_group_id VARCHAR ( 256 ),
fld_user_lname VARCHAR ( 256 ),
fld_user_fname VARCHAR ( 256 ),
fld_user_email VARCHAR ( 256 ),
fld_user_phone VARCHAR ( 256 ),
fld_user_group_id VARCHAR ( 256 ),
PRIMARY KEY(fld_user_id)
);
INSERT INTO ramstk_user VALUES (1,'Tester','Johnny','[email protected]','+1.269.867.5309','1');
Expand Down Expand Up @@ -256,16 +252,29 @@ INSERT INTO ramstk_stakeholders VALUES (4,'Management');

CREATE TABLE IF NOT EXISTS ramstk_site_info (
fld_site_id INTEGER NOT NULL,
fld_product_key VARCHAR ( 512 ),
fld_expire_on DATE,
fld_function_enabled INTEGER,
fld_requirement_enabled INTEGER,
fld_hardware_enabled INTEGER,
fld_vandv_enabled INTEGER,
fld_fmea_enabled INTEGER,
fld_site_name VARCHAR(512),
fld_product_key VARCHAR(512),
fld_expire_on DATE,
fld_function_enabled INTEGER,
fld_requirement_enabled INTEGER,
fld_hardware_enabled INTEGER,
fld_software_enabled INTEGER,
fld_rcm_enabled INTEGER,
fld_testing_enabled INTEGER,
fld_incident_enabled INTEGER,
fld_survival_enabled INTEGER,
fld_vandv_enabled INTEGER,
fld_hazard_enabled INTEGER,
fld_stakeholder_enabled INTEGER,
fld_allocation_enabled INTEGER,
fld_similar_item_enabled INTEGER,
fld_fmea_enabled INTEGER,
fld_pof_enabled INTEGER,
fld_rbd_enabled INTEGER,
fld_fta_enabled INTEGER,
PRIMARY KEY(fld_site_id)
);
INSERT INTO ramstk_site_info VALUES (1,'0000','2019-08-20',0,0,0,0,0);
INSERT INTO ramstk_site_info VALUES (1,'DEMO SITE','DEMO',CURRENT_DATE + 30,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0);

CREATE TABLE IF NOT EXISTS ramstk_rpn (
fld_rpn_id INTEGER NOT NULL,
Expand Down
20 changes: 12 additions & 8 deletions data/postgres_program_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,26 @@ CREATE TABLE ramstk_program_info (
fld_requirement_active INTEGER,
fld_hardware_active INTEGER,
fld_software_active INTEGER,
fld_vandv_active INTEGER,
fld_fmea_active INTEGER,
fld_rcm_active INTEGER,
fld_testing_active INTEGER,
fld_fraca_active INTEGER,
fld_incident_active INTEGER,
fld_survival_active INTEGER,
fld_rcm_active INTEGER,
fld_vandv_active INTEGER,
fld_hazard_active INTEGER,
fld_stakeholder_active INTEGER,
fld_allocation_active INTEGER,
fld_similar_item_active INTEGER,
fld_fmea_active INTEGER,
fld_pof_active INTEGER,
fld_rbd_active INTEGER,
fld_fta_active INTEGER,
fld_created_on DATE,
fld_created_on DATE DEFAULT CURRENT_DATE,
fld_created_by VARCHAR(512),
fld_last_saved_on DATE,
fld_last_saved_on DATE DEFAULT CURRENT_DATE,
fld_last_saved_by VARCHAR(512),
fld_method VARCHAR(512),
PRIMARY KEY (fld_revision_id)
);
INSERT INTO "ramstk_program_info" VALUES(1,1,1,1,1,1,1,1,1,1,0,0,0,'2019-07-21','','2019-07-21','','STANDARD');
INSERT INTO "ramstk_program_info" VALUES(1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,CURRENT_DATE,'',CURRENT_DATE,'');
CREATE TABLE ramstk_program_status (
fld_revision_id INTEGER NOT NULL,
fld_status_id INTEGER NOT NULL,
Expand Down
20 changes: 12 additions & 8 deletions devtools/test_program_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,26 @@ CREATE TABLE ramstk_program_info (
fld_requirement_active INTEGER,
fld_hardware_active INTEGER,
fld_software_active INTEGER,
fld_vandv_active INTEGER,
fld_fmea_active INTEGER,
fld_rcm_active INTEGER,
fld_testing_active INTEGER,
fld_fraca_active INTEGER,
fld_incident_active INTEGER,
fld_survival_active INTEGER,
fld_rcm_active INTEGER,
fld_vandv_active INTEGER,
fld_hazard_active INTEGER,
fld_stakeholder_active INTEGER,
fld_allocation_active INTEGER,
fld_similar_item_active INTEGER,
fld_fmea_active INTEGER,
fld_pof_active INTEGER,
fld_rbd_active INTEGER,
fld_fta_active INTEGER,
fld_created_on DATE,
fld_created_on DATE DEFAULT CURRENT_DATE,
fld_created_by VARCHAR(512),
fld_last_saved_on DATE,
fld_last_saved_on DATE DEFAULT CURRENT_DATE,
fld_last_saved_by VARCHAR(512),
fld_method VARCHAR(512),
PRIMARY KEY (fld_revision_id)
);
INSERT INTO "ramstk_program_info" VALUES(1,1,1,1,1,1,1,1,1,1,0,0,0,'2019-07-21','','2019-07-21','','STANDARD');
INSERT INTO "ramstk_program_info" VALUES(1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,CURRENT_DATE,'',CURRENT_DATE,'');
CREATE TABLE ramstk_program_status (
fld_revision_id INTEGER NOT NULL,
fld_status_id INTEGER NOT NULL,
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ ignore =
D213
match = 'src/ramstk/*.py'

[rstcheck]
report = warning

[yapf]
based_on_style = pep8
split_before_arithmetic_operator = true
Expand Down
5 changes: 3 additions & 2 deletions src/ramstk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def do_connect_to_site_db(conn_info) -> BaseDatabase:
pub.sendMessage(
'do_log_info_msg',
logger_name='INFO',
message="Connecting to the RAMSTK common database {0:s}.".format(
conn_info['database']))
message="Connecting to the RAMSTK common database {0} on {1} "
"using port {2}.".format(conn_info['database'], conn_info['host'],
conn_info['port']))

_site_db = BaseDatabase()
_site_db.do_connect(conn_info)
Expand Down
4 changes: 2 additions & 2 deletions src/ramstk/controllers/options/datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def do_select_all(self, attributes: Dict[str, Any]) -> None:
# noinspection PyUnresolvedReferences
for _option in self.common_dao.session.query(RAMSTKSiteInfo).all():

self.tree.create_node(tag='Site Info',
self.tree.create_node(tag='siteinfo',
identifier='siteinfo',
parent=self._root,
data={'siteinfo': _option})
Expand All @@ -108,7 +108,7 @@ def do_select_all(self, attributes: Dict[str, Any]) -> None:
for _option in self.dao.session.query(RAMSTKProgramInfo).filter(
RAMSTKProgramInfo.revision_id == self._revision_id).all():

self.tree.create_node(tag='Program Info',
self.tree.create_node(tag='programinfo',
identifier='programinfo',
parent=self._root,
data={'programinfo': _option})
Expand Down
68 changes: 67 additions & 1 deletion src/ramstk/models/commondb/ramstksiteinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,28 @@ class RAMSTKSiteInfo(RAMSTK_BASE, RAMSTKBaseTable):
"""Class to represent ramstk_site_info in the RAMSTK Common database."""

__defaults__ = {
'site_name': '',
'product_key': '',
'expire_on': date.today() + timedelta(30),
'function_enabled': 0,
'requirement_enabled': 0,
'hardware_enabled': 0,
'software_enabled': 0,
'rcm_enabled': 0,
'testing_enabled': 0,
'incident_enabled': 0,
'survival_enabled': 0,
'vandv_enabled': 0,
'fmea_enabled': 0
'hazard_enabled': 0,
'stakeholder_enabled': 0,
'allocation_enabled': 0,
'similar_item_enabled': 0,
'fmea_enabled': 0,
'pof_enabled': 0,
'rbd_enabled': 0,
'fta_enabled': 0,
}

__tablename__ = 'ramstk_site_info'
__table_args__ = {'extend_existing': True}

Expand All @@ -37,6 +51,9 @@ class RAMSTKSiteInfo(RAMSTK_BASE, RAMSTKBaseTable):
primary_key=True,
autoincrement=True,
nullable=False)
site_name = Column('fld_site_name',
String(512),
default=__defaults__['site_name'])
product_key = Column('fld_product_key',
String(512),
default=__defaults__['product_key'])
Expand All @@ -52,12 +69,48 @@ class RAMSTKSiteInfo(RAMSTK_BASE, RAMSTKBaseTable):
hardware_enabled = Column('fld_hardware_enabled',
Integer,
default=__defaults__['hardware_enabled'])
software_enabled = Column('fld_software_enabled',
Integer,
default=__defaults__['software_enabled'])
rcm_enabled = Column('fld_rcm_enabled',
Integer,
default=__defaults__['rcm_enabled'])
testing_enabled = Column('fld_testing_enabled',
Integer,
default=__defaults__['testing_enabled'])
incident_enabled = Column('fld_incident_enabled',
Integer,
default=__defaults__['incident_enabled'])
survival_enabled = Column('fld_survival_enabled',
Integer,
default=__defaults__['survival_enabled'])
vandv_enabled = Column('fld_vandv_enabled',
Integer,
default=__defaults__['vandv_enabled'])
hazard_enabled = Column('fld_hazard_enabled',
Integer,
default=__defaults__['hazard_enabled'])
stakeholder_enabled = Column('fld_stakeholder_enabled',
Integer,
default=__defaults__['stakeholder_enabled'])
allocation_enabled = Column('fld_allocation_enabled',
Integer,
default=__defaults__['allocation_enabled'])
similar_item_enabled = Column('fld_similar_item_enabled',
Integer,
default=__defaults__['similar_item_enabled'])
fmea_enabled = Column('fld_fmea_enabled',
Integer,
default=__defaults__['fmea_enabled'])
pof_enabled = Column('fld_pof_enabled',
Integer,
default=__defaults__['pof_enabled'])
rbd_enabled = Column('fld_rbd_enabled',
Integer,
default=__defaults__['rbd_enabled'])
fta_enabled = Column('fld_fta_enabled',
Integer,
default=__defaults__['fta_enabled'])

def get_attributes(self):
"""Retrieve current values of the RAMSTKSiteInfo data model attributes.
Expand All @@ -68,13 +121,26 @@ def get_attributes(self):
"""
_attributes = {
'site_id': self.site_id,
'site_name': self.site_name,
'product_key': self.product_key,
'expire_on': self.expire_on,
'function_enabled': self.function_enabled,
'requirement_enabled': self.requirement_enabled,
'hardware_enabled': self.hardware_enabled,
'software_enabled': self.software_enabled,
'rcm_enabled': self.rcm_enabled,
'testing_enabled': self.testing_enabled,
'incident_enabled': self.incident_enabled,
'survival_enabled': self.survival_enabled,
'vandv_enabled': self.vandv_enabled,
'hazard_enabled': self.hazard_enabled,
'stakeholder_enabled': self.stakeholder_enabled,
'allocation_enabled': self.allocation_enabled,
'similar_item_enabled': self.similar_item_enabled,
'fmea_enabled': self.fmea_enabled,
'pof_enabled': self.pof_enabled,
'rbd_enabled': self.rbd_enabled,
'fta_enabled': self.fta_enabled,
}

return _attributes
35 changes: 35 additions & 0 deletions src/ramstk/models/commondb/ramstksiteinfo.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Standard Library Imports
from typing import Any

# RAMSTK Package Imports
from ramstk.db import RAMSTK_BASE as RAMSTK_BASE
from ramstk.models import RAMSTKBaseTable as RAMSTKBaseTable

class RAMSTKSiteInfo(RAMSTK_BASE, RAMSTKBaseTable):
__defaults__: Any = ...
__tablename__: str = ...
__table_args__: Any = ...
site_id: Any = ...
site_name: Any = ...
product_key: Any = ...
expire_on: Any = ...
function_enabled: Any = ...
requirement_enabled: Any = ...
hardware_enabled: Any = ...
software_enabled: Any = ...
rcm_enabled: Any = ...
testing_enabled: Any = ...
incident_enabled: Any = ...
survival_enabled: Any = ...
vandv_enabled: Any = ...
hazard_enabled: Any = ...
stakeholder_enabled: Any = ...
allocation_enabled: Any = ...
similar_item_enabled: Any = ...
fmea_enabled: Any = ...
pof_enabled: Any = ...
rbd_enabled: Any = ...
fta_enabled: Any = ...

def get_attributes(self):
...
Loading

0 comments on commit d854cf4

Please sign in to comment.